com.vladsch.flexmark.html.renderer.NodeRenderingHandler Java Examples

The following examples show how to use com.vladsch.flexmark.html.renderer.NodeRenderingHandler. 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: MarkNodeRenderer.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {
    HashSet<NodeRenderingHandler<?>> set = new HashSet<>();
    set.add(new NodeRenderingHandler<>(Mark.class, new CustomNodeRenderer<Mark>() {
        @Override
        public void render(Mark node, NodeRendererContext context, HtmlWriter html) {
            MarkNodeRenderer.this.render(node, context, html);
        }
    }));

    return set;
}
 
Example #2
Source File: MathJaxNodeRenderer.java    From OmniList with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {
    HashSet<NodeRenderingHandler<?>> set = new HashSet<>();
    set.add(new NodeRenderingHandler<>(MathJax.class, new CustomNodeRenderer<MathJax>() {
        @Override
        public void render(MathJax node, NodeRendererContext context, HtmlWriter html) {
            MathJaxNodeRenderer.this.render(node, context, html);
        }
    }));

    return set;
}
 
Example #3
Source File: TwitterNodeRenderer.java    From MarkdownView with Apache License 2.0 5 votes vote down vote up
@Override
public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {
    HashSet<NodeRenderingHandler<?>> set = new HashSet<>();
    set.add(new NodeRenderingHandler<>(Twitter.class, new CustomNodeRenderer<Twitter>() {
        @Override
        public void render(Twitter node, NodeRendererContext context, HtmlWriter html) {
            TwitterNodeRenderer.this.render(node, context, html);
        }
    }));
    return set;
}
 
Example #4
Source File: KeystrokeNodeRenderer.java    From MarkdownView with Apache License 2.0 5 votes vote down vote up
@Override
public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {
    HashSet<NodeRenderingHandler<?>> set = new HashSet<>();
    set.add(new NodeRenderingHandler<>(Keystroke.class, new CustomNodeRenderer<Keystroke>() {
        @Override
        public void render(Keystroke node, NodeRendererContext context, HtmlWriter html) {
            KeystrokeNodeRenderer.this.render(node, context, html);
        }
    }));

    return set;
}
 
Example #5
Source File: MarkNodeRenderer.java    From MarkdownView with Apache License 2.0 5 votes vote down vote up
@Override
public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {
    HashSet<NodeRenderingHandler<?>> set = new HashSet<>();
    set.add(new NodeRenderingHandler<>(Mark.class, new CustomNodeRenderer<Mark>() {
        @Override
        public void render(Mark node, NodeRendererContext context, HtmlWriter html) {
            MarkNodeRenderer.this.render(node, context, html);
        }
    }));

    return set;
}
 
Example #6
Source File: MathJaxNodeRenderer.java    From MarkdownView with Apache License 2.0 5 votes vote down vote up
@Override
public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {
    HashSet<NodeRenderingHandler<?>> set = new HashSet<>();
    set.add(new NodeRenderingHandler<>(MathJax.class, new CustomNodeRenderer<MathJax>() {
        @Override
        public void render(MathJax node, NodeRendererContext context, HtmlWriter html) {
            MathJaxNodeRenderer.this.render(node, context, html);
        }
    }));

    return set;
}
 
Example #7
Source File: LabelNodeRenderer.java    From MarkdownView with Apache License 2.0 5 votes vote down vote up
@Override
public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {
    HashSet<NodeRenderingHandler<?>> set = new HashSet<>();
    set.add(new NodeRenderingHandler<>(Label.class, new CustomNodeRenderer<Label>() {
        @Override
        public void render(Label node, NodeRendererContext context, HtmlWriter html) {
            LabelNodeRenderer.this.render(node, context, html);
        }
    }));

    return set;
}
 
Example #8
Source File: EmojiNodeRenderer.java    From MarkdownView with Apache License 2.0 5 votes vote down vote up
@Override
public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {
    HashSet<NodeRenderingHandler<?>> set = new HashSet<>();
    set.add(new NodeRenderingHandler<>(Emoji.class, new CustomNodeRenderer<Emoji>() {
        @Override
        public void render(Emoji node, NodeRendererContext context, HtmlWriter html) {
            EmojiNodeRenderer.this.render(node, context, html);
        }
    }));
    return set;
}
 
Example #9
Source File: BeanNodeRenderer.java    From MarkdownView with Apache License 2.0 5 votes vote down vote up
@Override
public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {
    HashSet<NodeRenderingHandler<?>> set = new HashSet<>();
    set.add(new NodeRenderingHandler<>(Bean.class, new CustomNodeRenderer<Bean>() {
        @Override
        public void render(Bean node, NodeRendererContext context, HtmlWriter html) {
            BeanNodeRenderer.this.render(node, context, html);
        }
    }));

    return set;
}
 
Example #10
Source File: VideoLinkNodeRenderer.java    From MarkdownView with Apache License 2.0 5 votes vote down vote up
@Override
public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {
    HashSet<NodeRenderingHandler<?>> set = new HashSet<>();
    set.add(new NodeRenderingHandler<>(VideoLink.class, new CustomNodeRenderer<VideoLink>() {
        @Override
        public void render(VideoLink node, NodeRendererContext context, HtmlWriter html) {
            VideoLinkNodeRenderer.this.render(node, context, html);
        }
    }));
    return set;
}
 
Example #11
Source File: UMLNodeRenderer.java    From zeppelin with Apache License 2.0 5 votes vote down vote up
@Override
public Set<NodeRenderingHandler<?>> getNodeRenderingHandlers() {
  Set<NodeRenderingHandler<?>> set = new HashSet<>();
  set.add(new NodeRenderingHandler<>(UMLBlockQuote.class,
      new CustomNodeRenderer<UMLBlockQuote>() {
        @Override
        public void render(UMLBlockQuote node, NodeRendererContext context,
                           HtmlWriter html) {
          UMLNodeRenderer.this.render(node, context, html);
        }
      }));
  return set;
}
 
Example #12
Source File: NodeRendererFactoryImpl.java    From OmniList with GNU Affero General Public License v3.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 = dimensions[0] == null || dimensions[0].equals("") ? "auto" : dimensions[0];
                                String height = dimensions[1] == null || dimensions[1].equals("") ? "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 #13
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;
        }
    };
}