Package org.pegdown

Examples of org.pegdown.PegDownProcessor


    public static Result mailing(Proposal.Status status) {
        JsonNode body = request().body().asJson();
        String subjet = body.get("subject").asText();
        String mailMarkdown = body.get("mail").asText();

        PegDownProcessor pegDownProcessor = new PegDownProcessor();
        String mailHtml = pegDownProcessor.markdownToHtml(mailMarkdown);

        Set<String> mailsOfSpeakers = new HashSet<String>();

        for (Proposal proposal : Proposal.findByStatus(status,getEvent())) {
            if (proposal.getSpeaker() != null && proposal.getSpeaker().email != null) {
View Full Code Here


    }
    return null;
  }

  private RootNode parseMarkdown(String md) {
    return new PegDownProcessor(ALL & ~(HARDWRAPS))
        .parseMarkdown(md.toCharArray());
  }
View Full Code Here

   * @return html version of markdown text
   * @throws java.text.ParseException
   */
  public static String transformMarkdown(String markdown, LinkRenderer linkRenderer) {
    try {
      PegDownProcessor pd = new PegDownProcessor(ALL & ~SMARTYPANTS);
      RootNode astRoot = pd.parseMarkdown(markdown.toCharArray());
      return new WorkaroundHtmlSerializer(linkRenderer == null ? new LinkRenderer() : linkRenderer).toHtml(astRoot);
    } catch (ParsingTimeoutException e) {
      return null;
    }
  }
View Full Code Here

   * @return html version of markdown text
   * @throws java.text.ParseException
   */
  public static String transformMarkdown(String markdown, LinkRenderer linkRenderer) {
    try {
      PegDownProcessor pd = new PegDownProcessor(ALL & ~SMARTYPANTS);
      RootNode astRoot = pd.parseMarkdown(markdown.toCharArray());
      return new WorkaroundHtmlSerializer(linkRenderer == null ? new LinkRenderer() : linkRenderer).toHtml(astRoot);
    } catch (ParsingTimeoutException e) {
      return null;
    }
  }
View Full Code Here

    /** Init/reinit thread local {@link PegDownProcessor}. */
    private static ThreadLocal<PegDownProcessor> initProcessor() {
        return new ThreadLocal<PegDownProcessor>() {
            @Override protected PegDownProcessor initialValue() {
                return new PegDownProcessor(MarkdownGlobalSettings.getInstance().getExtensionsValue(),
                                            MarkdownGlobalSettings.getInstance().getParsingTimeout());
            }
        };
    }
View Full Code Here

    /** Init/reinit thread local {@link PegDownProcessor}. */
    private static ThreadLocal<PegDownProcessor> initProcessor() {
        return new ThreadLocal<PegDownProcessor>() {
            @Override protected PegDownProcessor initialValue() {
                return new PegDownProcessor(MarkdownGlobalSettings.getInstance().getExtensionsValue(),
                                            MarkdownGlobalSettings.getInstance().getParsingTimeout());
            }
        };
    }
View Full Code Here

     * you can override this method.
     *
     * @return A (possibly customised) Pegdown processor.
     */
    protected PegDownProcessor createProcessor() {
        return new PegDownProcessor(firstNonNull(pegdownExtensions, DEFAULT_PEGDOWN_EXTENSIONS), getParseTimeout());
    }
View Full Code Here

     * you can override this method.
     *
     * @return A (possibly customised) Pegdown processor.
     */
    protected PegDownProcessor createProcessor() {
        return new PegDownProcessor(firstNonNull(pegdownExtensions, DEFAULT_PEGDOWN_EXTENSIONS), getParseTimeout());
    }
View Full Code Here

    URL url = BaseModel.class.getResource("/views/markdown/demo-all-elements.md");
    String markdown = Resources.toString(url, Charsets.UTF_8).trim();

    // New processor each time due to pegdown not being thread-safe internally
    PegDownProcessor processor = new PegDownProcessor();

    // Return the rendered HTML
    return processor.markdownToHtml(markdown);

  }
View Full Code Here

  private static class ThreadLocalPegDownProcessor extends ThreadLocal<PegDownProcessor> {

    @Override
    protected PegDownProcessor initialValue() {

      return new PegDownProcessor();

    }
View Full Code Here

TOP

Related Classes of org.pegdown.PegDownProcessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.