com.vladsch.flexmark.util.data.DataHolder Java Examples

The following examples show how to use com.vladsch.flexmark.util.data.DataHolder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MarkdownEditerController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
public String convert2text() {
    try {
        // https://github.com/vsch/flexmark-java/blob/master/flexmark-java-samples/src/com/vladsch/flexmark/samples/MarkdownToText.java
        DataHolder OPTIONS = PegdownOptionsAdapter.flexmarkOptions(Extensions.ALL);
        MutableDataSet FORMAT_OPTIONS = new MutableDataSet();
        FORMAT_OPTIONS.set(Parser.EXTENSIONS, OPTIONS.get(Parser.EXTENSIONS));
        Parser PARSER = Parser.builder(OPTIONS).build();

        Node document = PARSER.parse(mainArea.getText());
        TextCollectingVisitor textCollectingVisitor = new TextCollectingVisitor();
        String text = textCollectingVisitor.collectAndGetText(document);
        return text;
    } catch (Exception e) {
        return e.toString();
    }
}
 
Example #2
Source File: MarkdownEngine.java    From jbake with MIT License 6 votes vote down vote up
@Override
public void processBody(final ParserContext context) {
    List<String> mdExts = context.getConfig().getMarkdownExtensions();

    int extensions = PegdownExtensions.NONE;

    for (String ext : mdExts) {
        if (ext.startsWith("-")) {
            ext = ext.substring(1);
            extensions = removeExtension(extensions, extensionFor(ext));
        } else {
            if (ext.startsWith("+")) {
                ext = ext.substring(1);
            }
            extensions = addExtension(extensions, extensionFor(ext));
        }
    }

    DataHolder options = PegdownOptionsAdapter.flexmarkOptions(extensions);

    Parser parser = Parser.builder(options).build();
    HtmlRenderer renderer = HtmlRenderer.builder(options).build();

    Document document = parser.parse(context.getBody());
    context.setBody(renderer.render(document));
}
 
Example #3
Source File: FlexmarkConfluenceWikiVisitor.java    From maven-confluence-plugin with Apache License 2.0 5 votes vote down vote up
final static DataHolder OPTIONS() {

        int EXT =   com.vladsch.flexmark.profile.pegdown.Extensions.NONE
                    | com.vladsch.flexmark.profile.pegdown.Extensions.FENCED_CODE_BLOCKS
                    | com.vladsch.flexmark.profile.pegdown.Extensions.TABLES
                    | com.vladsch.flexmark.profile.pegdown.Extensions.STRIKETHROUGH
                 // | Extensions.SMARTS; // Breaks link including a dash -
                    ;
        return PegdownOptionsAdapter.flexmarkOptions(true, EXT );
    }
 
Example #4
Source File: UMLNodeRenderer.java    From zeppelin with Apache License 2.0 4 votes vote down vote up
public UMLNodeRenderer(DataHolder options) {
  this.options = new GitLabOptions(options);
}
 
Example #5
Source File: UMLNodeRenderer.java    From zeppelin with Apache License 2.0 4 votes vote down vote up
@Override
public NodeRenderer apply(final DataHolder options) {
  return new UMLNodeRenderer(options);
}
 
Example #6
Source File: UMLBlockQuoteParser.java    From zeppelin with Apache License 2.0 4 votes vote down vote up
UMLBlockQuoteParser(DataHolder options, BasedSequence openMarker, BasedSequence openTrailing) {
  this.options = new GitLabOptions(options);
  this.block.setOpeningMarker(openMarker);
  this.block.setOpeningTrailing(openTrailing);
}
 
Example #7
Source File: UMLBlockQuoteParser.java    From zeppelin with Apache License 2.0 4 votes vote down vote up
@Override
public BlockParserFactory apply(DataHolder options) {
  return new UMLBlockQuoteParser.BlockFactory(options);
}
 
Example #8
Source File: UMLBlockQuoteParser.java    From zeppelin with Apache License 2.0 4 votes vote down vote up
BlockFactory(DataHolder options) {
  super(options);
  this.options = new GitLabOptions(options);
}
 
Example #9
Source File: FlexmarkLinkResolver.java    From markdown-page-generator-plugin with MIT License 4 votes vote down vote up
public FlexmarkLinkResolver(LinkResolverContext context) {
    DataHolder options = context.getOptions();
    this.inputFileExtensions = options.get(PageGeneratorExtension.INPUT_FILE_EXTENSIONS).trim().split("\\s*,\\s*");
}
 
Example #10
Source File: FlexmarkAttributeProvider.java    From markdown-page-generator-plugin with MIT License 4 votes vote down vote up
public FlexmarkAttributeProvider(LinkResolverContext context) {
    DataHolder options = context.getOptions();
    attributeMap = options.get(AttributesExtension.ATTRIBUTE_MAP);
}