diff --git a/helpers/content.go b/helpers/content.go index f8479cd1b9a..75cb26d9c9c 100644 --- a/helpers/content.go +++ b/helpers/content.go @@ -640,13 +640,49 @@ func getAsciidocContent(ctx *RenderingContext) []byte { } jww.INFO.Println("Rendering", ctx.DocumentName, "with", path, "...") - args := []string{"--no-header-footer", "--safe"} + args := []string{"--no-header-footer", "--safe", "--attribute=toc"} if isAsciidoctor { // asciidoctor-specific arg to show stack traces on errors args = append(args, "--trace") } args = append(args, "-") - return externallyRenderContent(ctx, path, args) + return replaceAsciidocTOC(externallyRenderContent(ctx, path, args)) +} + +// replaceAsciidocTOC replaces html tags for TOC for compatibility with blackfriday rendered TOC. +func replaceAsciidocTOC(content []byte) []byte { + first := []byte(`