use of com.vladsch.flexmark.ast.util.TextCollectingVisitor in project flexmark-java by vsch.
the class TextCollectingVisitorTest method test_basic.
@Test
public void test_basic() {
DataHolder options = new MutableDataSet().set(Parser.EXTENSIONS, Arrays.asList(TablesExtension.create()));
Parser parser = Parser.builder(options).build();
String markdown = "| First Header | Second Header |\n" + "| ------------- | ------------- |\n" + "| Content Cell | Content Cell |\n" + "\n" + "| Left-aligned | Center-aligned | Right-aligned |\n" + "| :--- | :---: | ---: |\n" + "| git status | git status | git status |\n" + "| git diff | git diff | git diff |\n" + "";
Node document = parser.parse(markdown);
TextCollectingVisitor collectingVisitor = new TextCollectingVisitor();
final String text = collectingVisitor.collectAndGetText(document);
System.out.println(text);
final String astText = new AstCollectingVisitor().collectAndGetAstText(document);
System.out.println(astText);
}
use of com.vladsch.flexmark.ast.util.TextCollectingVisitor in project flexmark-java by vsch.
the class YouTrackConverterNodeRenderer method render.
private void render(Image node, NodeRendererContext context, HtmlWriter html) {
if (!context.isDoNotRenderLinks()) {
String altText = new TextCollectingVisitor().collectAndGetText(node);
ResolvedLink resolvedLink = context.resolveLink(LinkType.IMAGE, node.getUrl().unescape(), null);
html.raw("!").raw(resolvedLink.getUrl()).raw("!");
}
}
use of com.vladsch.flexmark.ast.util.TextCollectingVisitor in project flexmark-java by vsch.
the class YouTrackConverterNodeRenderer method render.
private void render(ImageRef node, NodeRendererContext context, HtmlWriter html) {
if (!node.isDefined()) {
// empty ref, we treat it as text
assert !node.isDefined();
html.text(node.getChars().unescape());
} else {
if (!context.isDoNotRenderLinks()) {
Reference reference = node.getReferenceNode(referenceRepository);
assert reference != null;
String altText = new TextCollectingVisitor().collectAndGetText(node);
ResolvedLink resolvedLink = context.resolveLink(LinkType.IMAGE, reference.getUrl().unescape(), null);
html.raw("!").raw(resolvedLink.getUrl()).raw("!");
}
}
}
Aggregations