Skip to main content

BlockKind

Enum BlockKind 

Source
#[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 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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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.

Fields

§level: u8

1, 2 or 3.

§

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: u8

Nesting 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: u16

0-based row inside the table.

§column: u16

0-based column inside the table.

§row_span: u16

How many rows the cell covers, 1 unless the document ruled two rows together by breaking the rule between them over this column.

§column_span: u16

How many columns the cell covers, 1 unless its words cross a column boundary the rest of the table keeps.

§header: bool

Whether the cell is in the table’s header row.

§

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.

§

Footer

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§

Source§

impl Clone for BlockKind

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for BlockKind

Source§

impl Debug for BlockKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for BlockKind

Source§

impl Hash for BlockKind

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for BlockKind

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for BlockKind

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneAny for T
where T: Any + Clone,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts 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>

Converts 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)

Converts &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)

Converts &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
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> DynEq for T
where T: Eq + 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn dyn_eq(&self, other: &(dyn Any + 'static)) -> bool

Source§

impl<T> DynHash for T
where T: Hash + ?Sized,

Source§

fn dyn_hash(&self, state: &mut dyn Hasher)

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more