Package org.eclipse.text.html
Class HTMLBuilder
java.lang.Object
org.eclipse.text.html.HTMLBuilder
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBullet(StringBuilder buffer, String bullet) Adds bulletpointvoidaddPageEpilog(StringBuilder buffer) voidaddPageProlog(StringBuilder buffer) voidaddParagraph(StringBuilder buffer, Reader paragraphReader) voidaddParagraph(StringBuilder buffer, String paragraph) voidaddPreFormatted(StringBuilder buffer, String preFormatted) Appends a string and keeps its whitespace and newlines.voidaddSmallHeader(StringBuilder buffer, String header) Adds h5 headlinestatic StringconvertToHTMLContent(String content) Escapes reserved HTML characters in the given string.static StringconvertToHTMLContentWithWhitespace(String content) Escapes reserved HTML characters in the given string and returns them in a way that preserves whitespace in a browser.static StringconvertTopLevelFont(String styles, boolean bold, boolean italic, int height, String fontName) Replaces the following style attributes of the font definition of thehtmlelement: font-size font-weight font-style font-family The font's name is used as font family, asans-serifdefault font family is appended for the case that the given font name is not available.voidendBulletList(StringBuilder buffer) ends the bulletpointlistvoidinsertPageProlog(StringBuilder buffer, int position) voidinsertPageProlog(StringBuilder buffer, int position, String styleSheet) voidinsertPageProlog(StringBuilder buffer, int position, URL styleSheetURL) voidinsertPageProlog(StringBuilder buffer, int position, RGB fgRGB, RGB bgRGB, String styleSheet) voidinsertStyles(StringBuilder buffer, String[] styles) static StringvoidvoidstartBulletList(StringBuilder buffer)
-
Constructor Details
-
HTMLBuilder
public HTMLBuilder() -
HTMLBuilder
-
-
Method Details
-
setColors
-
convertToHTMLContent
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
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
-
insertPageProlog
public void insertPageProlog(StringBuilder buffer, int position, RGB fgRGB, RGB bgRGB, String styleSheet) - Parameters:
buffer- the output StringBuilderposition- offset where the prolog is placedfgRGB- Foreground-ColorbgRGB- Background-ColorstyleSheet- Stylesheet
-
insertStyles
- Parameters:
buffer- the output bufferstyles- array with styles to be appended
-
insertPageProlog
- Parameters:
buffer- the output bufferposition- the offset
-
insertPageProlog
- Parameters:
buffer- the output bufferposition- the offsetstyleSheetURL- URL to the Stylesheet
-
insertPageProlog
- Parameters:
buffer- the output bufferposition- the offsetstyleSheet- Stylesheet
-
addPageProlog
- Parameters:
buffer- the output buffer
-
addPageEpilog
-
startBulletList
- Parameters:
buffer- the output buffer
-
endBulletList
ends the bulletpointlist- Parameters:
buffer- the output buffer
-
addBullet
Adds bulletpoint- Parameters:
buffer- the output bufferbullet- the bulletpoint
-
addSmallHeader
Adds h5 headline- Parameters:
buffer- the output bufferheader- of h5 headline
-
addParagraph
- Parameters:
buffer- the output bufferparagraph- the content of the paragraph
-
addPreFormatted
Appends a string and keeps its whitespace and newlines.- Parameters:
buffer- the output StringBuilderpreFormatted- the string that should be rendered with whitespace preserved- Since:
- 3.7
- See Also:
-
addParagraph
- Parameters:
buffer- the output bufferparagraphReader- 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 thehtmlelement:- font-size
- font-weight
- font-style
- font-family
sans-serifdefault 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 definitionsbold- Should the text be bolditalic- Should the text be italicheight- Height of the textfontName- font name- Returns:
- the modified style definitions
- Since:
- 3.3
-