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

The following examples show how to use com.vladsch.flexmark.util.options.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: MarkExtension.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void extend(HtmlRenderer.Builder rendererBuilder, String rendererType) {
    switch (rendererType) {
        case "HTML":
            rendererBuilder.nodeRendererFactory(new NodeRendererFactory() {
                @Override
                public NodeRenderer create(DataHolder options) {
                    return new MarkNodeRenderer(options);
                }
            });
            break;
    }
}
 
Example #2
Source File: MarkExtension.java    From MarkdownView with Apache License 2.0 5 votes vote down vote up
@Override
public void extend(HtmlRenderer.Builder rendererBuilder, String rendererType) {
    switch (rendererType) {
        case "HTML":
            rendererBuilder.nodeRendererFactory(new NodeRendererFactory() {
                @Override
                public NodeRenderer create(DataHolder options) {
                    return new MarkNodeRenderer(options);
                }
            });
            break;
    }
}
 
Example #3
Source File: HelpActivity.java    From mhzs with MIT License 5 votes vote down vote up
/**
     * 展示网页
     */
    private void showHtml(String md) {
        DataHolder OPTIONS = PegdownOptionsAdapter.flexmarkOptions(true,
                Extensions.NONE);
        Parser parser = Parser.builder(OPTIONS).build();
        HtmlRenderer renderer = HtmlRenderer.builder(OPTIONS).build();

        Node document = parser.parse(md);
        String html = renderer.render(document);

//        LogUtil.e(html);

        mWebView.getSettings().setDefaultTextEncodingName("UTF-8");
        mWebView.loadData(html, "text/html; charset=UTF-8", null);
    }
 
Example #4
Source File: MathJaxExtension.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void extend(HtmlRenderer.Builder rendererBuilder, String rendererType) {
    switch (rendererType) {
        case "HTML":
            rendererBuilder.nodeRendererFactory(new NodeRendererFactory() {
                @Override
                public NodeRenderer create(DataHolder options) {
                    return new MathJaxNodeRenderer(options);
                }
            });
            break;
    }
}
 
Example #5
Source File: MathJaxExtension.java    From MarkdownView with Apache License 2.0 5 votes vote down vote up
@Override
public void extend(HtmlRenderer.Builder rendererBuilder, String rendererType) {
    switch (rendererType) {
        case "HTML":
            rendererBuilder.nodeRendererFactory(new NodeRendererFactory() {
                @Override
                public NodeRenderer create(DataHolder options) {
                    return new MathJaxNodeRenderer(options);
                }
            });
            break;
    }
}
 
Example #6
Source File: EmojiNodeRenderer.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
@Override
public NodeRenderer create(final DataHolder options) {
    return new EmojiNodeRenderer(options);
}
 
Example #7
Source File: MarkNodeRenderer.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
@Override
public NodeRenderer create(final DataHolder options) {
    return new MarkNodeRenderer(options);
}
 
Example #8
Source File: MathJaxNodeRenderer.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
public MathJaxNodeRenderer(DataHolder options) {
}
 
Example #9
Source File: MathJaxNodeRenderer.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
@Override
public NodeRenderer create(final DataHolder options) {
    return new MathJaxNodeRenderer(options);
}
 
Example #10
Source File: LabelNodeRenderer.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
public LabelNodeRenderer(DataHolder options) {
}
 
Example #11
Source File: LabelNodeRenderer.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
@Override
public NodeRenderer create(final DataHolder options) {
    return new LabelNodeRenderer(options);
}
 
Example #12
Source File: EmojiNodeRenderer.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
public EmojiNodeRenderer(DataHolder options) {
    this.rootImagePath = options.get(EmojiExtension.ROOT_IMAGE_PATH);
    this.attrImageSize = options.get(EmojiExtension.ATTR_IMAGE_SIZE);
    this.attrAlign = options.get(EmojiExtension.ATTR_ALIGN);
    this.extImage = options.get(EmojiExtension.IMAGE_EXT);
}
 
Example #13
Source File: KeystrokeNodeRenderer.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
@Override
public NodeRenderer create(final DataHolder options) {
    return new KeystrokeNodeRenderer(options);
}
 
Example #14
Source File: BeanNodeRenderer.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
public BeanNodeRenderer(DataHolder options) {
    mMarkdownView = options.get(BeanExtension.BEAN_VIEW);
}
 
