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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addBullet
(StringBuilder buffer, String bullet) Adds bulletpointvoid
addPageEpilog
(StringBuilder buffer) void
addPageProlog
(StringBuilder buffer) void
addParagraph
(StringBuilder buffer, Reader paragraphReader) void
addParagraph
(StringBuilder buffer, String paragraph) void
addPreFormatted
(StringBuilder buffer, String preFormatted) Appends a string and keeps its whitespace and newlines.void
addSmallHeader
(StringBuilder buffer, String header) Adds h5 headlinestatic String
convertToHTMLContent
(String content) Escapes reserved HTML characters in the given string.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.static String
convertTopLevelFont
(String styles, boolean bold, boolean italic, int height, String fontName) Replaces the following style attributes of the font definition of thehtml
element: font-size font-weight font-style font-family The font's name is used as font family, asans-serif
default font family is appended for the case that the given font name is not available.void
endBulletList
(StringBuilder buffer) ends the bulletpointlistvoid
insertPageProlog
(StringBuilder buffer, int position) void
insertPageProlog
(StringBuilder buffer, int position, String styleSheet) void
insertPageProlog
(StringBuilder buffer, int position, URL styleSheetURL) void
insertPageProlog
(StringBuilder buffer, int position, RGB fgRGB, RGB bgRGB, String styleSheet) void
insertStyles
(StringBuilder buffer, String[] styles) static String
void
void
startBulletList
(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 thehtml
element:- font-size
- font-weight
- font-style
- font-family
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 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
-