diff --git a/src/elements/literal.rs b/src/elements/literal.rs
index aca778d..76e81d0 100644
--- a/src/elements/literal.rs
+++ b/src/elements/literal.rs
@@ -2,7 +2,6 @@ use crate::tokens::{Arrow, FontCommand, Function, Greek, Logical, Misc, Operatio
#[derive(Debug, Clone, PartialOrd, PartialEq)]
pub enum Literal {
- Integer,
Text(PlainText),
Symbol(Symbol),
Number(Number),
diff --git a/src/format/mathml.rs b/src/format/mathml.rs
index 6f4af23..2371d51 100644
--- a/src/format/mathml.rs
+++ b/src/format/mathml.rs
@@ -1,11 +1,29 @@
-use crate::elements::literal::{Number, PlainText, Symbol};
-use crate::tokens::{Arrow, FontCommand, Function, Greek, Logical, Misc, Relation};
+use crate::elements::literal::{Literal, Number, PlainText, Symbol};
+use crate::tokens::{Arrow, FontCommand, Function, Greek, Logical, Misc, Operation, Relation};
use htmlescape::encode_minimal;
pub trait ToMathML {
fn to_mathml(&self) -> String;
}
+impl ToMathML for Literal {
+ fn to_mathml(&self) -> String {
+ match self {
+ Literal::Text(t) => t.to_mathml(),
+ Literal::Symbol(s) => s.to_mathml(),
+ Literal::Number(n) => n.to_mathml(),
+ Literal::Greek(g) => g.to_mathml(),
+ Literal::FontCommand(f) => f.to_mathml(),
+ Literal::Relation(r) => r.to_mathml(),
+ Literal::Function(f) => f.to_mathml(),
+ Literal::Logical(l) => l.to_mathml(),
+ Literal::Arrow(a) => a.to_mathml(),
+ Literal::Misc(m) => m.to_mathml(),
+ Literal::Operation(o) => o.to_mathml(),
+ }
+ }
+}
+
impl ToMathML for Greek {
fn to_mathml(&self) -> String {
let inner = match self {
@@ -234,3 +252,36 @@ impl ToMathML for Misc {
format!("{}", inner)
}
}
+
+impl ToMathML for Operation {
+ fn to_mathml(&self) -> String {
+ let inner = match self {
+ Operation::Plus => "+",
+ Operation::Minus => "−",
+ Operation::CDot => "∙",
+ Operation::Ast => "∗",
+ Operation::Star => "⋆",
+ Operation::Slash => "/",
+ Operation::Backslash => "∖",
+ Operation::Times => "×",
+ Operation::Div => "÷",
+ Operation::LTimes => "⋉",
+ Operation::RTimes => "⋊",
+ Operation::Bowtie => "⋈",
+ Operation::Circ => "∘",
+ Operation::OPlus => "⊕",
+ Operation::OTimes => "⊗",
+ Operation::ODot => "⊙",
+ Operation::Wedge => "∧",
+ Operation::BidWedge => "⋀",
+ Operation::Vee => "∨",
+ Operation::BigVee => "⋁",
+ Operation::Cap => "∩",
+ Operation::BigCap => "⋂",
+ Operation::Cup => "∪",
+ Operation::BigCup => "⋃",
+ _ => "",
+ };
+ format!("{}", inner)
+ }
+}