Gathering detailed insights and metrics for @dongivan/mathjax-vuewer
Gathering detailed insights and metrics for @dongivan/mathjax-vuewer
Gathering detailed insights and metrics for @dongivan/mathjax-vuewer
Gathering detailed insights and metrics for @dongivan/mathjax-vuewer
A Vue component which could render MathML / LaTeX codes by MathJax.
npm install @dongivan/mathjax-vuewer
Typescript
Module System
Node Version
NPM Version
48.3
Supply Chain
90.7
Quality
75.4
Maintenance
100
Vulnerability
100
License
TypeScript (49.51%)
Vue (45.93%)
HTML (4.55%)
Total Downloads
368
Last Day
2
Last Week
2
Last Month
3
Last Year
153
6 Commits
1 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
0.1.2
Package Id
@dongivan/mathjax-vuewer@0.1.2
Unpacked Size
21.42 kB
Size
7.19 kB
File Count
9
NPM Version
8.7.0
Node Version
16.13.0
Cumulative downloads
Total Downloads
Last day
0%
2
Compared to previous day
Last week
0%
2
Compared to previous week
Last month
-70%
3
Compared to previous month
Last year
16.8%
153
Compared to previous year
1
5
A Vue component which could render MathML / LaTeX codes by MathJax.
Based on Vue 3.2 & MathJax 3.
formular uses this component to render expressions. You can see more details if you visit the link on a wide enough screen (width more than 540px).
npm install @dongivan/mathjax-vuewer --save
Firstly, register the component as a Vue plugin.
import MathJaxVuewer from "@dongivan/mathjax-vuewer"
import { createApp } from "vue";
const app = createApp(...);
app.use(MathJaxVuewer, {
componentName: ...,
script: ...,
options: ...,
})
Then, use it in your template.
<template>
<MathJaxVuewer :content="content" source-format="tex" target-format="html" />
</template>
Key | Type | Default | Description |
---|---|---|---|
componentName | string | "MathJaxVuewer" | The component name used in template |
script | string | undefined | The url of MathJax script. If it is not set, you should load mathjax script by yourself (use <script> for example). |
options | Object | undefined | The options needed by MathJax when it initializes. If it is not set, you should write the config object(window.MathJax ) to initialize the MathJax. |
Prop | Type | Default | Description |
---|---|---|---|
content | string | required | The source content of expression. If you want to use a MathMLElement tree as content, you should render the MathMLElement tree as string first(use ele.outerHTML for example). |
source-format | "mml" | "mathml" | "latex" | "tex" | "tex" | The source format of expression. "mml" and "mathml" both mean using MathMLElement; "latex" and "tex" both mean using LaTex |
target-format | "html" | "chtml" | "svg" | "chtml" | The target format of expression. "html" and "chtml" both mean that the result will be rendered as html, and "svg" means that the result will be SVG. |
display | boolean | false | display will be used when MathJax renders the content while source-format is set to "tex"(or "latex"). The result would be a inline element if display == false , or a block element if display == true . When source-format is set to "mml"(or "mathml"), this prop will not be used (You should set an attribute named display and valued block of the root node of the MathMLElement tree if you want MathJax to render it as a block element). |
Event | Description |
---|---|
math-jax-loaded | The component will detect whether the MathJax is loaded and emit this event after that. And the component WILL NOT render the content before this event emitted. |
MathJax is designed for render the whole page, and it will read the global variable window.MathJax
and modify it when initializing. MathJaxVuewer will inject a ready()
function (see here) into the window.MathJax.startup
in order to know whether MathJax is ready, and this must be done before MathJax read window.MathJax
.
That means, if you load MathJax manually (which means you leave script
and options
of the plugin option to undefined
), things would be complicated: MathJax may read and modify window.MathJax
before the ready()
function is injected. In this situation, the component will test whether window.MathJax.config
exists -- and emit "math-jax-loaded" if it does. However, even window.MathJax.config
was set, the MathJax may not be ready at once, and the component may throw an error because it cannot find the render function like tex2svgPromise()
before MathJax initialized.
You should load all MathJax components which used by MathJaxVuewer in the window.MathJax
options (or plugin option). For example, you have two MathJaxVuewer components, one is used to render LaTeX to html, and the other renders MathMLElement to SVG, then you should have an options like this:
{
loader: {
load: ["input/tex-base", "input/mml", "output/chtml", "output/svg", "[tex]/html"],
},
tex: {
packages: {
"[+]": ["base"],
},
},
startup: {
output: ["chtml", "svg"],
},
}
Becareful, the options.startup.output
is important. Please set it correctly, or the component may throw an error that it cannot find the render function.
No vulnerabilities found.
No security vulnerabilities found.