Skip to main content

Model

Struct Model 

Source
pub struct Model {
    pub schema: Option<Relaxng>,
    pub schema_data: Option<Vec<SymStr>>,
    pub schema_class: SymHashMap<FxHashSet<SymStr>>,
    pub code_namespace_prefixes: SymHashMap<SymStr>,
    pub code_namespaces: SymHashMap<SymStr>,
    pub document_namespace_prefixes: SymHashMap<SymStr>,
    pub document_namespaces: SymHashMap<SymStr>,
    pub permissive: bool,
    pub no_compiled: bool,
    pub debug_mode: bool,
    pub namespace_errors: u8,
    pub tagprop: SymHashMap<TagFrame>,
}

Fields§

§schema: Option<Relaxng>§schema_data: Option<Vec<SymStr>>§schema_class: SymHashMap<FxHashSet<SymStr>>§code_namespace_prefixes: SymHashMap<SymStr>§code_namespaces: SymHashMap<SymStr>§document_namespace_prefixes: SymHashMap<SymStr>§document_namespaces: SymHashMap<SymStr>§permissive: bool§no_compiled: bool§debug_mode: bool§namespace_errors: u8§tagprop: SymHashMap<TagFrame>

Implementations§

Source§

impl Model

Source

pub fn new() -> Self

Source

pub fn register_namespace( &mut self, codeprefix: &str, namespace_opt: Option<&str>, )


Namespaces


There are TWO namespace mappings!!! One for coding, one for the document output.

Coding: this namespace mapping associates prefixes to namespace URIs for use in the latexml code, constructors and such. This must be a one to one mapping and there are no default namespaces. Document: this namespace mapping associates prefixes to namespace URIs as used in the generated document, and will be the set of prefixes used in the generated output. This mapping may also use a prefix of “#default” which is for the unprefixed form of elements (not used for attributes!)

Source

pub fn register_namespace_sym( &mut self, codeprefix: SymStr, namespace_opt: Option<SymStr>, )

Source

pub fn register_document_namespace( &mut self, docprefix: &str, namespace_opt: Option<&str>, )

Register a prefix in the DOCUMENT mapping — the second of the two mappings described on Model::register_namespace above.

An empty docprefix is the #default entry, i.e. the unprefixed form of elements (never attributes). None for the namespace unbinds the prefix.

Source

pub fn set_relaxng_schema(&mut self, schema: &str)

Source

pub fn load_compiled_schema(&mut self, path: &str)

TODO: This is another component that would fit perfectly as a compiler plugin. For now, simply reimplementing the runtime loading of LaTeXML.model as-is from Model.pm

Source

pub fn load_compiled_schema_str(&mut self, content: &str, source: &str)

Same as Self::load_compiled_schema but consumes an already- loaded .model body. source is used purely for diagnostic messages (the note_begin/note_end envelope and the malformed-line panic). Avoids the disk read when the model is served from the binary’s own embedded RelaxNG table.

Source

pub fn add_tag_content(&mut self, tag: &str, elements: Vec<&str>)

Source

pub fn add_tag_attribute(&mut self, tag: &str, attributes: Vec<&str>)

Source

pub fn set_schema_class(&mut self, classname: &str, content: HashSet<SymStr>)

Source

pub fn dump_compiled_schema(&self) -> String

Serialise the loaded schema into the .model plain-text format emitted by Perl LaTeXML::Common::Model::compileSchema (Model.pm L121-136). Three kinds of lines, all newline-separated:

  • prefix=namespace for every entry in document_namespaces (sorted by prefix).
  • classname:=(elt1,elt2,...) for every entry in schema_class (sorted by classname; each element list sorted).
  • tag{attr1,attr2}(child1,child2) for every entry in tagprop (sorted by tag; attrs and children sorted; tags whose name starts with ! are skipped — they are content-model-only negations).

Output is identical to the Perl tool so a downstream tools/compileschema.sh can diff Rust vs. Perl-generated LaTeXML.model files byte-for-byte (modulo schema content).

Source

pub fn describe_model(&self)

Trait Implementations§

Source§

impl Debug for Model

Source§

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

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

impl Default for Model

Source§

fn default() -> Model

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

Auto Trait Implementations§

§

impl Freeze for Model

§

impl RefUnwindSafe for Model

§

impl Send for Model

§

impl Sync for Model

§

impl Unpin for Model

§

impl UnsafeUnpin for Model

§

impl UnwindSafe for Model

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, 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.