Skip to main content

Mouth

Struct Mouth 

Source
pub struct Mouth { /* private fields */ }

Implementations§

Source§

impl Mouth

Source

pub fn create(source: &str, options: MouthOptions) -> Result<Self>

Source

pub fn foodtype(&self) -> FoodType

What kind of source feeds this mouth (file vs literal/string injection).

Source

pub fn new(text: &str, options: Option<MouthOptions>) -> Result<Self>

Source

pub fn with_bib_data_literals(self) -> Self

Read % & # as ordinary characters (catcode 12) instead of comment, alignment tab and parameter, for the whole life of this mouth.

Treatment 1 of two (see OXIDIZED_DESIGN #74): this is “be bibtex”. BibTeX’s lexer interprets only braces and the entry/field delimiters — it has no comment syntax inside an entry (% is significant only in the junk BETWEEN entries, Pre::BibTeX::skipJunk), no alignment and no parameters. So a field value it hands back is a string in which all three are ordinary characters: a percent-encoded URL, a publisher’s name (“Taylor & Francis”), an issue number.

Re-injected as TeX source (BibTeX.pool’s \bibentry@create) under the default catcodes, each misfires: % (14) comments out the rest of its line — the field’s own closing brace included — so the entry’s group never closes; & (4) is a stray alignment tab and is dropped; # (6) reaches the Stomach as a parameter token. Reading the injected text with all three neutralized preserves the value BibTeX actually parsed, without altering a byte of it.

_ is deliberately NOT in this set, and the reason is the boundary between the two treatments. A catcode is decided at tokenization, before anything knows whether it is inside $…$ — and a subscript in a .bib title’s math (title = {Bounds on $x_1+x_2$}) is legitimate TeX that must keep working. _ therefore belongs to treatment 2 (bibtex.rs::escape_bib_data_specials), which walks the value and skips math spans. Measured: putting _ here silently flattened every subscript in a bibliography title. The other three have no legitimate meaning inside a .bib field, in math or out.

A \catcode in the injected text cannot do this job either: the catcode would still be a State assignment, so a raw .sty opened from inside a field handler would inherit it — and so would the document. Scoping to the Mouth keeps the rule attached to the text that BibTeX lexed, which is exactly where it belongs.

Only the TeX-special meaning is removed: a character that has been given some other catcode (LETTER, say) keeps it. And \%, \&, \# still work, because the backslash is untouched.

Source

pub fn get_source(&self) -> &str

Source

pub fn open(&mut self, content: &str) -> Result<()>

Source

pub fn stop_reading(&mut self)

Stop reading from this mouth: clear buffers and close file handle. Called by flush_mouth (\endinput) to prevent further reading. Does NOT restore catcodes — that’s done by finish().

Source

pub fn finish(&mut self)

Fully finish this mouth: stop reading AND restore catcodes/state. Called by close_mouth when the mouth is popped from the stack.

Source

pub fn has_more_input(&mut self) -> bool

Checks if there is more input to process.

Note: we need mutability, as we may refill the internal BufReader when performing the check.

Source

pub fn read_token(&mut self) -> Option<Token>

Read the next token, or undef if exhausted. Note that this also returns COMMENT tokens containing source comments, and also locator comments (file, line# info). LaTeXML::Core::Gullet intercepts them and passes them on at appropriate times.

Source

pub fn read_tokens(&mut self) -> Tokens

Read all tokens until a token equal to $until (if given), or until exhausted. Returns an empty Tokens list, if there is no input

Source

pub fn read_raw_line(&mut self, noread: bool) -> Option<String>

Source

pub fn is_eol(&mut self) -> bool

Checks if Mouth read is at the end of a line.

Careful: used BOTH for flushing input for \endinput and for detecting line end for \read

Source

pub fn at_eof(&self) -> bool

Source

pub fn get_locator_from_start(&self) -> Locator

§1 accurate-start locator (docs/performance/SOURCE_PROVENANCE.md): from = the captured start of the most recently begun token (last_token_start), to = the mouth’s current position. Unlike get_locator, whose from is the eating-disorder heuristic (line start vs current col), this from is exact for the token currently being processed — the basis for accurate construct-start ranges under --source-map. lineno is already 1-indexed (it counts from 1 after the first line fetch); colno is 0-indexed, +1 to 1-indexed columns, matching get_locator.

Source

pub fn get_location(&self) -> String

Trait Implementations§

Source§

impl Debug for Mouth

Source§

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

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

impl Default for Mouth

Source§

fn default() -> Self

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

impl Display for Mouth

Source§

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

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

impl From<Mouth> for Stored

Source§

fn from(value: Mouth) -> Self

Converts to this type from the input type.
Source§

impl Object for Mouth

Source§

fn stringify(&self) -> String

Source§

fn get_locator(&self) -> Option<Locator>

The object’s stored source locator, if it has one. None is the honest “no recorded source position” (replacing the old Locator::default() file!()/line!() sentinel). For “where the parser is now” (error reporting, box creation), use the free fn gullet::get_locator().
Source§

fn isa_box(&self) -> bool

Source§

fn is_expandable(&self) -> bool

Source§

fn is_definition(&self) -> bool

Source§

fn is_comment(&self) -> bool

Source§

fn be_digested(self) -> Result<Digested>
where Self: Sized + Debug,

Source§

fn revert(&self) -> Result<Tokens>

each concrete object needs to provide its own path back to tokens
Source§

impl PartialEq for Mouth

Source§

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

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

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

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl Freeze for Mouth

§

impl RefUnwindSafe for Mouth

§

impl Send for Mouth

§

impl Sync for Mouth

§

impl Unpin for Mouth

§

impl UnsafeUnpin for Mouth

§

impl UnwindSafe for Mouth

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.