Skip to main content

Body

Struct Body 

Source
pub struct Body {
Show 14 fields pub blocks: Vec<Block>, pub headings: Vec<Heading>, pub links: Vec<Link>, pub footnote_refs: Vec<(String, usize)>, pub footnote_defs: Vec<(String, usize)>, pub ref_defs: Vec<(String, String, usize)>, pub inline_html: Vec<usize>, pub fenced: Vec<(usize, usize)>, pub code_blocks: Vec<CodeBlock>, pub code_spans: Vec<(usize, usize, usize)>, pub link_spans: Vec<(usize, usize, usize)>, pub anchors: Vec<Anchor>, pub reading_changes: Vec<(usize, usize, usize, String)>, pub first_line: usize,
}
Expand description

A parsed body.

Fields§

§blocks: Vec<Block>

The blocks, in order, headings excluded.

§headings: Vec<Heading>

The headings, in order.

§links: Vec<Link>

Every link and image, include interiors and the definition block excluded.

§footnote_refs: Vec<(String, usize)>

Footnote references: label and line.

§footnote_defs: Vec<(String, usize)>

Footnote definitions: label and line.

§ref_defs: Vec<(String, String, usize)>

The link reference definitions outside the generated block, those in a list item or a quote among them, as comrak reads them: label, destination as written, and the line of the label, in order.

§inline_html: Vec<usize>

Lines carrying inline HTML other than a comment.

§fenced: Vec<(usize, usize)>

Line ranges of fenced and indented code, inclusive: the lines of each entry of code_blocks.

§code_blocks: Vec<CodeBlock>

Every code block, at any depth of quotes, lists, and footnotes, in the order of the document; none inside a region or the trailer.

§code_spans: Vec<(usize, usize, usize)>

Byte ranges a code span covers: line, start, end. A span crossing lines records one entry per line.

§link_spans: Vec<(usize, usize, usize)>

Byte ranges a link’s text and destination cover: line, start, end, as code_spans.

§anchors: Vec<Anchor>

The generated anchors, removed from the text before it was parsed (TLMD_107).

§reading_changes: Vec<(usize, usize, usize, String)>

Each change that the readings of the units and the headings make on one line, in order: the line, the start and the end of the bytes that it replaces in the line without its anchors, and what the reading writes in their place.

§first_line: usize

The line the body starts on.

Implementations§

Source§

impl Body

Source

pub fn nested_headings(&self) -> Vec<Heading>

Each heading inside a list item or a quote, at any depth, in the order of the document, with the slug of TLMD_101. Such a heading is part of its block, not a heading of the document (TLMD_173), but a host that resolves a link to it needs it.

Source

pub fn blocks_between(&self, from: usize, to: usize) -> Vec<&Block>

The blocks between from (exclusive) and to (exclusive), as a section’s body.

Source

pub fn in_code(&self, line: usize) -> bool

Whether line lies inside fenced or indented code.

Source

pub fn clean_line<'a>(&self, line: usize, text: &'a str) -> Cow<'a, str>

text, the line numbered line as written, without the generated anchors the parse removed from it.

Source

pub fn read_line(&self, line: usize, text: &str) -> Reading

text, the line numbered line without its anchors, in its reading: each change that the readings of the units and the headings make on the line applied, each byte mapped to its byte of text.

Source

pub fn in_code_span(&self, line: usize, col: usize) -> bool

Whether byte col of line lies inside a code span.

Source

pub fn span_around(&self, line: usize, col: usize) -> Option<usize>

Whether byte col of line lies strictly inside a code span or a link, and where that span starts.

Source

pub fn mask_spans<'a>(&self, line: usize, text: &'a str) -> Cow<'a, str>

text, the line numbered line, with every code span overwritten by a run of backticks, as mask_code reads it. Lengths, byte offsets, and line numbers are kept, so a finding still points where the text is.

Trait Implementations§

Source§

impl Clone for Body

Source§

fn clone(&self) -> Body

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 Debug for Body

Source§

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

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

impl Default for Body

Source§

fn default() -> Body

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Body

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Body, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Body

Source§

impl PartialEq for Body

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for Body

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Body

Auto Trait Implementations§

§

impl Forget for Body

§

impl Freeze for Body

§

impl Move for Body

§

impl RefUnwindSafe for Body

§

impl Send for Body

§

impl Sync for Body

§

impl Unpin for Body

§

impl UnsafeUnpin for Body

§

impl UnwindSafe for Body

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> 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

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

Source§

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

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<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<'a, T> FromIn<'a, T> for T

Source§

fn from_in(t: T, _: &'a Allocator) -> T

Converts to this type from the input type within the given allocator.
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<'a, T, U> IntoIn<'a, U> for T
where U: FromIn<'a, T>,

Source§

fn into_in(self, allocator: &'a Allocator) -> U

Converts this type into the (usually inferred) input type within the given allocator.
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, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> 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> ToJmespath for T
where T: Serialize,

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.