Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mathml2omml

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mathml2omml - npm Package Compare versions

Comparing version 0.3.3 to 0.4.0

src/parse-stringify/index.js

10

package.json
{
"name": "mathml2omml",
"version": "0.3.3",
"version": "0.4.0",
"description": "a MathML to OMML converter ",

@@ -29,3 +29,3 @@ "main": "dist/index.js",

"devDependencies": {
"@rollup/plugin-node-resolve": "^13.3.0",
"entities": "^4.3.1",
"eslint": "^8.17.0",

@@ -36,8 +36,8 @@ "eslint-config-standard": "^17.0.0",

"eslint-plugin-promise": "^6.0.0",
"jest": "^28.1.0",
"rollup": "^2.78.1",
"dom-serializer": "^2.0.0",
"htmlparser2": "^8.0.1",
"jest": "^28.1.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"rollup-plugin-terser": "^7.0.2",
"xml-formatter": "^2.6.1"
}
}

@@ -40,6 +40,8 @@ # mathml2omml

The xml parser/stringifier in the `parse-stringify`-folder is based upon [html-parse-stringify](https://github.com/henrikjoreteg/html-parse-stringify) (MIT).
License of test files depends on source of files.
Some test fixtures fall under other licenses/copyrights. See the LICENSE and copyirght.txt files in the different test fixture folders.
Some test fixtures fall under other licenses/copyrights. See the LICENSE and copyright.txt files in the different test fixture folders.
Remaining test fixtures fall under the same license and copyright as the source code.
import { nodeResolve } from '@rollup/plugin-node-resolve'
import {terser} from 'rollup-plugin-terser'

@@ -24,5 +25,6 @@ const onwarn = warning => {

plugins: [
nodeResolve()
nodeResolve(),
terser()
],
onwarn
}

@@ -1,31 +0,1 @@

export function cleanText (element, options = { text: 'remove' }) {
switch (element.name) {
case 'mi':
case 'mn':
case 'mo':
case 'ms':
case 'mtext':
options = { text: 'trim' }
break
default:
break
}
if (element.children) {
if (options.text === 'remove') {
element.children = element.children.filter(child => child.type !== 'text')
} else if (options.text === 'trim') {
element.children.forEach(child => {
if (child.type === 'text') {
child.data = child.data.trim()
}
})
}
element.children.forEach(child => {
if (child.type === 'tag') {
cleanText(child, options)
}
})
}
}
export function getTextContent (node, trim = true) {

@@ -32,0 +2,0 @@ let returnString = ''

@@ -1,5 +0,3 @@

import * as htmlparser2 from 'htmlparser2'
import render from 'dom-serializer'
import { parse, stringifyDoc } from './parse-stringify'
import { walker } from './walker.js'
import { cleanText } from './helpers.js'

@@ -9,4 +7,3 @@ class MML2OMML {

this.inString = mmlString
this.inXML = htmlparser2.parseDocument(mmlString)
cleanText(this.inXML)
this.inXML = parse(mmlString)
this.outXML = false

@@ -18,3 +15,3 @@ this.outString = false

const outXML = {}
walker(this.inXML, outXML)
walker({ children: this.inXML, type: 'root' }, outXML)
this.outXML = outXML

@@ -24,3 +21,3 @@ }

getResult () {
this.outString = render([this.outXML], { xmlMode: true, encodeEntities: false, decodeEntities: false })
this.outString = stringifyDoc([this.outXML])
return this.outString

@@ -27,0 +24,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc