Refine search
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); } }
private void render(MailLink node, NodeRendererContext context, HtmlWriter html) { String text = node.getText().unescape(); if (context.isDoNotRenderLinks()) { html.text(text); } else { ResolvedLink resolvedLink = context.resolveLink(LinkType.LINK, text, null); html.raw("[").raw(text).raw("|mailto:").raw(resolvedLink.getUrl()).raw("]"); } }
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(final TableBody node, final NodeRendererContext context, HtmlWriter html) { html.withAttr().withCondLine().tagIndent("tbody", new Runnable() { @Override public void run() { context.renderChildren(node); } }); }
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); } }
if (node.isDefined()) { reference = node.getReferenceNode(referenceRepository); String url = reference.getUrl().unescape(); isSuppressed = isSuppressedLinkPrefix(url, context); 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(); html.attr("href", resolvedLink.getUrl()); html.attr(attributes); html.srcPos(node.getChars()).withAttr(resolvedLink).tag("a"); renderChildrenSourceLineWrapped(node, node.getText(), context, html); html.tag("/a");
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(); } }
@Override public void run() { html.srcPos(node.getText()).withAttr().tag("span"); context.renderChildren(node); html.tag("/span"); } });
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); html.attr(attributes); html.srcPos(node.getChars()).withAttr(resolvedLink).tagVoid("img");
@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"); } }
private void render(Abbreviation node, NodeRendererContext context, HtmlWriter html) { String text = node.getChars().unescape(); BasedSequence abbreviation = node.getAbbreviation(); String tag; if (options.useLinks) { html.attr("href", "#"); tag = "a"; } else { tag = "abbr"; } html.attr("title", abbreviation); html.srcPos(node.getChars()).withAttr().tag(tag); html.text(text); html.closeTag(tag); }
@Override public void run() { if (!paragraphClass.isEmpty()) html.attr("class", paragraphClass); html.srcPos(sourceText.getStartOffset(), sourceText.getEndOffset()).withAttr(TASK_ITEM_PARAGRAPH).tagLine("p", new Runnable() { @Override public void run() { html.raw(node.isItemDoneMarker() ? doneMarker : notDoneMarker); context.renderChildren(node); } }); } });
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"); } } }
private void outputNextLineBreakSpan(final Node node, final HtmlWriter html, final boolean outputBreakText) { final Range range = myLines.get(myNextLine); int eolLength = myEOLs.get(myNextLine); myNextLine++; // remove trailing spaces from text int countTrailing = node.getChars().baseSubSequence(nextLineStartOffset, range.getEnd() - eolLength).countTrailing(" \t"); if (!outputBreakText && countTrailing > 0) { countTrailing--; } eolLength += countTrailing; html.srcPos(nextLineStartOffset, range.getEnd() - eolLength).withAttr(PARAGRAPH_LINE).tag("span"); nextLineStartOffset = range.getEnd(); // remove leading spaces nextLineStartOffset += node.getChars().baseSubSequence(nextLineStartOffset, node.getChars().getBaseSequence().length()).countLeading(BasedSequence.WHITESPACE_NO_EOL_CHARS); }