forkme right red aa0000

About

This repository contains examples on how to use Gradle and Asciidoctor to create html5, pdf, epub, deck.js, and reveal.js outputs.

1. Diagrams HTML Example

An example project that demonstrates how to convert AsciiDoc with diagrams to HTML5 using the Asciidoctor Gradle plugin.

1.1. Usage

Convert the AsciiDoc to HTML5 by invoking the 'asciidoctor' goal:

$ ./gradlew asciidoctor

Open the file build/asciidoc/html/example-manual.html in your browser to see the generated HTML file.

1.2. Source

1.3. Outputs

2. HTML, PDF, DocBook & epub3 Example

An example project that demonstrates how to convert AsciiDoc to HTML, PDF, DocBook & epub3 using the Asciidoctor Gradle plugin.

2.1. Usage

Convert the AsciiDoc to HTML, PDF, DocBook & epub3 by invoking the 'asciidoctor' goal:

$ ./gradlew asciidoctor

Open the file build/asciidoc/epub3/example-manual.epub in your browser to see the generated epub file.

Open the file build/asciidoc/html5/example-manual.html in your browser to see the generated HTML file.

Open the file build/asciidoc/pdf/example-manual.pdf in your browser to see the generated PDF file.

Open the file build/asciidoc/pdf/example-manual.xml in your browser to see the generated DocBook file.

2.2. Source

2.3. Outputs

3. deck.js Example

An example project that demonstrates how to convert AsciiDoc to deck.js using the Asciidoctor Gradle plugin.

3.1. Usage

Convert the AsciiDoc to deck.js by invoking the 'asciidoctor' goal:

$ ./gradlew clean asciidoctor

3.2. IntelliJ

If you’re using IntelliJ you can generate the IDE’s files via:

$ ./gradlew idea

Open the file build/asciidoc/deckjs/example-manual.html in your browser to see the generated deckjs file.

3.3. Source

3.4. Outputs

4. epub3 Example

An example project that demonstrates how to convert AsciiDoc to epub3 using the Asciidoctor Gradle plugin.

4.1. Usage

Convert the AsciiDoc to epub3 by invoking the 'asciidoctor' goal:

$ ./gradlew asciidoctor

Open the file build/asciidoc/epub3/example-manual.epub in your browser to see the generated epub3 file.

4.2. Source

4.3. Outputs

5. Publish to GitHub Pages Example

An example project that demonstrates how to publish the HTML generated by the Gradle AsciiDoctor Plugin to GitHub pages using the Gradle Git Plugin.

5.1. Setup

You’ll need to do the following:

  1. Create a personal access token in Github (found within Settings → Applications).

  2. Create a gh-pages branch within your destination git repository.

  3. Modify you build.gradle and gradle.properties files (see below).

build.gradle
githubPages {
	repoUri = 'https://github.com/asciidoctor/asciidoctor-gradle-examples.git' (1)
	credentials { (2)
		username = project.hasProperty('githubToken') ? project.githubToken : ''
		password = ''
	}

	pages {
		from 'build/asciidoc/html5'
	}
}
1 The repoUri property should be set to the destination repo.
2 Use the personal access token from step 1 to set the githubToken property in a gradle.properties file within the root of the project or better yet in ~/.gradle/gradle.properties

5.2. Usage

  1. Add your asciidoc files to src/docs/asciidoc

  2. ./gradlew publishGhPages

5.3. Source

5.4. Outputs

6. HTML Example

An example project that demonstrates how to convert AsciiDoc to HTML5 using the Asciidoctor Gradle plugin.

6.1. Usage

Convert the AsciiDoc to HTML5 by invoking the 'asciidoctor' goal:

$ ./gradlew asciidoctor

Open the file build/asciidoc/html/example-manual.html in your browser to see the generated HTML file.

6.2. Source

6.3. Outputs

7. LiveReload HTML Example

An example project that demonstrates how to convert AsciiDoc to HTML5 using the Asciidoctor Gradle plugin with Live Reload support.

7.1. Usage

Convert the AsciiDoc to HTML5 by invoking the 'asciidoctor' goal:

$ ./gradlew asciidoctor

Open the file build/asciidoc/html/example-manual.html in your browser to see the generated HTML file.

7.2. Live Reload Support

The Gradle build also can support Live Reload

Start by running the build with Gradle 2.5+ continuous build feature.

$ ./gradlew -t asciidoctor

This ensures if you modify example-manual.adoc then everything is rebuilt.

Open another terminal and run the liveReload task:

$ ./gradlew liveReload

Now you can use the Chrome or Firefox plugins to automatically reload your browser when the build completes.

After installing the Chrome LiveReload extension, you need to check the "Allow access to file URLs" checkbox in Tools > Extensions > LiveReload in order for it to work with local files.

Now try editing example-manual.adoc and watching your browser. After a brief wait you will observe that the browser is automatically updated with your changes.

7.3. Source

7.4. Outputs

8. PDF Example

An example project that demonstrates how to convert AsciiDoc to PDF using the Asciidoctor Gradle plugin.

8.1. Usage

Convert the AsciiDoc to PDF by invoking the 'asciidoctor' goal:

$ ./gradlew asciidoctor

Open the file build/asciidoc/pdf/example-manual.pdf in your browser to see the generated PDF file.

8.2. Source

8.3. Outputs

9. Asciidoctor Gradle Plugin: AsciiDoc to (themed) PDF Example

An example project that demonstrates how to convert AsciiDoc to PDF using Asciidoctor PDF with the Asciidoctor Gradle plugin. This example produces a book and makes use of a YAML style sheet (defined in src/docs/asciidoc/theme).

The rendered document is created in the build/pdf directory.

9.1. Usage

Convert the AsciiDoc to PDF using Asciidoctor PDF by invoking the asciidoctor task (configured as the default task):

$ ./gradlew

This example is based on this maven example.

9.2. Source

9.3. Outputs

10. reveal.js Example

An example project that demonstrates how to convert AsciiDoc to reveal.js using the Asciidoctor Gradle plugin.

10.1. Usage

Convert the AsciiDoc to reveal.js by invoking the 'asciidoctor' goal:

$ ./gradlew clean asciidoctor

10.2. IntelliJ

If you’re using IntelliJ you can generate the IDE’s files via:

$ ./gradlew idea

Open the file build/asciidoc/reveal/example-manual.html in your browser to see the generated revealjs file.

10.3. Source

10.4. Outputs