当前位置: 首页>>代码示例>>Java>>正文


Java LinkRenderer类代码示例

本文整理汇总了Java中org.pegdown.LinkRenderer的典型用法代码示例。如果您正苦于以下问题:Java LinkRenderer类的具体用法?Java LinkRenderer怎么用?Java LinkRenderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LinkRenderer类属于org.pegdown包,在下文中一共展示了LinkRenderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: markdownToHtml

import org.pegdown.LinkRenderer; //导入依赖的package包/类
/**
 * Convert Markdown into HTML (just the body content) with inline styles
 * 
 * @param markdown Markdown to convert into HTML
 * @return String containing HTML (just the body content)
 * @throws MarkdownException 
 */
String markdownToHtml(String markdown) throws MarkdownException {
	Map<String, VerbatimSerializer> verbatimSerializers = new HashMap<>();
	verbatimSerializers.put(MyCustomVerbatimSerializer.DEFAULT, MyCustomVerbatimSerializer.INSTANCE);

	String htmlBody = processor.markdownToHtml(markdown.toCharArray(), new LinkRenderer(), verbatimSerializers);
	LOG.debug("Body before styles: {}",htmlBody);

	String htmlWithStyleInline = "";
	try {
		htmlWithStyleInline = new HtmlStyleSheetInliner().inlineStyleSheet(htmlBody, styleSheet);
	} catch (SAXException | IOException | TransformerException e) {
		e.printStackTrace();
		throw new MarkdownException("Could not turn Markdown to HTML");
	}
	LOG.debug("Body after styles: {}",htmlWithStyleInline);
	
	return htmlWithStyleInline;
}
 
开发者ID:windsource,项目名称:evernote-markdown-sync,代码行数:26,代码来源:MarkdownService.java

示例2: markdownToDocHtml

