use of com.vladsch.flexmark.parser.Parser in project flexmark-java by vsch.
the class TitleExtract method main.
public static void main(String[] args) {
Parser parser = Parser.builder(OPTIONS).build();
HtmlRenderer renderer = HtmlRenderer.builder(OPTIONS).build();
// You can re-use parser and renderer instances
Node document = parser.parse("\n" + "# Plugin commit-message-length-validator\n" + "\n" + "Vendor\n" + ": Gerrit Code Review\n" + "\n" + "Version\n" + ": v2.15-rc2\n" + "\n" + "commitmessage.maxSubjectLength\n" + ": Maximum length of the commit message's subject line. Defaults\n" + " to 50 if not specified or less than 0.\n" + "\n" + "## About\n" + "\n" + "This plugin checks the length of a commit's commit message subject and body, and reports warnings and errors to the git client if the lentghts are exceeded.\n" + "\n" + "## Documentation\n" + "\n" + "* [Commit Message Length Configuration](config.md)\n" + "* More Items\n" + "\n" + "");
String title = findTitle(document);
System.out.println("Title: " + title + "\n");
// "<p>This is <em>Sparta</em></p>\n"
String html = renderer.render(document);
System.out.println(html);
}
use of com.vladsch.flexmark.parser.Parser in project flexmark-java by vsch.
the class VisitorSample method countWords.
void countWords() {
Parser parser = Parser.builder().build();
Node document = parser.parse("Example\n=======\n\nSome more text");
visitor.visit(document);
// 4
System.out.println(wordCount);
}
use of com.vladsch.flexmark.parser.Parser in project flexmark-java by vsch.
the class ComboParserTest method testWrap.
// @Test
public void testWrap() throws Exception {
if (!example.isFullSpecExample())
return;
final HtmlRenderer RENDERER = HtmlRenderer.builder(OPTIONS).build();
final Parser PARSER = Parser.builder(OPTIONS).build();
String source = readResource("/wrap.md");
String html = readResource("/wrap.html");
assertRendering(source, html);
}
use of com.vladsch.flexmark.parser.Parser in project flexmark-java by vsch.
the class ComboTableSpecTest method testTable.
@Test
public void testTable() throws Exception {
if (!example.isFullSpecExample())
return;
final HtmlRenderer RENDERER = HtmlRenderer.builder(OPTIONS).build();
final Parser PARSER = Parser.builder(OPTIONS).build();
String source = readResource("/table.md");
String html = readResource("/table.html");
assertRendering(source, html);
}
use of com.vladsch.flexmark.parser.Parser in project flexmark-java by vsch.
the class DelimitedNodeTest method emphasisDelimiters.
@Test
public void emphasisDelimiters() {
String input = "* *emphasis* \n" + "* **strong** \n" + "* _important_ \n" + "* __CRITICAL__ \n";
Parser parser = Parser.builder().build();
Node document = parser.parse(input);
final List<DelimitedNode> list = new ArrayList<DelimitedNode>();
NodeVisitor visitor = new NodeVisitor(new VisitHandler<Emphasis>(Emphasis.class, new Visitor<Emphasis>() {
@Override
public void visit(Emphasis e) {
list.add(e);
}
}), new VisitHandler<StrongEmphasis>(StrongEmphasis.class, new Visitor<StrongEmphasis>() {
@Override
public void visit(StrongEmphasis e) {
list.add(e);
}
}));
visitor.visit(document);
assertEquals(4, list.size());
DelimitedNode emphasis = list.get(0);
DelimitedNode strong = list.get(1);
DelimitedNode important = list.get(2);
DelimitedNode critical = list.get(3);
assertEquals("*", String.valueOf(emphasis.getOpeningMarker()));
assertEquals("*", String.valueOf(emphasis.getClosingMarker()));
assertEquals("**", String.valueOf(strong.getOpeningMarker()));
assertEquals("**", String.valueOf(strong.getClosingMarker()));
assertEquals("_", String.valueOf(important.getOpeningMarker()));
assertEquals("_", String.valueOf(important.getClosingMarker()));
assertEquals("__", String.valueOf(critical.getOpeningMarker()));
assertEquals("__", String.valueOf(critical.getClosingMarker()));
}
Aggregations