Since the OptsBuilder takes ownership of the macros hashmap, the hashmap needs to be cloned every time a new equation is rendered.
I think it is a common use case to render multiple equations with the same set of macros / with the same opts. Wouldn't it be more convenient / faster to pass the macros as a &HashMap reference?
Or, maybe even better, to pass an &Opts reference to render_with_ops?
Right now I have to clone macros and create a new Opts object every time I render a new equation. It looks like this
for item in items_to_render {
let cloned_macros = macros.clone();
let ops = katex::Opts::builder()
.display_mode(display)
.output_type(katex::OutputType::Html)
.macros(cloned_macros)
.build()
.unwrap();
let result = katex::render_with_opts(&item, ops);
...
}
Which could be replaced by
let ops = katex::Opts::builder()
.display_mode(display)
.output_type(katex::OutputType::Html)
.macros(macros)
.build()
.unwrap();
for item in items_to_render {
let result = katex::render_with_opts(&item, &ops);
...
}
Hello,
Since the
OptsBuilder
takes ownership of themacros
hashmap, the hashmap needs to be cloned every time a new equation is rendered.I think it is a common use case to render multiple equations with the same set of macros / with the same opts. Wouldn't it be more convenient / faster to pass the macros as a
&HashMap
reference?Or, maybe even better, to pass an
&Opts
reference torender_with_ops
?Right now I have to clone
macros
and create a newOpts
object every time I render a new equation. It looks like thisWhich could be replaced by
Let me know if I'm missing something!