Example #15
Source File: BeanNodeRenderer.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
@Override
public NodeRenderer create(final DataHolder options) {
    return new BeanNodeRenderer(options);
}
 
Example #16
Source File: VideoLinkNodeRenderer.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
public VideoLinkNodeRenderer(DataHolder options) {
}
 
Example #17
Source File: VideoLinkNodeRenderer.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
@Override
public NodeRenderer create(final DataHolder options) {
    return new VideoLinkNodeRenderer(options);
}
 
Example #18
Source File: VideoLinkNodePostProcessor.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
public VideoLinkNodePostProcessor(DataHolder options) {
}
 
Example #19
Source File: VideoLinkNodePostProcessor.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
public Factory(DataHolder options) {
    super(false);

    addNodes(Link.class);
}
 
Example #20
Source File: MarkNodeRenderer.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
public MarkNodeRenderer(DataHolder options) {
}
 
Example #21
Source File: KeystrokeNodeRenderer.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
public KeystrokeNodeRenderer(DataHolder options) {
}
 
Example #22
Source File: TwitterNodePostProcessor.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
public Factory(DataHolder options) {
    super(false);

    addNodes(Link.class);
}
 
Example #23
Source File: TwitterNodePostProcessor.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
public TwitterNodePostProcessor(DataHolder options) {
}
 
Example #24
Source File: TwitterNodeRenderer.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
@Override
public NodeRenderer create(final DataHolder options) {
    return new TwitterNodeRenderer(options);
}
 
Example #25
Source File: TwitterNodeRenderer.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
public TwitterNodeRenderer(DataHolder options) {
}
 
Example #26
Source File: MarkdownView.java    From MarkdownView with Apache License 2.0 4 votes vote down vote up
@Override
public NodeRenderer create(DataHolder options) {
    return new NodeRenderer() {
        @Override
        public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {
            HashSet<NodeRenderingHandler<?>> set = new HashSet<>();
            set.add(new NodeRenderingHandler<>(Image.class, new CustomNodeRenderer<Image>() {
                @Override
                public void render(Image node, NodeRendererContext context, HtmlWriter html) {
                    if (!context.isDoNotRenderLinks()) {
                        String altText = new TextCollectingVisitor().collectAndGetText(node);

                        ResolvedLink resolvedLink = context.resolveLink(LinkType.IMAGE, node.getUrl().unescape(), 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", "&amp;");
                            url += content;
                        }

                        final int index = url.indexOf('@');

                        if (index >= 0) {
                            String[] dimensions = url.substring(index + 1, url.length()).split("\\|");
                            url = url.substring(0, index);

                            if (dimensions.length == 2) {
                                String width = TextUtils.isEmpty(dimensions[0]) ? "auto" : dimensions[0];
                                String height = TextUtils.isEmpty(dimensions[1]) ? "auto" : dimensions[1];
                                html.attr("style", "width: " + width + "; height: " + height);
                            }
                        }

                        html.attr("src", url);
                        html.attr("alt", altText);

                        if (node.getTitle().isNotNull()) {
                            html.attr("title", node.getTitle().unescape());
                        }

                        html.srcPos(node.getChars()).withAttr(resolvedLink).tagVoid("img");
                    }
                }
            }));
            return set;
        }
    };
}
 
Example #27
Source File: EmojiNodeRenderer.java    From onedev with MIT License 4 votes vote down vote up
@Override
public NodeRenderer create(final DataHolder options) {
    return new EmojiNodeRenderer(options);
}
 
Example #28
Source File: EmojiNodeRenderer.java    From onedev with MIT License 4 votes vote down vote up
public EmojiNodeRenderer(DataHolder options) {
    this.attrImageSize = options.get(EmojiExtension.ATTR_IMAGE_SIZE);
    this.attrAlign = options.get(EmojiExtension.ATTR_ALIGN);
}
 
Example #29
Source File: MathJaxNodeRenderer.java    From OmniList with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public NodeRenderer create(final DataHolder options) {
    return new MathJaxNodeRenderer(options);
}
 
Example #30
Source File: MathJaxNodeRenderer.java    From OmniList with GNU Affero General Public License v3.0 4 votes vote down vote up
public MathJaxNodeRenderer(DataHolder options) {
}