Add a safe option as well. By default the safe option for API is SECURE or 20 (integer value) which disables include directives to be rendered. You can use any of the below key-value pair:
'safe':'SAFE'
'safe': 1
'safe':'SERVER'
'safe': 10
'safe':'UNSAFE' //If you want
'safe': 0
Below should work.
def output = asciidoctor.renderFile(new File('index.ad'),[
'in_place':true,
'header_footer':true,
'safe':'SAFE'
])
Refer Running AsciiDoctor Securely for more details.
UPDATE
toc and section numbers are attributes in CLI, so we just need to add required attributes to options.
Simplest way:
def output = asciidoctor.renderFile(new File('index.ad'),[
'in_place':true,
'header_footer':true,
'safe':'SAFE',
'attributes': [toc: true, numbered: true] //I suppose
])
But the above tightly couples with the underlying ascii doc implementations which we wanted to abstract in the first place. Asciidoctor provides useful Builder patterns to overcome this clutter.
import static org.asciidoctor.AttributesBuilder.attributes
import static org.asciidoctor.OptionsBuilder.options
import org.asciidoctor.Placement
Attributes attributes = attributes().tableOfContents(true)
.tableOfContents2(Placement.LEFT)
.sectionNumbers(true)
.get()
Options options = options().inPlace(true)
.headerFooter(true)
.attributes(attributes)
.get()
def output = asciidoctor.renderFile(new File('index.ad'), options)
Visit this package from asciidoctor java integration and it will be pretty much clear as to how things can be tailored easily.