@Override public NodeRenderer create(final DataHolder options) { return new CoreNodeRenderer(options); } }
@Override public void render(Emphasis node, NodeRendererContext context, HtmlWriter html) { CoreNodeRenderer.this.render(node, context, html); } }),
void render(OrderedListItem node, NodeRendererContext context, HtmlWriter html) { renderListItem(node, context, html); }
@SuppressWarnings("MethodMayBeStatic") void render(AutoLink node, NodeRendererContext context, final HtmlWriter html) { final String text = node.getText().toString(); if (context.isDoNotRenderLinks() || isSuppressedLinkPrefix(node.getUrl(), context)) { html.text(text); } else { ResolvedLink resolvedLink = context.resolveLink(LinkType.LINK, text, null); html.srcPos(node.getText()).attr("href", resolvedLink.getUrl().startsWith("www.") ? context.getHtmlOptions().autolinkWwwPrefix + resolvedLink.getUrl() : resolvedLink.getUrl()) .withAttr(resolvedLink) .tag("a", false, false, new Runnable() { @Override public void run() { html.text(text); } }); } }
void render(Link node, NodeRendererContext context, HtmlWriter html) { if (context.isDoNotRenderLinks() || isSuppressedLinkPrefix(node.getUrl(), context)) { context.renderChildren(node); } else { ResolvedLink resolvedLink = context.resolveLink(LinkType.LINK, node.getUrl().unescape(), null, null); html.attr("href", resolvedLink.getUrl()); // we have a title part, use that if (node.getTitle().isNotNull()) { resolvedLink.getNonNullAttributes().replaceValue(Attribute.TITLE_ATTR, node.getTitle().unescape()); } else { resolvedLink.getNonNullAttributes().remove(Attribute.TITLE_ATTR); } html.attr(resolvedLink.getAttributes()); html.srcPos(node.getChars()).withAttr(resolvedLink).tag("a"); renderChildrenSourceLineWrapped(node, node.getText(), context, html); html.tag("/a"); } }
@SuppressWarnings("MethodMayBeStatic") void render(HtmlInnerBlockComment node, NodeRendererContext context, HtmlWriter html) { renderHtmlBlock(node, context, html, context.getHtmlOptions().suppressHtmlCommentBlocks, context.getHtmlOptions().escapeHtmlCommentBlocks, false); }
void render(SoftLineBreak node, NodeRendererContext context, HtmlWriter html) { final String softBreak = context.getHtmlOptions().softBreak; if (context.getHtmlOptions().sourcePositionParagraphLines) { if (renderLineBreak(softBreak, softBreak.equals("\n") || softBreak.equals("\r\n") || softBreak.equals("\r") ? "code" : null, node, context, html)) { return; } } html.raw(softBreak); }
@SuppressWarnings("MethodMayBeStatic") void render(HtmlInlineComment node, NodeRendererContext context, HtmlWriter html) { renderInlineHtml(node, context, html, context.getHtmlOptions().suppressInlineHtmlComments, context.getHtmlOptions().escapeInlineHtmlComments); }
private void renderChildrenSourceLineWrapped( final Node node, final BasedSequence nodeChildText, final NodeRendererContext context, final HtmlWriter html ) { // if have SOFT BREAK or HARD BREAK as child then we open our own span if (context.getHtmlOptions().sourcePositionParagraphLines && nodeChildText.indexOfAny(EOL_CHARS) >= 0) { if (myNextLine > 0) { myNextLine--; } outputSourceLineSpan(node, node, node, html); context.renderChildren(node); html.tag("/span"); } else { context.renderChildren(node); } }
private boolean renderLineBreak(String breakText, final String suppressInTag, final Node node, NodeRendererContext context, HtmlWriter html) { if (myLines != null && myNextLine < myLines.size()) { // here we may need to close tags opened since the span tag List<String> openTags = html.getOpenTagsAfterLast("span"); int iMax = openTags.size(); final boolean outputBreakText = iMax == 0 || suppressInTag == null || !suppressInTag.equalsIgnoreCase(openTags.get(iMax - 1)); if (!outputBreakText && !html.isPendingSpace()) { // we add a space for EOL html.raw(" "); } for (int i = iMax; i-- > 0; ) { html.closeTag(openTags.get(i)); } html.tag("/span"); if (outputBreakText) { html.raw(breakText); } outputNextLineBreakSpan(node, html, outputBreakText); for (String tag : openTags) { if (!outputBreakText && context.getHtmlOptions().inlineCodeSpliceClass != null && !context.getHtmlOptions().inlineCodeSpliceClass.isEmpty()) { html.attr(Attribute.CLASS_ATTR, context.getHtmlOptions().inlineCodeSpliceClass).withAttr().tag(tag); } else { html.tag(tag); } } return true; } return false; }
@SuppressWarnings("MethodMayBeStatic") void render(Image node, NodeRendererContext context, HtmlWriter html) { if (!(context.isDoNotRenderLinks() || isSuppressedLinkPrefix(node.getUrl(), context))) { String altText = new TextCollectingVisitor().collectAndGetText(node); ResolvedLink resolvedLink = context.resolveLink(LinkType.IMAGE, node.getUrl().unescape(), null, null); String url = resolvedLink.getUrl(); if (!node.getUrlContent().isEmpty()) { // reverse URL encoding of =, & String content = Escaping.percentEncodeUrl(node.getUrlContent()).replace("+", "%2B").replace("%3D", "=").replace("%26", "&"); url += content; } html.attr("src", url); html.attr("alt", altText); // we have a title part, use that if (node.getTitle().isNotNull()) { resolvedLink.getNonNullAttributes().replaceValue(Attribute.TITLE_ATTR, node.getTitle().unescape()); } else { resolvedLink.getNonNullAttributes().remove(Attribute.TITLE_ATTR); } html.attr(resolvedLink.getAttributes()); html.srcPos(node.getChars()).withAttr(resolvedLink).tagVoid("img"); } }
reference = node.getReferenceNode(referenceRepository); String url = reference.getUrl().unescape(); isSuppressed = isSuppressedLinkPrefix(url, context); } else { html.text(node.getChars().prefixOf(node.getChildChars()).unescape()); renderChildrenSourceLineWrapped(node, node.getText(), context, html); html.text(node.getChars().suffixOf(node.getChildChars()).unescape()); renderChildrenSourceLineWrapped(node, node.getText(), context, html); html.tag("/a");
@SuppressWarnings("MethodMayBeStatic") void render(HtmlCommentBlock node, NodeRendererContext context, HtmlWriter html) { renderHtmlBlock(node, context, html, context.getHtmlOptions().suppressHtmlCommentBlocks, context.getHtmlOptions().escapeHtmlCommentBlocks, false); }
void render(HardLineBreak node, NodeRendererContext context, HtmlWriter html) { if (context.getHtmlOptions().sourcePositionParagraphLines) { if (renderLineBreak(context.getHtmlOptions().hardBreak, null, node, context, html)) { return; } } html.raw(context.getHtmlOptions().hardBreak); }
@SuppressWarnings("MethodMayBeStatic") void render(HtmlInline node, NodeRendererContext context, HtmlWriter html) { //if (context.getHtmlOptions().sourceWrapInlineHtml) { // html.srcPos(node.getChars()).withAttr(AttributablePart.NODE_POSITION).tag("span"); //} renderInlineHtml(node, context, html, context.getHtmlOptions().suppressInlineHtml, context.getHtmlOptions().escapeInlineHtml); //if (context.getHtmlOptions().sourceWrapInlineHtml) { // html.tag("/span"); //} }
public void renderTextBlockParagraphLines(final Paragraph node, final NodeRendererContext context, final HtmlWriter html, final boolean wrapTextInSpan) { if (context.getHtmlOptions().sourcePositionParagraphLines) { if (node.hasChildren()) { LineCollectingVisitor breakCollectingVisitor = new LineCollectingVisitor(); myLines = breakCollectingVisitor.collectAndGetRanges(node); myEOLs = breakCollectingVisitor.getEOLs(); myNextLine = 0; outputSourceLineSpan(node, node.getFirstChild(), node, html); context.renderChildren(node); html.tag("/span"); return; } } if (wrapTextInSpan) { html.withAttr().tag("span", false, false, new Runnable() { @Override public void run() { context.renderChildren(node); } }); } else { context.renderChildren(node); } }
private boolean renderLineBreak(String breakText, final String suppressInTag, final Node node, NodeRendererContext context, HtmlWriter html) { if (myLines != null && myNextLine < myLines.size()) { // here we may need to close tags opened since the span tag List<String> openTags = html.getOpenTagsAfterLast("span"); int iMax = openTags.size(); final boolean outputBreakText = iMax == 0 || suppressInTag == null || !suppressInTag.equalsIgnoreCase(openTags.get(iMax - 1)); if (!outputBreakText && !html.isPendingSpace()) { // we add a space for EOL html.raw(" "); } for (int i = iMax; i-- > 0; ) { html.closeTag(openTags.get(i)); } html.tag("/span"); if (outputBreakText) { html.raw(breakText); } outputNextLineBreakSpan(node, html, outputBreakText); for (String tag : openTags) { if (!outputBreakText && context.getHtmlOptions().inlineCodeSpliceClass != null && !context.getHtmlOptions().inlineCodeSpliceClass.isEmpty()) { html.attr(Attribute.CLASS_ATTR, context.getHtmlOptions().inlineCodeSpliceClass).withAttr().tag(tag); } else { html.tag(tag); } } return true; } return false; }
@Override public void render(Heading node, NodeRendererContext context, HtmlWriter html) { CoreNodeRenderer.this.render(node, context, html); } }),
private void render(Image node, NodeRendererContext context, final HtmlWriter html) { if (!(context.isDoNotRenderLinks() || CoreNodeRenderer.isSuppressedLinkPrefix(node.getUrl(), context))) { final String altText = new TextCollectingVisitor().collectAndGetText(node); ResolvedLink resolvedLink = context.resolveLink(LinkType.IMAGE, node.getUrl().unescape(), null, null); final String url = resolvedLink.getUrl(); if (node.getUrlContent().isEmpty()) { Attributes attributes = resolvedLink.getNonNullAttributes(); // need to take attributes for reference definition, then overlay them with ours attributes = context.extendRenderingNodeAttributes(node, AttributablePart.NODE, attributes); if (renderVideoImage(node, url, altText, attributes, html)) { return; } } context.delegateRender(); } }
void render(Link node, NodeRendererContext context, HtmlWriter html) { if (context.isDoNotRenderLinks() || isSuppressedLinkPrefix(node.getUrl(), context)) { context.renderChildren(node); } else { ResolvedLink resolvedLink = context.resolveLink(LinkType.LINK, node.getUrl().unescape(), null, null); html.attr("href", resolvedLink.getUrl()); // we have a title part, use that if (node.getTitle().isNotNull()) { resolvedLink.getNonNullAttributes().replaceValue(Attribute.TITLE_ATTR, node.getTitle().unescape()); } else { resolvedLink.getNonNullAttributes().remove(Attribute.TITLE_ATTR); } html.attr(resolvedLink.getAttributes()); html.srcPos(node.getChars()).withAttr(resolvedLink).tag("a"); renderChildrenSourceLineWrapped(node, node.getText(), context, html); html.tag("/a"); } }