use of org.commonmark.node.Node in project FastHub by k0shk0sh.
the class MentionDelimiterProcessor method process.
@Override
public void process(Text opener, Text closer, int delimiterCount) {
Node mention = new Mention();
Node tmp = opener.getNext();
while (tmp != null && tmp != closer) {
Node next = tmp.getNext();
mention.appendChild(tmp);
tmp = next;
}
opener.insertAfter(mention);
}
use of org.commonmark.node.Node in project FastHub by k0shk0sh.
the class MentionNodeRenderer method renderChildren.
private void renderChildren(Node parent) {
Node node = parent.getFirstChild();
while (node != null) {
Node next = node.getNext();
context.render(node);
node = next;
}
}
use of org.commonmark.node.Node in project gitiles by GerritCodeReview.
the class DocServlet method showDoc.
private void showDoc(HttpServletRequest req, HttpServletResponse res, GitilesView view, MarkdownToHtml.Builder fmt, Navbar navbar, MarkdownFile srcFile) throws IOException {
Map<String, Object> data = new HashMap<>();
data.putAll(navbar.toSoyData());
MarkdownConfig cfg = navbar.getConfig();
Node doc = GitilesMarkdown.parse(cfg, srcFile.consumeContent());
data.put("pageTitle", pageTitle(doc, srcFile));
if (view.getType() != GitilesView.Type.ROOTED_DOC) {
data.put("sourceUrl", GitilesView.show().copyFrom(view).toUrl());
data.put("logUrl", GitilesView.log().copyFrom(view).toUrl());
data.put("blameUrl", GitilesView.blame().copyFrom(view).toUrl());
}
if (cfg.analyticsId != null) {
data.put("analyticsId", cfg.analyticsId);
}
try (OutputStream out = startRenderCompressedStreamingHtml(req, res, SOY_TEMPLATE, data)) {
Writer w = newWriter(out, res);
fmt.setConfig(cfg).setFilePath(srcFile.path).build().renderToHtml(new StreamHtmlBuilder(w), doc);
w.flush();
} catch (RuntimeIOException e) {
Throwables.throwIfInstanceOf(e.getCause(), IOException.class);
throw e;
}
}
use of org.commonmark.node.Node in project gitiles by GerritCodeReview.
the class GitilesHtmlExtension method inline.
private static void inline(HtmlInline curr) {
String html = curr.getLiteral();
Matcher m = BREAK.matcher(html);
if (m.matches()) {
switch(m.group(1).toLowerCase()) {
case "br":
curr.insertAfter(new HardLineBreak());
curr.unlink();
return;
case "hr":
curr.insertAfter(new ThematicBreak());
curr.unlink();
return;
}
}
m = ANCHOR_OPEN.matcher(html);
if (m.matches()) {
String name = m.group(2);
Node next = curr.getNext();
// HtmlInline{<a name="id">}HtmlInline{</a>}
if (isAnchorClose(next)) {
next.unlink();
NamedAnchor anchor = new NamedAnchor();
anchor.setName(name);
curr.insertAfter(anchor);
curr.unlink();
MarkdownUtil.trimPreviousWhitespace(anchor);
return;
}
}
}
use of org.commonmark.node.Node in project gitiles by GerritCodeReview.
the class MarkdownToHtml method visit.
private void visit(BlockNote node) {
html.open("div").attribute("class", node.getClassName());
Node f = node.getFirstChild();
if (f == node.getLastChild() && f instanceof Paragraph) {
// Avoid <p> inside <div> if there is only one <p>.
visitChildren(f);
} else {
visitChildren(node);
}
html.close("div");
}
Aggregations