Rename the crate, binary, core crate, font families, env vars, and internal commands from texcraft/tex-engine to texrra. Serve the separately versioned texrra-web frontend from TEXRRA_WEB_DIR, ../web, or ./web instead of embedding index.html. Add starred section heading support and an arXiv template conformance fixture.
98 lines
2.9 KiB
Rust
98 lines
2.9 KiB
Rust
/// Explicit math-style command encountered in a TeX math list.
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
|
pub enum MathStyleCommand {
|
|
Display,
|
|
Text,
|
|
Script,
|
|
ScriptScript,
|
|
}
|
|
|
|
/// TeX's eight math styles, including the cramped variants.
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
|
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
|
pub enum MathStyle {
|
|
Display,
|
|
DisplayCramped,
|
|
Text,
|
|
TextCramped,
|
|
Script,
|
|
ScriptCramped,
|
|
ScriptScript,
|
|
ScriptScriptCramped,
|
|
}
|
|
|
|
impl MathStyle {
|
|
pub fn from_command(command: MathStyleCommand) -> Self {
|
|
match command {
|
|
MathStyleCommand::Display => Self::Display,
|
|
MathStyleCommand::Text => Self::Text,
|
|
MathStyleCommand::Script => Self::Script,
|
|
MathStyleCommand::ScriptScript => Self::ScriptScript,
|
|
}
|
|
}
|
|
|
|
pub fn cramped(self) -> Self {
|
|
match self {
|
|
Self::Display | Self::DisplayCramped => Self::DisplayCramped,
|
|
Self::Text | Self::TextCramped => Self::TextCramped,
|
|
Self::Script | Self::ScriptCramped => Self::ScriptCramped,
|
|
Self::ScriptScript | Self::ScriptScriptCramped => Self::ScriptScriptCramped,
|
|
}
|
|
}
|
|
|
|
pub fn numerator_child(self) -> Self {
|
|
match self {
|
|
Self::Display => Self::Text,
|
|
Self::DisplayCramped => Self::TextCramped,
|
|
Self::Text => Self::Script,
|
|
Self::TextCramped => Self::ScriptCramped,
|
|
Self::Script => Self::ScriptScript,
|
|
Self::ScriptCramped => Self::ScriptScriptCramped,
|
|
Self::ScriptScript | Self::ScriptScriptCramped => self,
|
|
}
|
|
}
|
|
|
|
pub fn denominator_child(self) -> Self {
|
|
self.numerator_child().cramped()
|
|
}
|
|
|
|
pub fn superscript_child(self) -> Self {
|
|
match self {
|
|
Self::Display | Self::Text => Self::Script,
|
|
Self::DisplayCramped | Self::TextCramped => Self::ScriptCramped,
|
|
Self::Script | Self::ScriptScript => Self::ScriptScript,
|
|
Self::ScriptCramped | Self::ScriptScriptCramped => Self::ScriptScriptCramped,
|
|
}
|
|
}
|
|
|
|
pub fn subscript_child(self) -> Self {
|
|
self.superscript_child().cramped()
|
|
}
|
|
|
|
pub fn is_cramped(self) -> bool {
|
|
matches!(
|
|
self,
|
|
Self::DisplayCramped
|
|
| Self::TextCramped
|
|
| Self::ScriptCramped
|
|
| Self::ScriptScriptCramped
|
|
)
|
|
}
|
|
|
|
pub fn is_display(self) -> bool {
|
|
matches!(self, Self::Display | Self::DisplayCramped)
|
|
}
|
|
|
|
pub fn is_text_size(self) -> bool {
|
|
matches!(
|
|
self,
|
|
Self::Display | Self::DisplayCramped | Self::Text | Self::TextCramped
|
|
)
|
|
}
|
|
|
|
pub fn conditional_math_spacing(self) -> bool {
|
|
self.is_text_size()
|
|
}
|
|
}
|