Top Description Constructors Methods
org.jabref.htmltonode

public final Class HtmlToNode

extends Object
Class Inheritance
Imports
java.util.List, .Objects, javafx.scene.layout.Region, org.jabref.htmltonode.internal.HtmlToModel, .PlainText, org.jabref.htmltonode.model.Block, org.jspecify.annotations.Nullable

Entry point: converts HTML (the subset produced for JabRef's entry preview — citeproc-java CSL output, JabRef preview layouts, flexmark markdown, <mark> search highlights) into plain JavaFX nodes, with no dependency on javafx.web.
Region preview = HtmlToNode.render(citationHtml, HtmlRenderOptions.defaults() .withLinkHandler(NativeDesktop::openBrowserShowPopup)); scrollPane.setContent(preview);
Region preview = HtmlToNode.render(citationHtml, HtmlRenderOptions.defaults()
        .withLinkHandler(NativeDesktop::openBrowserShowPopup));
scrollPane.setContent(preview);

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static List<Block>

Returns:

the parsed blocks, in document order; empty for blank input, never null
parse
(String
the HTML to parse; documents, fragments and malformed markup are all accepted
html
)

Parses HTML into the renderer-independent block model.

public static List<Block>

Returns:

the parsed blocks, in document order; empty for blank input, never null
parse
(String
the HTML to parse
html
,
@Nullable String
the URI to resolve relative href/src values against, or null for none
baseUri
)

Parses HTML, resolving relative links and image sources against baseUri (a <base href> inside the HTML wins, as in a browser).

public static Region

Returns:

the rendered content, ready to be placed in a ScrollPane or any other parent
render
(String
the HTML to render
html
)

Parses and renders HTML with HtmlRenderOptions#defaults().

public static Region

Returns:

the rendered content, ready to be placed in a ScrollPane or any other parent
render
(String
the HTML to render
html
,
HtmlRenderOptions
rendering options
options
)

Parses and renders HTML in one step, resolving relative URLs against HtmlRenderOptions#baseUri().

public static Region

Returns:

the rendered content, ready to be placed in a ScrollPane or any other parent
render
(List<Block>
the blocks to render
blocks
,
HtmlRenderOptions
rendering options
options
)

Renders an already parsed block model, e.g. to render the result of parse(String) several times or with different options.

public static String

Returns:

the stylesheet URL in the form accepted by Parent#getStylesheets()
stylesheet
()

URL of the built-in stylesheet (already attached to rendered roots).

public static String

Returns:

the text content with paragraph breaks, list markers and tab-separated table cells
toPlainText
(String
the HTML to convert
html
)

Extracts readable plain text, comparable to the DOM's document.body.innerText (which JabRef's "Copy preview" uses with WebView today).

public static String

Returns:

the text content with paragraph breaks, list markers and tab-separated table cells
toPlainText
(List<Block>
the blocks to convert
blocks
)

Extracts readable plain text from an already parsed block model.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

HtmlToNodeback to summary
private HtmlToNode()

Method Detail

parseback to summary
public static List<Block> parse(String html)

Parses HTML into the renderer-independent block model.

Parameters
html:String

the HTML to parse; documents, fragments and malformed markup are all accepted

Returns:List<Block>

the parsed blocks, in document order; empty for blank input, never null

parseback to summary
public static List<Block> parse(String html, @Nullable String baseUri)

Parses HTML, resolving relative links and image sources against baseUri (a <base href> inside the HTML wins, as in a browser).

Parameters
html:String

the HTML to parse

baseUri:@Nullable String

the URI to resolve relative href/src values against, or null for none

Returns:List<Block>

the parsed blocks, in document order; empty for blank input, never null

renderback to summary
public static Region render(String html)

Parses and renders HTML with HtmlRenderOptions#defaults().

Parameters
html:String

the HTML to render

Returns:Region

the rendered content, ready to be placed in a ScrollPane or any other parent

renderback to summary
public static Region render(String html, HtmlRenderOptions options)

Parses and renders HTML in one step, resolving relative URLs against HtmlRenderOptions#baseUri().

Parameters
html:String

the HTML to render

options:HtmlRenderOptions

rendering options

Returns:Region

the rendered content, ready to be placed in a ScrollPane or any other parent

renderback to summary
public static Region render(List<Block> blocks, HtmlRenderOptions options)

Renders an already parsed block model, e.g. to render the result of parse(String) several times or with different options.

Parameters
blocks:List<Block>

the blocks to render

options:HtmlRenderOptions

rendering options

Returns:Region

the rendered content, ready to be placed in a ScrollPane or any other parent

stylesheetback to summary
public static String stylesheet()

URL of the built-in stylesheet (already attached to rendered roots). Add it to a scene only when styling nodes that were re-parented out of the rendered tree.

Returns:String

the stylesheet URL in the form accepted by Parent#getStylesheets()

toPlainTextback to summary
public static String toPlainText(String html)

Extracts readable plain text, comparable to the DOM's document.body.innerText (which JabRef's "Copy preview" uses with WebView today).

Parameters
html:String

the HTML to convert

Returns:String

the text content with paragraph breaks, list markers and tab-separated table cells

toPlainTextback to summary
public static String toPlainText(List<Block> blocks)

Extracts readable plain text from an already parsed block model.

Parameters
blocks:List<Block>

the blocks to convert

Returns:String

the text content with paragraph breaks, list markers and tab-separated table cells