Skip to content

Commit

Permalink
more opts
Browse files Browse the repository at this point in the history
  • Loading branch information
xu-cheng committed Feb 1, 2020
1 parent d14a920 commit d73352b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,19 @@ pub struct Opts {
/// Color used for invalid LaTeX.
error_color: Option<String>,
/// Collection of custom macros.
/// Read <https://katex.org/docs/options.html> for more information.
macros: HashMap<String, String>,
/// Specifies a minimum thickness, in ems.
/// Read <https://katex.org/docs/options.html> for more information.
min_rule_thickness: Option<f64>,
/// Max size for user-specified sizes.
/// If set to `None`, users can make elements and spaces arbitrarily large.
/// Read <https://katex.org/docs/options.html> for more information.
max_size: Option<Option<f64>>,
/// Limit the number of macro expansions to the specified number.
/// If set to `None`, the macro expander will try to fully expand as in LaTeX.
/// Read <https://katex.org/docs/options.html> for more information.
max_expand: Option<Option<i32>>,
}

impl Opts {
Expand Down Expand Up @@ -132,6 +141,21 @@ impl Into<JsValue> for Opts {
if let Some(min_rule_thickness) = self.min_rule_thickness {
opt.insert("minRuleThickness".to_owned(), min_rule_thickness.into());
}
if let Some(max_size) = self.max_size {
if let Some(max_size) = max_size {
opt.insert("maxSize".to_owned(), max_size.into());
}
}
if let Some(max_expand) = self.max_expand {
match max_expand {
Some(max_expand) => {
opt.insert("maxExpand".to_owned(), max_expand.into());
}
None => {
opt.insert("maxExpand".to_owned(), i32::max_value().into());
}
}
}
JsValue::Object(opt)
}
}
Expand Down

0 comments on commit d73352b

Please sign in to comment.