Top Description Fields Constructors Methods
org.jabref.htmltonode.internal

pack-priv final Class BlockCollector

extends Object
Class Inheritance
Imports
java.util.ArrayList, .List, java.util.regex.Pattern, org.jabref.htmltonode.model.Block, .Inline, .InlineStyle

Accumulates blocks while walking the DOM. Inline content between block elements is gathered into "anonymous" paragraphs (spaced = false, no CSS classes), with HTML whitespace collapsing across element boundaries. U+00A0 ( ) is intentionally not treated as collapsible.

Field Summary

Modifier and TypeField and Description
private boolean
afterWhitespace

true at paragraph start and after emitted whitespace/line breaks → leading spaces are dropped

private final List<Block>
private static final Pattern
private final List<Inline>
private final boolean

Constructor Summary

AccessConstructor and Description
pack-priv
BlockCollector(boolean preserveWhitespace)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
add(Block block)

Adds a block, closing any open anonymous paragraph first.

pack-priv void
pack-priv void
pack-priv void
appendText(String text, InlineStyle style, WhiteSpaceMode whiteSpace)

private void
pack-priv List<Block>
private static List<Inline>
private static List<Inline>
trimTrailing(List<Inline> inlines)

Removes trailing whitespace runs and trailing line breaks (browsers do not render a line break that is the last thing in a block).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

afterWhitespaceback to summary
private boolean afterWhitespace

true at paragraph start and after emitted whitespace/line breaks → leading spaces are dropped

blocksback to summary
private final List<Block> blocks
COLLAPSIBLE_WHITESPACEback to summary
private static final Pattern COLLAPSIBLE_WHITESPACE
currentInlinesback to summary
private final List<Inline> currentInlines
preserveWhitespaceback to summary
private final boolean preserveWhitespace

Constructor Detail

BlockCollectorback to summary
pack-priv BlockCollector(boolean preserveWhitespace)

Method Detail

addback to summary
pack-priv void add(Block block)

Adds a block, closing any open anonymous paragraph first.

appendImageback to summary
pack-priv void appendImage(Inline.Image image)
appendLineBreakback to summary
pack-priv void appendLineBreak()
appendTextback to summary
pack-priv void appendText(String text, InlineStyle style, WhiteSpaceMode whiteSpace)
closeParagraphback to summary
private void closeParagraph()
finishback to summary
pack-priv List<Block> finish()
mergeAdjacentRunsback to summary
private static List<Inline> mergeAdjacentRuns(List<Inline> inlines)
trimTrailingback to summary
private static List<Inline> trimTrailing(List<Inline> inlines)

Removes trailing whitespace runs and trailing line breaks (browsers do not render a line break that is the last thing in a block).