Struct TexParser

Source
pub struct TexParser {
    pub code_environment: String,
    pub default_language: Option<String>,
    pub comment_start: String,
    pub interpolation_start: String,
    pub interpolation_end: String,
    pub macro_start: String,
    pub macro_end: String,
}
Expand description

The config for parsing a TeX document

Fields§

§code_environment: String

The environment used to indicate code.

Default: code

§default_language: Option<String>

The language to set if there was no automatically detected language. Optional

§comment_start: String

The sequence to identify a comment which should be omitted from the compiled code.

Default: //

§interpolation_start: String

The sequence to identify the start of a meta variable interpolation.

Default: @{

§interpolation_end: String

The sequence to identify the end of a meta variable interpolation.

Default: }

§macro_start: String

The sequence to identify the start of a macro invocation.

Default: ==>

§macro_end: String

The sequence to identify the end of a macro invocation.

Default: .

Implementations§

Source§

impl TexParser

Source

pub fn for_language(language: String) -> Self

Creates a default parser with a fallback language

Source

pub fn default_language(&self, language: Option<String>) -> Self

Sets the default language of this parser (or does nothing if None is passed)

Trait Implementations§

Source§

impl Clone for TexParser

Source§

fn clone(&self) -> TexParser

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 TexParser

Source§

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

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

impl Default for TexParser

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for TexParser

Source§

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

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

impl Parser for TexParser

Source§

type Error = TexError

The type of error for this parser
Source§

fn parse<'a>(&self, input: &'a str) -> Result<Document<'a>, Self::Error>

Parses the text part of the document. Should delegate the code section on a line-by-line basis to the built in code parser.
Source§

fn parse_name<'a>( &self, input: &'a str, ) -> Result<(String, Vec<&'a str>), ParseError>

Parses a macro name, returning the name and the extracted variables
Source§

fn parse_line<'a>( &self, line_number: usize, input: &'a str, ) -> Result<Line<'a>, ParseError>

Parses a line as code, returning the parsed Line object
Source§

impl ParserConfig for TexParser

Source§

fn comment_start(&self) -> &str

The token to denote the start of a comment that should be rendered in the documentation. This may be specified as the actual line comment symbol used by the source language to exclude all comments from the transpiled file, or it can be a completely separate symbol to allow for some comments to be left untouched even in the output files.
Source§

fn interpolation_start(&self) -> &str

The token to denote the start of a meta-variable interpolation
Source§

fn interpolation_end(&self) -> &str

The token to denote the end of a meta-variable interpolation
Source§

fn macro_start(&self) -> &str

The token to denote the start of a macro invocation
Source§

fn macro_end(&self) -> &str

The token to denote the end of a macro invocation
Source§

impl Printer for TexParser

Source§

fn print_text_block<'a>(&self, block: &TextBlock<'a>) -> String

Prints a text block
Source§

fn print_code_block<'a>(&self, block: &CodeBlock<'a>) -> String

Prints a code block
Source§

fn print_name(&self, name: String, vars: &[&str]) -> String

Fills a name with its placeholders
Source§

fn print_line<'a>(&self, line: &Line<'a>, print_comments: bool) -> String

Prints a line of a code block

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> 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,