Open arctrong opened 3 years ago
To Reproduce
private static String generateHtml(String mdText) { MutableDataSet options = new MutableDataSet(); options.set(Parser.EXTENSIONS, Arrays.asList(TocExtension.create())); Parser parser = Parser.builder(options).build(); HtmlRenderer renderer = HtmlRenderer.builder(options).build(); Node document = parser.parse(mdText); return renderer.render(document); }
Give it the following input:
[TOC] # Level 1 ## Level 2 ### Level 3
Expected behavior
<div class="toc"> <ul> <li><a href="#level-1">Level 1</a><ul> <li><a href="#level-2">Level 2</a><ul> <li><a href="#level-3">Level 3</a></li> </ul> </li> </ul> </li> </ul> </div> <h1 id="level-1">Level 1</h1> <h2 id="level-2">Level 2</h2> <h3 id="level-3">Level 3</h3>
Resulting Output
<ul> <li><a href="#level-1">Level 1</a><ul> <li><a href="#level-2">Level 2</a><ul> <li><a href="#level-3">Level 3</a></li> </ul> </li> </ul> </li> </ul> <h1 id="level-1">Level 1</h1> <h2 id="level-2">Level 2</h2> <h3 id="level-3">Level 3</h3>
Additional comments
If this is already implemented, please make it clear how to obtain this result. This page doesn't help. Thanks.
[TOC] isn't part of the Markdown standard. I contend that such a concept doesn't belong in Markdown.
[TOC]
Instead, flexmark-java could have an option to export a ToC as part of its configuration, rather than as a processing instruction inside a document.
To Reproduce
Give it the following input:
Expected behavior
Resulting Output
Additional comments
If this is already implemented, please make it clear how to obtain this result. This page doesn't help. Thanks.