Skip to content

Instantly share code, notes, and snippets.

@der3k
Created July 6, 2013 10:50
Show Gist options
  • Select an option

  • Save der3k/5939558 to your computer and use it in GitHub Desktop.

Select an option

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

tolleiv commented Jan 31, 2017

Copy link
Copy Markdown

Thanks for sharing!

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