use of com.vladsch.flexmark.util.options.MutableDataHolder in project flexmark-java by vsch.
the class XWikiMacrosSample method main.
public static void main(String[] args) {
MutableDataHolder options = new MutableDataSet();
options.set(Parser.EXTENSIONS, Arrays.asList(MacroExtension.create()));
Parser parser = Parser.builder(options).build();
HtmlRenderer renderer = HtmlRenderer.builder(options).build();
String markdown = "markdown content here";
Node document = parser.parse(markdown);
XWikiMacrosSample macroProcessor = new XWikiMacrosSample();
macroProcessor.visitor.visitChildren(document);
}
use of com.vladsch.flexmark.util.options.MutableDataHolder in project flexmark-java by vsch.
the class ParserTest method indentationWithLines.
@Test
public void indentationWithLines() {
String given = " - 1 space\n - 3 spaces\n - 5 spaces\n\t - tab + space";
MutableDataHolder options = new MutableDataSet().set(Parser.TRACK_DOCUMENT_LINES, true);
Parser parser = Parser.builder(options).build();
Document document = parser.parse(given);
assertThat(document.getFirstChild(), instanceOf(BulletList.class));
assertEquals("Document line count", 4, document.getLineCount());
// first level list
Node list = document.getFirstChild();
assertEquals("expect one child", list.getFirstChild(), list.getLastChild());
assertEquals("1 space", firstText(list.getFirstChild()));
assertEquals("node start line number", 0, list.getStartLineNumber());
assertEquals("node end line number", 3, list.getEndLineNumber());
// second level list
list = list.getFirstChild().getLastChild();
assertEquals("expect one child", list.getFirstChild(), list.getLastChild());
assertEquals("3 spaces", firstText(list.getFirstChild()));
assertEquals("node start line number", 1, list.getStartLineNumber());
assertEquals("node end line number", 3, list.getEndLineNumber());
// third level list
list = list.getFirstChild().getLastChild();
assertEquals("5 spaces", firstText(list.getFirstChild()));
assertEquals("tab + space", firstText(list.getFirstChild().getNext()));
assertEquals("node start line number", 2, list.getStartLineNumber());
assertEquals("node end line number", 3, list.getEndLineNumber());
}
Aggregations