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); }
if (node.getParent() instanceof ListItem) { BasedSequence marker = ((ListItem) node.getParent()).getOpeningMarker(); prefix = RepeatedCharSequence.of(" ", Utils.minLimit(8 - marker.length() - 1, 4)).toString(); markdown.openPreFormatted(true); if (context.isTransformingText()) { markdown.appendNonTranslating(node.getContentChars()); } else { if (formatterOptions.indentedCodeMinimizeIndent) { List<BasedSequence> lines = node.getContentLines(); int[] leadColumns = new int[lines.size()]; int minSpaces = Integer.MAX_VALUE; markdown.append(node.getContentChars()); markdown.append(node.getContentChars());
@Override public void closeBlock(ParserState state) { // trim trailing blank lines out of the block if (trimTrailingBlankLines) { int trailingBlankLines = 0; List<BasedSequence> lines = content.getLines(); for (BasedSequence line : new Reverse<BasedSequence>(lines)) { if (!line.isBlank()) break; trailingBlankLines++; } if (trailingBlankLines > 0) block.setContent(lines.subList(0, lines.size() - trailingBlankLines)); else block.setContent(content); } else { block.setContent(content); } if (codeContentBlock) { CodeBlock codeBlock = new CodeBlock(block.getChars(), block.getContentLines()); block.appendChild(codeBlock); } content = null; }
private void render(IndentedCodeBlock node, NodeRendererContext context, HtmlWriter html) { html.line().raw("{noformat}").line(); html.raw(node.getContentChars().trimTailBlankLines().normalizeEndWithEOL()); html.line().raw("{noformat}").line(); }
private void render(final IndentedCodeBlock node, final DocxRendererContext docx) { List<BasedSequence> lines = node.getContentLines(); docx.renderFencedCodeLines(lines); }
private void render(IndentedCodeBlock node, NodeRendererContext context, HtmlWriter html) { html.line().raw("{noformat}").line(); html.raw(node.getContentChars().trimTailBlankLines().normalizeEndWithEOL()); html.line().raw("{noformat}").line(); }
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); }
if (node.getParent() instanceof ListItem) { BasedSequence marker = ((ListItem) node.getParent()).getOpeningMarker(); prefix = RepeatedCharSequence.of(" ", Utils.minLimit(8 - marker.length() - 1, 4)).toString(); markdown.openPreFormatted(true); if (context.isTransformingText()) { markdown.appendNonTranslating(node.getContentChars()); } else { if (formatterOptions.indentedCodeMinimizeIndent) { List<BasedSequence> lines = node.getContentLines(); int[] leadColumns = new int[lines.size()]; int minSpaces = Integer.MAX_VALUE; markdown.append(node.getContentChars()); markdown.append(node.getContentChars());
@Override public void closeBlock(ParserState state) { // trim trailing blank lines out of the block if (trimTrailingBlankLines) { int trailingBlankLines = 0; List<BasedSequence> lines = content.getLines(); for (BasedSequence line : new Reverse<BasedSequence>(lines)) { if (!line.isBlank()) break; trailingBlankLines++; } if (trailingBlankLines > 0) block.setContent(lines.subList(0, lines.size() - trailingBlankLines)); else block.setContent(content); } else { block.setContent(content); } if (codeContentBlock) { CodeBlock codeBlock = new CodeBlock(block.getChars(), block.getContentLines()); block.appendChild(codeBlock); } content = null; }
private void render(IndentedCodeBlock node, NodeRendererContext context, HtmlWriter html) { html.line().raw("{noformat}").line(); html.raw(node.getContentChars().trimTailBlankLines().normalizeEndWithEOL()); html.line().raw("{noformat}").line(); }
private void render( IndentedCodeBlock node, NodeRendererContext context, HtmlWriter html ) { html.line(); html.attr( "class", "source" ).tag( "div" ); 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(CoreNodeRenderer.CODE_CONTENT).tag("code"); String s = node.getContentChars().trimTailBlankLines().normalizeEndWithEOL(); while ( !s.isEmpty() && s.charAt( 0 ) == '\n' ) { html.raw( "<br/>" ); s = s.substring( 1 ); } html.text( s ); //html.tag("/code"); html.tag( "/pre" ).closePre(); html.tag( "/div" ); html.line(); }
/** * 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); }