Package org.pegdown

Examples of org.pegdown.PegDownProcessor


*/
public class MarkdownProcessor {
    PegDownProcessor pegDownProcessor;

    public MarkdownProcessor() {
        pegDownProcessor = new PegDownProcessor();
    }
View Full Code Here


        }
       
        long maxParsingTime = context.getConfig().getLong("markdown.maxParsingTimeInMillis", PegDownProcessor.DEFAULT_MAX_PARSING_TIME);
       
        PegDownProcessor pegdownProcessor = new PegDownProcessor(extensions, maxParsingTime);
        context.setBody(pegdownProcessor.markdownToHtml(context.getBody()));
    }
View Full Code Here

    public MarkdownLexerVisitorTestSupport() {
    }

    public void runTestWithExtensions(String baseName, int extensions) throws IOException {
        String source = getTestResourceAsString(baseName + ".md");
        PegDownProcessor processor = new PegDownProcessor(extensions);
        RootNode rootNode = processor.parseMarkdown(source.toCharArray());

        assertThat("rootNode", rootNode, notNullValue());

        final int totalLength = source.length();
        MarkdownTokenListBuilder builder = new MarkdownTokenListBuilder(totalLength);
View Full Code Here

    /**
     * Tokenizes the input
     */
    private void tokenizeInput() {
        MarkdownGlobalOptions markdownOptions = MarkdownGlobalOptions.getInstance();
        PegDownProcessor markdownProcessor = new PegDownProcessor(markdownOptions.getExtensionsValue());

        // Read the complete input and feed the PegDown Parser
        // Selected extensions over plain markdown are taken in account
        char[] markdownSource = readAll(info.input());

        int inputLength = markdownSource.length;

        List<MarkdownToken> tokens;
        try {
            RootNode rootNode = markdownProcessor.parseMarkdown(markdownSource);

            MarkdownTokenListBuilder builder = new MarkdownTokenListBuilder(inputLength);
            MarkdownLexerVisitor visitor = new MarkdownLexerVisitor(builder);
            rootNode.accept(visitor);
            tokens = builder.build();
View Full Code Here

        this.snapshot = snapshot;

        CharSequence text = snapshot.getText();

        this.extensions = MarkdownGlobalOptions.getInstance().getExtensionsValue();
        PegDownProcessor markdownProcessor = new PegDownProcessor(extensions);

        rootNode = markdownProcessor.parser.parse(text.toString().toCharArray());
    }
View Full Code Here

    private String renderBodyText(Set<RenderOption> renderOptions, MarkdownGlobalOptions markdownOptions,
            String sourceText) throws IOException {
        String bodyText;
        try {
            PegDownProcessor markdownProcessor = new PegDownProcessor(markdownOptions.getExtensionsValue());
            final boolean resolveImageUrls = renderOptions.contains(RenderOption.RESOLVE_IMAGE_URLS);
            final boolean resolveLinkUrls = renderOptions.contains(RenderOption.RESOLVE_LINK_URLS);
            if (resolveImageUrls || resolveLinkUrls) {
                RootNode rootNode = markdownProcessor.parseMarkdown(sourceText.toCharArray());
                FileObject sourceFile = context.getPrimaryFile();
                final PreviewSerializer htmlSerializer
                        = new PreviewSerializer(sourceFile.toURL(), resolveImageUrls, resolveLinkUrls);
                bodyText = htmlSerializer.toHtml(rootNode);
            }
            else {
                RootNode rootNode = markdownProcessor.parseMarkdown(sourceText.toCharArray());
                final ExportSerializer htmlSerializer
                        = new ExportSerializer(new LinkRenderer());
                bodyText = htmlSerializer.toHtml(rootNode);
            }
        }
View Full Code Here

            Item item = new Item();

            String statusText = tempContent.getContent();

            PegDownProcessor processor = new PegDownProcessor();
            String htmlText = processor.markdownToHtml(statusText);
            log.debug("feed html content {}", htmlText);
            // url handling  for mention & tags
            htmlText = convertLinks(htmlText);

            Content content = new Content();
View Full Code Here

   * @param markdown
   * @return html version of markdown text
   * @throws java.text.ParseException
   */
  public static String transformMarkdown(String markdown, LinkRenderer linkRenderer) {
    PegDownProcessor pd = new PegDownProcessor(ALL & ~SMARTYPANTS);
    String html = pd.markdownToHtml(markdown, linkRenderer == null ? new LinkRenderer() : linkRenderer);
    return html;
  }
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.