Skip to content

Instantly share code, notes, and snippets.

@der3k
Created July 6, 2013 10:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save der3k/5939558 to your computer and use it in GitHub Desktop.
Save der3k/5939558 to your computer and use it in GitHub Desktop.
Render Asciidoc using Groovy
@Grab('org.asciidoctor:asciidoctor-java-integration')
import org.asciidoctor.Asciidoctor
import org.asciidoctor.Attributes
import org.asciidoctor.OptionsBuilder
import org.asciidoctor.SafeMode
import static org.asciidoctor.Asciidoctor.Factory.create
//println 'Starting...'
Asciidoctor asciidoctor = create()
//println 'Asciidoctor instance created'
Attributes attr = new Attributes()
attr.linkCss = false
attr.dataUri = true
Map options = OptionsBuilder.options()
.compact(false)
.headerFooter(true)
.safe(SafeMode.UNSAFE)
.backend("html5")
.attributes(attr)
.asMap()
println asciidoctor.render("*This* is it\n\nimage::sunset.jpg[Sunset]\n", options)
//println "OK"
@tolleiv
Copy link

tolleiv commented Jan 31, 2017

Thanks for sharing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment