#[non_exhaustive]pub enum BlockKind {
Paragraph,
Heading {
level: u8,
},
ListItem {
level: u8,
ordinal: Option<u32>,
},
TableCell {
row: u16,
column: u16,
row_span: u16,
column_span: u16,
header: bool,
},
Header,
Footer,
Caption,
Figure,
}Expand description
The block model and both serialisations of it, re-exported from
pdf-engine: what PdfDocument::extract_blocks hands back, which pages
it hands back, and the two ways to write them out (#573).
One definition and not a facade copy of it, for the reason
ProcessingLimits is re-exported rather than mirrored: a caller holding
a Block from the facade and one from the engine must be holding the same
type, or every consumer of both has to convert between two shapes that
carry identical fields.
The kind of a block. Paragraphs (#567), headings (#568) and list items
(#569); tables and running heads arrive with theirs (#570, #571).
#[non_exhaustive] because those variants land in a published crate: a
caller that matches on this must keep a fallback arm, and adding a kind must
not be a breaking change.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Paragraph
Running text: one or more lines the page sets as one paragraph.
Heading
A heading, at a level from 1 to 3 (#568).
The level is the block’s rank among the type the DOCUMENT sets above its
own body, never a point size: see crate::headings. Levels below the
third fold into it, so level is always 1, 2 or 3 and a consumer
mapping it to #..###### never runs off the end.
ListItem
One item of a list (#569).
ONE BLOCK PER ITEM, not one per list. The item is what a caller chunks,
cites and embeds – the same unit every other kind here is – and a
container kind would need a second shape of Block, with its own text
and its own box, for a grouping that consecutive items already say. A
list is therefore a run of adjacent blocks of this kind, and the
markdown serializer reads it as one.
The marker itself is NOT in Block::text: a bullet and a number are
what the page used to say “item”, and a consumer that wanted them back
would have to strip them again before indexing the words. It is still in
Block::spans, which carry what the page drew rather than what it
said. The one exception is an outline’s number – II.4.1, 10.2 –
which stays at the head of the text, because it is the clause’s name as
much as its marker: a cross-reference cites it, and no one ordinal can
say it (#599).
Fields
level: u8Nesting depth, 0 for the outermost list. From the indent steps the column itself uses, never a measurement in points, and never more than four: deeper steps fold into the fourth, the way heading clusters below the third fold into level 3.
ordinal: Option<u32>The number the document wrote – 3. is 3, c) is 3, iv. is 4 –
or None where the item was marked with a bullet, or numbered by
its place in an outline (II.4.1), which no one number says and
which the item’s text therefore keeps.
The document’s own number and not a count of this list’s items, so a list that opens at 5, or one the extraction lost an item out of, still says what the page says.
TableCell
One cell of a table (#570).
ONE BLOCK PER CELL, for the reason a list is one block per item: the
cell is what a caller chunks, cites and embeds, and a container kind
would need a second shape of Block – its own text, its own box –
for a grouping that row, column and a run of adjacent blocks already
say. A table is therefore a run of these in ROW-MAJOR order, opening at
row: 0, column: 0, and crate::markdown reads such a run back as one
table.
The grid is the whole table’s, not the row’s: column is a column of
the table, so the third cell of a row whose second cell is missing is at
column 2 and not at column 1.
Fields
row_span: u16How many rows the cell covers, 1 unless the document ruled two rows together by breaking the rule between them over this column.
Header
A running header: the line a document repeats at the TOP of its pages (#571).
Not in the reading order. crate::reading_order keeps these blocks
after the body rather than dropping them, because what a page repeats
is still something a caller may want to read – the chapter it is in,
the revision of the form – and it is the body it must not interrupt.
A running footer, including a page number (#571).
The same block as BlockKind::Header at the other end of the page:
see there for why it is kept rather than dropped.
Caption
A caption: the line or lines that say what a picture or a table beside them shows (#636). Read by the learned pass from where the page draws its images; the heuristics never produce one.
Figure
A figure: a placed image or a drawn vector cluster on the page (#658).
Listed late, after the learned pass and the text joins, from the
figure boxes the text pass recorded: placed images first, then the
path clusters [crate::text::TextExtractionDevice::take_graphics]
keeps. A page with no text block still carries its placed images –
a scan reads as its figure markers – but no drawn cluster, and
figures merge into their page’s reading order by vertical position.
Block::text is empty: a figure says nothing; the Markdown
serializer writes it as an image reference from its page and its
number among that page’s figures.
Trait Implementations§
impl Copy for BlockKind
impl Eq for BlockKind
impl StructuralPartialEq for BlockKind
Auto Trait Implementations§
impl Freeze for BlockKind
impl RefUnwindSafe for BlockKind
impl Send for BlockKind
impl Sync for BlockKind
impl Unpin for BlockKind
impl UnsafeUnpin for BlockKind
impl UnwindSafe for BlockKind
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneAny for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.