Class HTMLBuilder

java.lang.Object
org.eclipse.text.html.HTMLBuilder

public class HTMLBuilder extends Object
Provides a set of convenience methods for creating HTML pages.

Moved into this package from org.eclipse.jface.internal.text.revisions.

Since:
3.14
  • Constructor Details

    • HTMLBuilder

      public HTMLBuilder()
    • HTMLBuilder

      public HTMLBuilder(RGB bg, RGB fg, RGB link, RGB alink)
  • Method Details

    • setColors

      public void setColors(RGB bg, RGB fg, RGB link, RGB alink)
    • convertToHTMLContent

      public static String convertToHTMLContent(String content)
      Escapes reserved HTML characters in the given string.

      Warning: Does not preserve whitespace.

      Parameters:
      content - the input string
      Returns:
      the string with escaped characters
      See Also:
    • convertToHTMLContentWithWhitespace

      public static String convertToHTMLContentWithWhitespace(String content)
      Escapes reserved HTML characters in the given string and returns them in a way that preserves whitespace in a browser.
      Parameters:
      content - the input string
      Returns:
      the processed string
      Since:
      3.7
      See Also:
    • read

      public static String read(Reader rd)
    • insertPageProlog

      public void insertPageProlog(StringBuilder buffer, int position, RGB fgRGB, RGB bgRGB, String styleSheet)
      Parameters:
      buffer - the output StringBuilder
      position - offset where the prolog is placed
      fgRGB - Foreground-Color
      bgRGB - Background-Color
      styleSheet - Stylesheet
    • insertStyles

      public void insertStyles(StringBuilder buffer, String[] styles)
      Parameters:
      buffer - the output buffer
      styles - array with styles to be appended
    • insertPageProlog

      public void insertPageProlog(StringBuilder buffer, int position)
      Parameters:
      buffer - the output buffer
      position - the offset
    • insertPageProlog

      public void insertPageProlog(StringBuilder buffer, int position, URL styleSheetURL)
      Parameters:
      buffer - the output buffer
      position - the offset
      styleSheetURL - URL to the Stylesheet
    • insertPageProlog

      public void insertPageProlog(StringBuilder buffer, int position, String styleSheet)
      Parameters:
      buffer - the output buffer
      position - the offset
      styleSheet - Stylesheet
    • addPageProlog

      public void addPageProlog(StringBuilder buffer)
      Parameters:
      buffer - the output buffer
    • addPageEpilog

      public void addPageEpilog(StringBuilder buffer)
    • startBulletList

      public void startBulletList(StringBuilder buffer)
      Parameters:
      buffer - the output buffer
    • endBulletList

      public void endBulletList(StringBuilder buffer)
      ends the bulletpointlist
      Parameters:
      buffer - the output buffer
    • addBullet

      public void addBullet(StringBuilder buffer, String bullet)
      Adds bulletpoint
      Parameters:
      buffer - the output buffer
      bullet - the bulletpoint
    • addSmallHeader

      public void addSmallHeader(StringBuilder buffer, String header)
      Adds h5 headline
      Parameters:
      buffer - the output buffer
      header - of h5 headline
    • addParagraph

      public void addParagraph(StringBuilder buffer, String paragraph)
      Parameters:
      buffer - the output buffer
      paragraph - the content of the paragraph
    • addPreFormatted

      public void addPreFormatted(StringBuilder buffer, String preFormatted)
      Appends a string and keeps its whitespace and newlines.
      Parameters:
      buffer - the output StringBuilder
      preFormatted - the string that should be rendered with whitespace preserved
      Since:
      3.7
      See Also:
    • addParagraph

      public void addParagraph(StringBuilder buffer, Reader paragraphReader)
      Parameters:
      buffer - the output buffer
      paragraphReader - The content of the Read will be added to output buffer
    • convertTopLevelFont

      public static String convertTopLevelFont(String styles, boolean bold, boolean italic, int height, String fontName)
      Replaces the following style attributes of the font definition of the html element:
      • font-size
      • font-weight
      • font-style
      • font-family
      The font's name is used as font family, a sans-serif default font family is appended for the case that the given font name is not available.

      If the listed font attributes are not contained in the passed style list, nothing happens.

      Parameters:
      styles - CSS style definitions
      bold - Should the text be bold
      italic - Should the text be italic
      height - Height of the text
      fontName - font name
      Returns:
      the modified style definitions
      Since:
      3.3