1234567891011121314151617181920212223242526272829303132333435 |
- const parse = require('./katex.min')
- function Latex () {
- }
- Latex.prototype.onParse = function (node, vm) {
-
- if (!vm.options.editable && node.type === 'text' && /\$(.+?)\$/.test(node.text)) {
- delete node.type
- node.name = 'span'
- node.attrs = {}
- node.children = node.text.split('$').map((str, index) => {
-
- if ((index + 1) % 2 === 0) {
- return {
- name: 'span',
- attrs: {},
- children: parse.default(str)
- }
- }
- return {
- type: 'text',
- text: str
- }
- })
- delete node.text
- }
- }
- module.exports = Latex
|