Top Description Fields Constructors Methods
org.jabref.htmltonode

public final Class HtmlRenderOptions

extends Object
Class Inheritance
Imports
java.util.function.Consumer, javafx.scene.text.Font, org.jspecify.annotations.Nullable

Rendering options. Immutable; start from defaults() and refine via with… methods:
HtmlRenderOptions options = HtmlRenderOptions.defaults() .withLinkHandler(url -> openInBrowser(url)) .withBaseUri(libraryFileDirectory.toUri().toString());
HtmlRenderOptions options = HtmlRenderOptions.defaults()
        .withLinkHandler(url -> openInBrowser(url))
        .withBaseUri(libraryFileDirectory.toUri().toString());

Field Summary

Modifier and TypeField and Description
private final @Nullable String
private final double
private final @Nullable String
private final Consumer<String>
private final boolean
private final String
private final boolean

Constructor Summary

AccessConstructor and Description
private
HtmlRenderOptions(double baseFontSize, @Nullable String baseFontFamily, String monospaceFontFamily, Consumer<String> linkHandler, @Nullable String baseUri, boolean renderImages, boolean loadRemoteImages)

Method Summary

Modifier and TypeMethod and Description
public @Nullable String
baseFontFamily()

Returns: the configured base font family, or null if unset

public double
baseFontSize()

Returns: the configured base font size, or a non-positive value if unset

public @Nullable String
baseUri()

Returns: the base URI for resolving relative URLs, or null if unset

public static HtmlRenderOptions

Returns:

the default options
defaults
()

Default options: system font and size, links ignored, file:/data: images rendered, remote images not loaded, no base URI.

public Consumer<String>
linkHandler()

Returns: the handler invoked with the resolved href of a clicked link

public boolean
loadRemoteImages()

Returns: whether http(s): image sources may be loaded

public String
monospaceFontFamily()

Returns: the font family used for monospace runs

public boolean
renderImages()

Returns: whether <img> elements are rendered at all

public String
resolvedBaseFontFamily()

Returns: the effective base font family: the configured one, or Font#getDefault()'s family

public double
resolvedBaseFontSize()

Returns: the effective base font size: the configured one, or Font#getDefault()'s size

public HtmlRenderOptions
withBaseFontFamily(@Nullable String newBaseFontFamily)

Font family for regular text; unset means Font#getDefault()'s family.

public HtmlRenderOptions
withBaseFontSize(double newBaseFontSize)

Base font size in points/pixels; unset means Font#getDefault()'s size.

public HtmlRenderOptions
withBaseUri(String
the base URI; use withoutBaseUri() to express absence
newBaseUri
)

Base URI against which relative href/src values are resolved (replacement for the <base href> JabRef injects for WebView today).

public HtmlRenderOptions
withLinkHandler(Consumer<String> newLinkHandler)

Invoked with the (resolved) href when a link is clicked.

public HtmlRenderOptions
withLoadRemoteImages(boolean newLoadRemoteImages)

Allow http(s): image sources.

public HtmlRenderOptions
withMonospaceFontFamily(String newMonospaceFontFamily)

Font family for code/pre content.

public HtmlRenderOptions
withoutBaseUri()

Leaves relative href/src values unresolved (the default).

public HtmlRenderOptions
withRenderImages(boolean newRenderImages)

Disable to skip <img> entirely (useful in tests and tooltips).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

baseFontFamilyback to summary
private final @Nullable String baseFontFamily
baseFontSizeback to summary
private final double baseFontSize
baseUriback to summary
private final @Nullable String baseUri
linkHandlerback to summary
private final Consumer<String> linkHandler
loadRemoteImagesback to summary
private final boolean loadRemoteImages
monospaceFontFamilyback to summary
private final String monospaceFontFamily
renderImagesback to summary
private final boolean renderImages

Constructor Detail

HtmlRenderOptionsback to summary
private HtmlRenderOptions(double baseFontSize, @Nullable String baseFontFamily, String monospaceFontFamily, Consumer<String> linkHandler, @Nullable String baseUri, boolean renderImages, boolean loadRemoteImages)

Method Detail

baseFontFamilyback to summary
public @Nullable String baseFontFamily()
Returns:@Nullable String

the configured base font family, or null if unset

baseFontSizeback to summary
public double baseFontSize()
Returns:double

the configured base font size, or a non-positive value if unset

baseUriback to summary
public @Nullable String baseUri()
Returns:@Nullable String

the base URI for resolving relative URLs, or null if unset

defaultsback to summary
public static HtmlRenderOptions defaults()

Default options: system font and size, links ignored, file:/data: images rendered, remote images not loaded, no base URI.

Returns:HtmlRenderOptions

the default options

linkHandlerback to summary
public Consumer<String> linkHandler()
Returns:Consumer<String>

the handler invoked with the resolved href of a clicked link

loadRemoteImagesback to summary
public boolean loadRemoteImages()
Returns:boolean

whether http(s): image sources may be loaded

monospaceFontFamilyback to summary
public String monospaceFontFamily()
Returns:String

the font family used for monospace runs

renderImagesback to summary
public boolean renderImages()
Returns:boolean

whether <img> elements are rendered at all

resolvedBaseFontFamilyback to summary
public String resolvedBaseFontFamily()
Returns:String

the effective base font family: the configured one, or Font#getDefault()'s family

resolvedBaseFontSizeback to summary
public double resolvedBaseFontSize()
Returns:double

the effective base font size: the configured one, or Font#getDefault()'s size

withBaseFontFamilyback to summary
public HtmlRenderOptions withBaseFontFamily(@Nullable String newBaseFontFamily)

Font family for regular text; unset means Font#getDefault()'s family.

withBaseFontSizeback to summary
public HtmlRenderOptions withBaseFontSize(double newBaseFontSize)

Base font size in points/pixels; unset means Font#getDefault()'s size.

withBaseUriback to summary
public HtmlRenderOptions withBaseUri(String newBaseUri)

Base URI against which relative href/src values are resolved (replacement for the <base href> JabRef injects for WebView today).

Parameters
newBaseUri:String

the base URI; use withoutBaseUri() to express absence

withLinkHandlerback to summary
public HtmlRenderOptions withLinkHandler(Consumer<String> newLinkHandler)

Invoked with the (resolved) href when a link is clicked. Default: no-op.

withLoadRemoteImagesback to summary
public HtmlRenderOptions withLoadRemoteImages(boolean newLoadRemoteImages)

Allow http(s): image sources. Off by default; file:/data:/jar: always load.

withMonospaceFontFamilyback to summary
public HtmlRenderOptions withMonospaceFontFamily(String newMonospaceFontFamily)

Font family for code/pre content. Default: "Monospaced" (JavaFX logical font).

withoutBaseUriback to summary
public HtmlRenderOptions withoutBaseUri()

Leaves relative href/src values unresolved (the default).

withRenderImagesback to summary
public HtmlRenderOptions withRenderImages(boolean newRenderImages)

Disable to skip <img> entirely (useful in tests and tooltips).