Package org.eclipse.mylyn.wikitext.core.parser.builder

Examples of org.eclipse.mylyn.wikitext.core.parser.builder.HtmlDocumentBuilder


  private static String renderMarkup(String content, MarkupLanguage markup,
      String pattern) {   
    markup.setInternalLinkPattern(pattern);
    StringWriter writer = new StringWriter();
    DocumentBuilder builder = new HtmlDocumentBuilder(writer);
    MarkupParser parser = new MarkupParser(markup, builder);
    parser.parse(content, false);
    return writer.toString();
  }
View Full Code Here


   * @param commitId
   * @param lang
   */
  private void parse(final MarkupDocument doc, final String repositoryName, final String commitId, MarkupLanguage lang) {
    StringWriter writer = new StringWriter();
    HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer) {

      @Override
      public void image(Attributes attributes, String imagePath) {
        String url;
        if (imagePath.indexOf("://") == -1) {
          // relative image
          String path = doc.getRelativePath(imagePath);
          url = getWicketUrl(RawPage.class, repositoryName, commitId, path);
        } else {
          // absolute image
          url = imagePath;
        }
        super.image(attributes, url);
      }

      @Override
      public void link(Attributes attributes, String hrefOrHashName, String text) {
        String url;
        if (hrefOrHashName.charAt(0) != '#') {
          if (hrefOrHashName.indexOf("://") == -1) {
            // relative link
            String path = doc.getRelativePath(hrefOrHashName);
            url = getWicketUrl(DocPage.class, repositoryName, commitId, path);
          } else {
            // absolute link
            url = hrefOrHashName;
          }
        } else {
          // page-relative hash link
          url = hrefOrHashName;
        }
        super.link(attributes, url, text);
      }
    };

    // avoid the <html> and <body> tags
    builder.setEmitAsDocument(false);

    MarkupParser parser = new MarkupParser(lang);
    parser.setBuilder(builder);
    parser.parse(doc.markup);
    doc.html = writer.toString();
View Full Code Here

   * @param commitId
   * @param lang
   */
  private void parse(final MarkupDocument doc, final String repositoryName, final String commitId, MarkupLanguage lang) {
    StringWriter writer = new StringWriter();
    HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer) {

      @Override
      public void image(Attributes attributes, String imagePath) {
        String url;
        if (imagePath.indexOf("://") == -1) {
          // relative image
          String path = doc.getRelativePath(imagePath);
          String contextUrl = RequestCycle.get().getRequest().getRelativePathPrefixToContextRoot();
          url = RawServlet.asLink(contextUrl, repositoryName, commitId, path);
        } else {
          // absolute image
          url = imagePath;
        }
        super.image(attributes, url);
      }

      @Override
      public void link(Attributes attributes, String hrefOrHashName, String text) {
        String url;
        if (hrefOrHashName.charAt(0) != '#') {
          if (hrefOrHashName.indexOf("://") == -1) {
            // relative link
            String path = doc.getRelativePath(hrefOrHashName);
            url = getWicketUrl(DocPage.class, repositoryName, commitId, path);
          } else {
            // absolute link
            url = hrefOrHashName;
          }
        } else {
          // page-relative hash link
          url = hrefOrHashName;
        }
        super.link(attributes, url, text);
      }
    };

    // avoid the <html> and <body> tags
    builder.setEmitAsDocument(false);

    MarkupParser parser = new MarkupParser(lang);
    parser.setBuilder(builder);
    parser.parse(doc.markup);

View Full Code Here

  @Override
  public String convert(String content) {
    MarkupParser parser = getMarkupParser();
   
    StringWriter writer = new StringWriter();
    HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer);
    // avoid the <html> and <body> tags
    builder.setEmitAsDocument(false);

    parser.setBuilder(builder);
    parser.parse(content);
    parser.setBuilder(null);
    return writer.toString();
View Full Code Here

                    nomarkdownMap.put(nomarkdownKey, "");
                  } else if (nomarkdown instanceof WikiText) {
                    // convert this hunk to html from a wiki format
                    StringWriter writer = new StringWriter();

                    HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer);
                    // avoid the <html> and <body> tags
                    builder.setEmitAsDocument(false);
                   
                    WikiText wikitext = (WikiText) nomarkdown;
                    MarkupLanguage lang;
                    switch (wikitext.syntax){
                    case TWIKI:
View Full Code Here

      } catch (Exception e) {
        throw new BuildException(MessageFormat.format(
            Messages.getString("MarkupToHtmlTask.16"), htmlOutputFile, e.getMessage()), e); //$NON-NLS-1$
      }
      try {
        HtmlDocumentBuilder builder = new HtmlDocumentBuilder(writer, formatOutput);
        for (Stylesheet stylesheet : stylesheets) {
          HtmlDocumentBuilder.Stylesheet builderStylesheet;

          if (stylesheet.url != null) {
            builderStylesheet = new HtmlDocumentBuilder.Stylesheet(stylesheet.url);
          } else {
            builderStylesheet = new HtmlDocumentBuilder.Stylesheet(stylesheet.file);
          }
          builder.addCssStylesheet(builderStylesheet);

          if (!stylesheet.attributes.isEmpty()) {
            for (Map.Entry<String, String> attr : stylesheet.attributes.entrySet()) {
              builderStylesheet.getAttributes().put(attr.getKey(), attr.getValue());
            }
          }
        }

        builder.setTitle(title == null ? name : title);
        builder.setEmitDtd(emitDoctype);
        if (emitDoctype && htmlDoctype != null) {
          builder.setHtmlDtd(htmlDoctype);
        }
        builder.setUseInlineStyles(useInlineCssStyles);
        builder.setSuppressBuiltInStyles(suppressBuiltInCssStyles);
        builder.setLinkRel(linkRel);
        builder.setDefaultAbsoluteLinkTarget(defaultAbsoluteLinkTarget);
        builder.setPrependImagePrefix(prependImagePrefix);
        builder.setXhtmlStrict(xhtmlStrict);

        SplittingStrategy splittingStrategy = multipleOutputFiles ? new DefaultSplittingStrategy()
            : new NoSplittingStrategy();
        SplittingOutlineParser outlineParser = new SplittingOutlineParser();
        outlineParser.setMarkupLanguage(markupLanguage.clone());
View Full Code Here

TOP

Related Classes of org.eclipse.mylyn.wikitext.core.parser.builder.HtmlDocumentBuilder

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.