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
impl Model
pub fn new() -> Self
Sourcepub fn register_namespace(
&mut self,
codeprefix: &str,
namespace_opt: Option<&str>,
)
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!)
pub fn register_namespace_sym( &mut self, codeprefix: SymStr, namespace_opt: Option<SymStr>, )
Sourcepub fn register_document_namespace(
&mut self,
docprefix: &str,
namespace_opt: Option<&str>,
)
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.
pub fn set_relaxng_schema(&mut self, schema: &str)
Sourcepub fn load_compiled_schema(&mut self, path: &str)
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
Sourcepub fn load_compiled_schema_str(&mut self, content: &str, source: &str)
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.
pub fn add_tag_content(&mut self, tag: &str, elements: Vec<&str>)
pub fn add_tag_attribute(&mut self, tag: &str, attributes: Vec<&str>)
pub fn set_schema_class(&mut self, classname: &str, content: HashSet<SymStr>)
Sourcepub fn dump_compiled_schema(&self) -> String
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=namespacefor every entry indocument_namespaces(sorted by prefix).classname:=(elt1,elt2,...)for every entry inschema_class(sorted by classname; each element list sorted).tag{attr1,attr2}(child1,child2)for every entry intagprop(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).