import org.pegdown.LinkRenderer; //导入依赖的package包/类
public byte[] markdownToDocHtml(String md, String charEnc) throws UnsupportedEncodingException {
  RootNode root = parseMarkdown(md);
  String title = findTitle(root);

  StringBuilder html = new StringBuilder();
  html.append("<html>");
  html.append("<head>");
  if (!Strings.isNullOrEmpty(title)) {
    html.append("<title>").append(title).append("</title>");
  }
  html.append("<style type=\"text/css\">\n");
  if (css != null) {
    html.append(css);
  } else {
    html.append(readCSS());
  }
  html.append("\n</style>");
  html.append("</head>");
  html.append("<body>\n");
  html.append(new ToHtmlSerializer(new LinkRenderer()).toHtml(root));
  html.append("\n</body></html>");
  return html.toString().getBytes(charEnc);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:24,代码来源:MarkdownFormatter.java

示例3: visit

import org.pegdown.LinkRenderer; //导入依赖的package包/类
@Override
public void visit(HeaderNode node) {
    String tag = "h" + node.getLevel();
    String title = printChildrenToString(node);
    LinkRenderer.Rendering anchorLink = createAnchorLink(title);
    printer.print('<').print(tag).print('>');
    printLink(anchorLink);
    visitChildren(node);
    printer.print('<').print('/').print(tag).print('>');
}
 
开发者ID:microacup,项目名称:microbbs,代码行数:11,代码来源:MarkdownToHtmlSerializer.java

示例4: renderToHtml

import org.pegdown.LinkRenderer; //导入依赖的package包/类
@Override
public String renderToHtml(String markdownSource) {
    // synchronizing on pegdown instance since neither the processor nor the underlying parser is thread-safe.
    synchronized (pegdown) {
        RootNode astRoot = pegdown.parseMarkdown(markdownSource.toCharArray());
        MarkdownToHtmlSerializer serializer = new MarkdownToHtmlSerializer(new LinkRenderer(),
                Collections.singletonMap(VerbatimSerializer.DEFAULT, PrettifyVerbatimSerializer.INSTANCE));
        return serializer.toHtml(astRoot);
    }
}
 
开发者ID:microacup,项目名称:microbbs,代码行数:11,代码来源:PegdownMarkdownService.java

示例5: markdownToHtml

import org.pegdown.LinkRenderer; //导入依赖的package包/类
@Override
public String markdownToHtml(char[] markdownSource,
		LinkRenderer linkRenderer,
		Map<String, VerbatimSerializer> verbatimSerializerMap) {
	try {
		RootNode astRoot = parseMarkdown(markdownSource);
		return new ToHtmlNoLinkSerializer(linkRenderer,
				verbatimSerializerMap).toHtml(astRoot);
	} catch (ParsingTimeoutException e) {
		return null;
	}
}
 
开发者ID:ZapBlasterson,项目名称:crushpaper,代码行数:13,代码来源:PegDownNoLinkProcessor.java

示例6: toHtml

import org.pegdown.LinkRenderer; //导入依赖的package包/类
@Override
public String toHtml(String source) {
    try {
        Map<String, VerbatimSerializer> serializers = new HashMap<>();
        PlantUmlVerbatimSerializer.addToMap(serializers);
        LinkRenderer linkRenderer = new TypeLinkRenderer();
        return processor.markdownToHtml(source, linkRenderer, serializers);
    } catch (Exception e) {
        LOGGER.error("Could not convert given source to markdown: {}", source, e);
        return source;
    }
}
 
开发者ID:protostuff,项目名称:protostuff-compiler,代码行数:13,代码来源:PegDownMarkdownProcessor.java

示例7: printAnchorLink

import org.pegdown.LinkRenderer; //导入依赖的package包/类
protected void printAnchorLink(LinkRenderer.Rendering rendering) {
    printer.print('<').print('a');
    printAttribute("href", rendering.href);
    for (LinkRenderer.Attribute attr : rendering.attributes) {
        printAttribute(attr.name, attr.value);
    }
    printer.print('>').print("<span class=\"octicon octicon-link\"></span>").print(rendering.text).print("</a>");
}
 
开发者ID:vsch,项目名称:idea-multimarkdown,代码行数:9,代码来源:MultiMarkdownToHtmlSerializer.java

示例8: printLink

import org.pegdown.LinkRenderer; //导入依赖的package包/类
@Override
protected void printLink(Rendering rendering) {
    printer.print('<').print('a');
    printAttribute("href", rendering.href);
    rendering.withAttribute("target", "_blank");
    for (LinkRenderer.Attribute attr : rendering.attributes) {
        printAttribute(attr.name, attr.value);
    }
    printer.print('>').print(rendering.text).print("</a>");
}
 
开发者ID:rkfg,项目名称:ns2gather,代码行数:11,代码来源:NS2GToHtmlSerializer.java

示例9: printImageTag

import org.pegdown.LinkRenderer; //导入依赖的package包/类
protected void printImageTag(LinkRenderer.Rendering rendering) {
    printer.print("<img");
    printAttribute("src", rendering.href);
    printAttribute("title", rendering.text);
    printAttribute("class", "chat-image");
    for (LinkRenderer.Attribute attr : rendering.attributes) {
        printAttribute(attr.name, attr.value);
    }
    printer.print("\"/>");
}
 
开发者ID:rkfg,项目名称:ns2gather,代码行数:11,代码来源:NS2GToHtmlSerializer.java

示例10: markdownToHtml

import org.pegdown.LinkRenderer; //导入依赖的package包/类
public String markdownToHtml(char[] markdownSource, LinkRenderer linkRenderer, Map<String, VerbatimSerializer> verbatimSerializerMap) {
    try {
        RootNode astRoot = parseMarkdown(markdownSource);
        return new NS2GToHtmlSerializer(linkRenderer, verbatimSerializerMap).toHtml(astRoot);
    } catch (ParsingTimeoutException e) {
        return null;
    }
}
 
开发者ID:rkfg,项目名称:ns2gather,代码行数:9,代码来源:NS2GPegDownProcessor.java

示例11: formatHtml

import org.pegdown.LinkRenderer; //导入依赖的package包/类
private String formatHtml(String text) {
    if (BricABrac.isBlank(text)) {
        return "";
    }
    PegDownProcessor markdownProcessor = configuration.getMarkdownProcessor();
    RootNode astRoot = markdownProcessor.parseMarkdown(text.toCharArray());

    //astRoot.accept(Visitors.dump());

    List<ToHtmlSerializerPlugin> htmlPlugins = configuration.htmlSerializerPlugins();
    ToHtmlSerializer htmlSerializer = new ToHtmlSerializer(new LinkRenderer(), htmlPlugins);
    return htmlSerializer.toHtml(astRoot);
}
 
开发者ID:Arnauld,项目名称:cucumber-contrib,代码行数:14,代码来源:MarkdownEmitter.java

示例12: getLinkRenderer

import org.pegdown.LinkRenderer; //导入依赖的package包/类
/**
 * Gets the link renderer.
 *
 * @return The link renderer.
 */
public LinkRenderer getLinkRenderer() {
    if ( linkRenderer == null ) {
        linkRenderer = new DocletLinkRenderer();
    }
    return linkRenderer;
}
 
开发者ID:Abnaxos,项目名称:markdown-doclet,代码行数:12,代码来源:Options.java

示例13: printLink

import org.pegdown.LinkRenderer; //导入依赖的package包/类
@Override
protected void printLink(LinkRenderer.Rendering rendering)
{
    printer.print('<').print('a');
    printAttribute("href", rendering.href);
    for (LinkRenderer.Attribute attr : rendering.attributes) {
        printAttribute(attr.name, attr.value);
    }
    printAttribute("target", "_blank");
    printer.print('>').print(rendering.text).print("</a>");        
}
 
开发者ID:windup,项目名称:windup,代码行数:12,代码来源:ToHtmlSerializerExtended.java

示例14: MarkdownToHtmlSerializer

import org.pegdown.LinkRenderer; //导入依赖的package包/类
public MarkdownToHtmlSerializer(final LinkRenderer linkRenderer, final Map<String, VerbatimSerializer> verbatimSerializers) {
    super(linkRenderer, verbatimSerializers);
}
 
开发者ID:microacup,项目名称:microbbs,代码行数:4,代码来源:MarkdownToHtmlSerializer.java

示例15: createAnchorLink

import org.pegdown.LinkRenderer; //导入依赖的package包/类
private LinkRenderer.Rendering createAnchorLink(String title) {
    String cleanedTitle = title.toLowerCase().replace("\n", " ").replaceAll("[^a-z\\d\\s]", " ");
    String slug = StringUtils.arrayToDelimitedString(StringUtils.tokenizeToStringArray(cleanedTitle, " "), "-");
    return new LinkRenderer.Rendering("#"+slug, "").withAttribute("class","anchor").withAttribute("name", slug);
}
 
开发者ID:microacup,项目名称:microbbs,代码行数:6,代码来源:MarkdownToHtmlSerializer.java


注:本文中的org.pegdown.LinkRenderer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。