Enum CommentItem

Source
pub enum CommentItem {
Show 14 variants Text(Span), LineBreak(usize), StartMathMode(usize), EndMathMode(usize), MathToken(Span), Label(usize, Span), Url(usize, Span), StartHtml(usize), EndHtml(usize), StartSubscript(usize), EndSubscript(usize), StartItalic(usize), EndItalic(usize), BibTag(Span),
}
Expand description

A comment markup item, which represents either a piece of text from the input or some kind of metadata item like the start or end of an italicized group.

Variants§

§

Text(Span)

A piece of regular text. The characters in the buffer at the given span should be interpreted literally, except for the escapes. Use unescape_text to strip the text escapes [, ~, `, and _. Note that [ and _ can also appear unescaped.

§

LineBreak(usize)

A paragraph break, caused by two or more consecutive newlines in the input. This is a zero-length item (all characters will be present in Text nodes before and after the element), but corresponds roughly to a <p> tag in HTML.

§

StartMathMode(usize)

Start math mode, indicated by a backtick character. The usize points to the character. Between CommentItem::StartMathMode and CommentItem::EndMathMode, there will be no comment items other than CommentItem::MathToken.

§

EndMathMode(usize)

End math mode, indicated by a backtick character. The usize points to the character. Between CommentItem::StartMathMode and CommentItem::EndMathMode, there will be no comment items other than CommentItem::MathToken.

§

MathToken(Span)

A single math token. After unescaping this should correspond to a $c or $v statement in the database. Use unescape_math to strip the escape character `.

§

Label(usize, Span)

A label of an existing theorem. The usize points to the ~ character. Use unescape_text to strip the text escapes [, ~, `, and _. Note that [, ~, _ can also appear unescaped.

§

Url(usize, Span)

A link to a web site URL. The usize points to the ~ character. Use unescape_text to strip the text escapes [, ~, `, and _. Note that [, ~, _ can also appear unescaped.

§

StartHtml(usize)

The <HTML> keyword, which starts HTML mode (it doesn’t actually put <HTML> in the output). In HTML mode subscripts and italics are disabled, and HTML markup is interpreted.

§

EndHtml(usize)

The </HTML> keyword, which ends HTML mode (it doesn’t actually put </HTML> in the output).

§

StartSubscript(usize)

The start of a subscript x_0. The usize points at the _ character.

§

EndSubscript(usize)

The end of a subscript like x_0. The usize points just after the end of the word.

§

StartItalic(usize)

The start of an italic section _italic text_. The usize points at the _ character.

§

EndItalic(usize)

The end of an italic section _italic text_. The usize points at the _ character.

§

BibTag(Span)

A bibliographic label [foo]. No escapes are needed inside the tag body.

Implementations§

Source§

impl CommentItem

Source

pub fn unescape_text(html_mode: bool, buf: &[u8], out: &mut Vec<u8>)

Remove text escapes from a markup segment buf, generally coming from the CommentItem::Text field.

Source

pub fn unescape_label(buf: &[u8], out: &mut Vec<u8>)

Remove text escapes from a markup segment buf, generally coming from the CommentItem::Label or CommentItem::Url fields.

Source

pub fn unescape_math(buf: &[u8], out: &mut Vec<u8>)

Remove math escapes from a markup segment buf, generally coming from the CommentItem::MathToken field.

Trait Implementations§

Source§

impl Clone for CommentItem

Source§

fn clone(&self) -> CommentItem

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for CommentItem

Source§

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

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

impl PartialEq for CommentItem

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for CommentItem

Source§

impl Eq for CommentItem

Source§

impl StructuralPartialEq for CommentItem

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> 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.