Search in sources :

Example 6 with Node

use of com.vladsch.flexmark.util.ast.Node in project zeppelin by apache.

the class MarkdownParser method render.

public String render(String markdownText) {
    Node document = parser.parse(markdownText);
    String html = renderer.render(document);
    return wrapWithMarkdownClassDiv(html);
}
Also used : Node(com.vladsch.flexmark.util.ast.Node)

Example 7 with Node

use of com.vladsch.flexmark.util.ast.Node in project configuration-as-code-plugin by jenkinsci.

the class JenkinsConfiguredWithReadmeRule method transformFencedCodeBlockFromMarkdownToString.

private List<String> transformFencedCodeBlockFromMarkdownToString(InputStream markdownContent) throws IOException {
    ArrayList<String> results = new ArrayList<>();
    final MutableDataSet FORMAT_OPTIONS = new MutableDataSet();
    FORMAT_OPTIONS.set(Parser.EXTENSIONS, OPTIONS.get(Parser.EXTENSIONS));
    Reader targetReader = new InputStreamReader(markdownContent);
    Node document = PARSER.parseReader(targetReader);
    TextCollectingVisitor textCollectingVisitor = new TextCollectingVisitor();
    Node fencedCodeBlock = document.getChildOfType(FencedCodeBlock.class);
    while (fencedCodeBlock != null) {
        results.add(textCollectingVisitor.collectAndGetText(fencedCodeBlock));
        fencedCodeBlock = fencedCodeBlock.getNextAny(FencedCodeBlock.class);
    }
    return results;
}
Also used : TextCollectingVisitor(com.vladsch.flexmark.ast.util.TextCollectingVisitor) InputStreamReader(java.io.InputStreamReader) Node(com.vladsch.flexmark.util.ast.Node) ArrayList(java.util.ArrayList) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) MutableDataSet(com.vladsch.flexmark.util.data.MutableDataSet) FencedCodeBlock(com.vladsch.flexmark.ast.FencedCodeBlock)

Aggregations

Node (com.vladsch.flexmark.util.ast.Node)7 TextCollectingVisitor (com.vladsch.flexmark.ast.util.TextCollectingVisitor)2 FencedCodeBlock (com.vladsch.flexmark.ast.FencedCodeBlock)1 Heading (com.vladsch.flexmark.ast.Heading)1 HtmlRenderer (com.vladsch.flexmark.html.HtmlRenderer)1 Parser (com.vladsch.flexmark.parser.Parser)1 AbstractBlockParser (com.vladsch.flexmark.parser.block.AbstractBlockParser)1 BlockParser (com.vladsch.flexmark.parser.block.BlockParser)1 MatchedBlockParser (com.vladsch.flexmark.parser.block.MatchedBlockParser)1 Block (com.vladsch.flexmark.util.ast.Block)1 MutableDataSet (com.vladsch.flexmark.util.data.MutableDataSet)1 BasedSequence (com.vladsch.flexmark.util.sequence.BasedSequence)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1