Socket
Socket
Sign inDemoInstall

rehype-mathjax

Package Overview
Dependencies
Maintainers
3
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rehype-mathjax - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

browser.js

47

index.js

@@ -1,46 +0,1 @@

const visit = require('unist-util-visit')
const unified = require('unified')
const parse = require('rehype-parse')
const toText = require('hast-util-to-text')
module.exports = rehypeMathjax
const assign = Object.assign
const parseHtml = unified().use(parse, {fragment: true, position: false})
const source = 'rehype-mathjax'
function rehypeMathjax(options) {
const opts = options || {}
const throwOnError = opts.throwOnError || false
return transformMath
function transformMath(tree, file) {
visit(tree, 'element', onelement)
function onelement(element) {
const classes = element.properties.className || []
const inline = classes.includes('math-inline')
const displayMode = classes.includes('math-display')
if (!inline && !displayMode) {
return
}
const value = toText(element)
let result = value
if (inline) {
result = `$` + result + `$`;
}
if (displayMode) {
result = `$$` + result + `$$`;
}
element.children = parseHtml.parse(result).children
}
}
}
module.exports = require('./svg')
{
"name": "rehype-mathjax",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"version": "2.0.0",
"description": "rehype plugin to transform inline and block math with MathJax",
"license": "MIT",
"keywords": [
"unified",
"remark",
"rehype",
"rehype-plugin",
"plugin",
"mdast",
"markdown",
"hast",
"html",
"math",
"mathjax",
"latex",
"tex"
],
"repository": "https://github.com/remarkjs/remark-math/tree/master/packages/rehype-mathjax",
"bugs": "https://github.com/remarkjs/remark-math/issues",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Ir1d/rehype-mathjax.git"
"browser": {
"./lib/adaptor.js": "./lib/adaptor.browser.js"
},
"author": "Ir1d",
"license": "MIT",
"bugs": {
"url": "https://github.com/Ir1d/rehype-mathjax/issues"
"author": "TANIGUCHI Masaya <mew@cat.ovh> (https://docs.casa)",
"contributors": [
"TANIGUCHI Masaya <mew@cat.ovh> (https://docs.casa)",
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
],
"files": [
"lib/",
"browser.js",
"chtml.js",
"svg.js",
"index.js"
],
"main": "index.js",
"dependencies": {
"hast-util-from-dom": "^2.0.0",
"hast-util-to-text": "^2.0.0",
"jsdom": "^16.0.0",
"mathjax-full": "^3.0.0",
"unist-util-visit": "^2.0.0"
},
"homepage": "https://github.com/Ir1d/rehype-mathjax#readme"
"devDependencies": {},
"xo": false
}
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