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); } }
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 FencedCodeBlock node, final NodeRendererContext context, HtmlWriter html) { final BasedSequence info = node.getInfoDelimitedByAny(options.blockInfoDelimiters); if (options.renderBlockMath && info.equals("math")) { html.line(); html.srcPosWithTrailingEOL(node.getChars()).attr(Attribute.CLASS_ATTR, options.blockMathClass).withAttr().tag("div").line().openPre(); if (codeContentBlock) { context.renderChildren(node); } else { html.text(node.getContentChars().normalizeEOL()); } html.closePre().tag("/div"); html.lineIf(context.getHtmlOptions().htmlBlockCloseTagEol); } else if (options.renderBlockMermaid && info.equals("mermaid")) { html.line(); html.srcPosWithTrailingEOL(node.getChars()).attr(Attribute.CLASS_ATTR, options.blockMermaidClass).withAttr().tag("div").line().openPre(); if (codeContentBlock) { context.renderChildren(node); } else { html.text(node.getContentChars().normalizeEOL()); } html.closePre().tag("/div"); html.lineIf(context.getHtmlOptions().htmlBlockCloseTagEol); } else { context.delegateRender(); } }
@SuppressWarnings("MethodMayBeStatic") void render(HtmlBlock node, NodeRendererContext context, HtmlWriter html) { html.line(); final HtmlRendererOptions htmlOptions = context.getHtmlOptions(); if (htmlOptions.sourceWrapHtmlBlocks) { html.srcPos(node.getChars()).withAttr(AttributablePart.NODE_POSITION).tag("div").indent().line(); } if (node.hasChildren()) { // inner blocks handle rendering context.renderChildren(node); } else { renderHtmlBlock(node, context, html, htmlOptions.suppressHtmlBlocks, htmlOptions.escapeHtmlBlocks, false); } if (htmlOptions.sourceWrapHtmlBlocks) { html.unIndent().tag("/div"); } html.lineIf(htmlOptions.htmlBlockCloseTagEol); }
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 (openedItems[lastLevel]) { if (openedList[lastLevel]) html.unIndent().tag(listClose).line(); html.lineIf(openedItemAppendCount[lastLevel] != html.getModCount()).tag("/li").line(); if (openedItems[lv]) { if (openedList[lv]) html.unIndent().tag(listClose).unIndent().line(); html.lineIf(openedItemAppendCount[lastLevel] != html.getModCount()).tag("/li").line(); if (openedItems[i]) { if (openedList[i]) html.unIndent().tag(listClose).unIndent().line(); html.lineIf(openedItemAppendCount[lastLevel] != html.getModCount()).tag("/li").line();
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); } }
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); }
/** * Renders a {@link IndentedCodeBlock} with hardline breaks to preserve new lines in Jive * * @param node {@link IndentedCodeBlock} * @param context {@link NodeRendererContext} * @param html {@link HtmlWriter} */ private 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 (Parser.FENCED_CODE_CONTENT_BLOCK.getFrom(options)) { context.renderChildren(node); } else { renderRawWithHardBreaks(node, html); } html.tag("/code"); html.tag("/pre").closePre(); html.lineIf(context.getHtmlOptions().htmlBlockCloseTagEol); }
@SuppressWarnings("MethodMayBeStatic") void render(HtmlBlock node, NodeRendererContext context, HtmlWriter html) { html.line(); final HtmlRendererOptions htmlOptions = context.getHtmlOptions(); if (htmlOptions.sourceWrapHtmlBlocks) { html.srcPos(node.getChars()).withAttr(AttributablePart.NODE_POSITION).tag("div").indent().line(); } if (node.hasChildren()) { // inner blocks handle rendering context.renderChildren(node); } else { renderHtmlBlock(node, context, html, htmlOptions.suppressHtmlBlocks, htmlOptions.escapeHtmlBlocks, false); } if (htmlOptions.sourceWrapHtmlBlocks) { html.unIndent().tag("/div"); } html.lineIf(htmlOptions.htmlBlockCloseTagEol); }
if (openedItems[lastLevel]) { if (openedList[lastLevel]) html.unIndent().tag(listClose).line(); html.lineIf(openedItemAppendCount[lastLevel] != html.getModCount()).tag("/li").line(); if (openedItems[lv]) { if (openedList[lv]) html.unIndent().tag(listClose).unIndent().line(); html.lineIf(openedItemAppendCount[lastLevel] != html.getModCount()).tag("/li").line(); if (openedItems[i]) { if (openedList[i]) html.unIndent().tag(listClose).unIndent().line(); html.lineIf(openedItemAppendCount[lastLevel] != html.getModCount()).tag("/li").line();
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); }
html.lineIf(context.getHtmlOptions().htmlBlockCloseTagEol);