Refine search
private void renderEmbedLink(final EmbedLink node, final NodeRendererContext context, final HtmlWriter html) { if (context.isDoNotRenderLinks()) { context.renderChildren(node); } else { ResolvedLink resolvedLink = context.resolveLink(LinkType.LINK, node.getUrl().unescape(), null); html.attr("title", node.getText()) .attr("src", resolvedLink.getUrl()) .withAttr() .tag("embed", true); } }
private void render(BasedSequence contentChars, String language, NodeRendererContext context, HtmlWriter html) { String text = contentChars.normalizeEOL(); if (!text.isEmpty()) { if (!language.isEmpty()) { html.attr("class", context.getHtmlOptions().languageClassPrefix + language); } html.line(); html.tag("pre").openPre(); html.srcPos(contentChars).withAttr().tag("code"); html.text(text); html.tag("/code"); html.tag("/pre").closePre(); html.line(); } }
private void render(Link node, NodeRendererContext context, HtmlWriter html) { if (context.isDoNotRenderLinks()) { context.renderChildren(node); } else { ResolvedLink resolvedLink = context.resolveLink(LinkType.LINK, node.getUrl().unescape(), null); html.raw("["); context.renderChildren(node); html.raw("|").raw(resolvedLink.getUrl()).raw("]"); } }
private void render(HtmlBlock node, NodeRendererContext context, HtmlWriter html) { if (node.hasChildren()) { // inner blocks handle rendering context.renderChildren(node); } else { renderHtmlBlock(node, context, html, context.getHtmlOptions().suppressHtmlBlocks, context.getHtmlOptions().escapeHtmlBlocks); } }
void render(FencedCodeBlock node, NodeRendererContext context, HtmlWriter html) { html.line(); html.srcPosWithTrailingEOL(node.getChars()).withAttr().tag("pre").openPre(); BasedSequence info = node.getInfo(); if (info.isNotNull() && !info.isBlank()) { BasedSequence language = node.getInfoDelimitedByAny(" "); html.attr("class", context.getHtmlOptions().languageClassPrefix + language.unescape()); } else { String noLanguageClass = context.getHtmlOptions().noLanguageClass.trim(); if (!noLanguageClass.isEmpty()) { html.attr("class", noLanguageClass); } } html.srcPosWithEOL(node.getContentChars()).withAttr(CODE_CONTENT).tag("code"); if (codeContentBlock) { context.renderChildren(node); } else { html.text(node.getContentChars().normalizeEOL()); } html.tag("/code"); html.tag("/pre").closePre(); html.lineIf(context.getHtmlOptions().htmlBlockCloseTagEol); }
if (node.isDefined()) { reference = node.getReferenceNode(referenceRepository); String url = reference.getUrl().unescape(); isSuppressed = isSuppressedLinkPrefix(url, context); resolvedLink = context.resolveLink(LinkType.LINK, url, null, null); if (reference.getTitle().isNotNull()) { resolvedLink.getNonNullAttributes().replaceValue(Attribute.TITLE_ATTR, reference.getTitle().unescape()); } else { resolvedLink.getNonNullAttributes().remove(Attribute.TITLE_ATTR); String normalizeRef = node.getReference().unescape(); resolvedLink = context.resolveLink(LinkType.LINK_REF, normalizeRef, null, null); if (resolvedLink.getStatus() == UNKNOWN) { resolvedLink = null; html.text(node.getChars().unescape()); } else { html.text(node.getChars().prefixOf(node.getChildChars()).unescape()); renderChildrenSourceLineWrapped(node, node.getText(), context, html); html.text(node.getChars().suffixOf(node.getChildChars()).unescape()); if (context.isDoNotRenderLinks() || isSuppressed) { context.renderChildren(node); } else { Attributes attributes = resolvedLink.getNonNullAttributes(); attributes = context.extendRenderingNodeAttributes(reference, AttributablePart.NODE, attributes);
void render(IndentedCodeBlock node, NodeRendererContext context, HtmlWriter html) { html.line(); html.srcPosWithEOL(node.getChars()).withAttr().tag("pre").openPre(); String noLanguageClass = context.getHtmlOptions().noLanguageClass.trim(); if (!noLanguageClass.isEmpty()) { html.attr("class", noLanguageClass); } html.srcPosWithEOL(node.getContentChars()).withAttr(CODE_CONTENT).tag("code"); if (codeContentBlock) { context.renderChildren(node); } else { html.text(node.getContentChars().trimTailBlankLines().normalizeEndWithEOL()); } html.tag("/code"); html.tag("/pre").closePre(); html.lineIf(context.getHtmlOptions().htmlBlockCloseTagEol); }
private void render(GfmUser node, NodeRendererContext context, HtmlWriter html) { if (context.isDoNotRenderLinks()) { html.text(node.getChars()); } else { StringBuilder sb = new StringBuilder(); sb.append(options.gitHubIssuesUrlRoot).append(options.gitHubIssueUrlPrefix).append(node.getText()).append(options.gitHubIssueUrlSuffix); html.srcPos(node.getChars()).attr("href", sb.toString()).withAttr().tag("a"); html.raw(options.gitHubUserTextPrefix); html.text(node.getChars()); html.raw(options.gitHubUserTextSuffix); html.tag("/a"); } }
@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); } }); } }
private void render(WikiImage node, NodeRendererContext context, HtmlWriter html) { if (!context.isDoNotRenderLinks()) { if (options.disableRendering) { html.text(node.getChars().unescape()); } else { String altText = node.getText().isNotNull() ? node.getText().toString() : node.getLink().unescape(); ResolvedLink resolvedLink = context.resolveLink(WikiLinkExtension.WIKI_LINK, node.getLink().unescape(), null); String url = resolvedLink.getUrl(); html.attr("src", url); html.attr("alt", altText); html.srcPos(node.getChars()).withAttr(resolvedLink).tagVoid("img"); } } }
String url = reference.getUrl().unescape(); isSuppressed = isSuppressedLinkPrefix(url, context); resolvedLink = context.resolveLink(LinkType.IMAGE, url, null, null); if (reference.getTitle().isNotNull()) { resolvedLink.getNonNullAttributes().replaceValue(Attribute.TITLE_ATTR, reference.getTitle().unescape()); } else { resolvedLink.getNonNullAttributes().remove(Attribute.TITLE_ATTR); resolvedLink = context.resolveLink(LinkType.IMAGE_REF, normalizeRef, null, null); if (resolvedLink.getStatus() == UNKNOWN) { resolvedLink = null; html.text(node.getChars().unescape()); } else { if (!(context.isDoNotRenderLinks() || isSuppressed)) { String altText = new TextCollectingVisitor().collectAndGetText(node); Attributes attributes = resolvedLink.getNonNullAttributes(); html.attr("src", resolvedLink.getUrl()); html.attr("alt", altText); attributes = context.extendRenderingNodeAttributes(reference, AttributablePart.NODE, attributes);
private void render(Ins node, NodeRendererContext context, HtmlWriter html) { if (insStyleHtmlOpen == null || insStyleHtmlClose == null) { if (context.getHtmlOptions().sourcePositionParagraphLines) { html.withAttr().tag("ins"); } else { html.srcPos(node.getText()).withAttr().tag("ins"); } context.renderChildren(node); html.tag("/ins"); } else { html.raw(insStyleHtmlOpen); context.renderChildren(node); html.raw(insStyleHtmlClose); } }
@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"); } }
@Override public void run() { html.srcPos(node.getText()).withAttr().tag("span"); context.renderChildren(node); html.tag("/span"); } });
private void render(Emoji node, NodeRendererContext context, HtmlWriter html) { final EmojiResolvedShortcut shortcut = EmojiResolvedShortcut.getEmojiText(node, myOptions.useShortcutType, myOptions.useImageType, myOptions.rootImagePath); if (shortcut.emoji == null || shortcut.emojiText == null) { // output as text html.text(":"); context.renderChildren(node); html.text(":"); } else { if (shortcut.isUnicode) { html.text(shortcut.emojiText); } else { ResolvedLink resolvedLink = context.resolveLink(LinkType.IMAGE, shortcut.emojiText, null); html.attr("src", resolvedLink.getUrl()); html.attr("alt", shortcut.alt); if (!myOptions.attrImageSize.isEmpty()) html.attr("height", myOptions.attrImageSize).attr("width", myOptions.attrImageSize); if (!myOptions.attrAlign.isEmpty()) html.attr("align", myOptions.attrAlign); if (!myOptions.attrImageClass.isEmpty()) html.attr("class", myOptions.attrImageClass); html.withAttr(resolvedLink); html.tagVoid("img"); } } }
@Override public void run() { html.text(node.getMarkerSuffix().unescape()); context.renderChildren(node); } });
private void render(Strikethrough node, NodeRendererContext context, HtmlWriter html) { html.raw("--"); context.renderChildren(node); html.raw("--"); }
private void render(WikiLink node, NodeRendererContext context, HtmlWriter html) { if (options.disableRendering) { html.text(node.getChars().unescape()); } else { ResolvedLink resolvedLink = context.resolveLink(WikiLinkExtension.WIKI_LINK, node.getLink().toString(), null); html.raw("["); html.raw(node.getText().isNotNull() ? node.getText().toString() : node.getPageRef().toString()); html.raw("|"); html.raw(resolvedLink.getUrl()); html.raw("]"); } }
public static void renderHtmlBlock(HtmlBlockBase node, NodeRendererContext context, HtmlWriter html, boolean suppress, boolean escape, final boolean trimSpaces) { if (suppress) return; if (node instanceof HtmlBlock) html.line(); String normalizeEOL = node instanceof HtmlBlock ? node.getContentChars().normalizeEOL() : node.getChars().normalizeEOL(); if (trimSpaces) { normalizeEOL = normalizeEOL.trim(); } if (escape) { if (node instanceof HtmlBlock) { if (normalizeEOL.length() > 0 && normalizeEOL.charAt(normalizeEOL.length() - 1) == '\n') { // leave off the trailing EOL normalizeEOL = normalizeEOL.substring(0, normalizeEOL.length() - 1); } html.raw("<p>").text(normalizeEOL).raw("</p>"); } else { html.text(normalizeEOL); } } else { html.rawPre((normalizeEOL)); } if (node instanceof HtmlBlock) { html.lineIf(context.getHtmlOptions().htmlBlockCloseTagEol); } }