use of com.vladsch.flexmark.parser.Parser in project flexmark-java by vsch.
the class DelimiterProcessorTest method delimiterProcessorWithInvalidDelimiterUse.
@Test
public void delimiterProcessorWithInvalidDelimiterUse() {
Parser parser = Parser.builder().customDelimiterProcessor(new CustomDelimiterProcessor(':', 0)).customDelimiterProcessor(new CustomDelimiterProcessor(';', -1)).build();
assertEquals("<p>:test:</p>\n", RENDERER.render(parser.parse(":test:")));
assertEquals("<p>;test;</p>\n", RENDERER.render(parser.parse(";test;")));
}
use of com.vladsch.flexmark.parser.Parser in project flexmark-java by vsch.
the class ParserTest method indentation.
@Test
public void indentation() {
String given = " - 1 space\n - 3 spaces\n - 5 spaces\n\t - tab + space";
Parser parser = Parser.builder().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());
}
use of com.vladsch.flexmark.parser.Parser in project flexmark-java by vsch.
the class TextCollectingVisitorTest method test_basic.
@Test
public void test_basic() {
Parser parser = Parser.builder().build();
Node document = parser.parse("Test text");
TextCollectingVisitor collectingVisitor = new TextCollectingVisitor();
final String text = collectingVisitor.collectAndGetText(document);
assertEquals("Test text", text);
}
use of com.vladsch.flexmark.parser.Parser in project flexmark-java by vsch.
the class TextCollectingVisitorTest method test_fenced_code.
@Test
public void test_fenced_code() {
Parser parser = Parser.builder().build();
Node document = parser.parse("```info\nfenced code\nlines\n```");
TextCollectingVisitor collectingVisitor = new TextCollectingVisitor();
final String text = collectingVisitor.collectAndGetText(document);
assertEquals("fenced code\nlines\n", text);
}
use of com.vladsch.flexmark.parser.Parser in project flexmark-java by vsch.
the class TextCollectingVisitorTest method test_emphasis.
@Test
public void test_emphasis() {
Parser parser = Parser.builder().build();
Node document = parser.parse("Test text *emphasis*");
TextCollectingVisitor collectingVisitor = new TextCollectingVisitor();
final String text = collectingVisitor.collectAndGetText(document);
assertEquals("Test text emphasis", text);
}
Aggregations