New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

markdown-it-mathjax3

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-it-mathjax3 - npm Package Compare versions

Comparing version 3.0.0-0 to 3.0.0

56

index.js

@@ -1,2 +0,1 @@

"use strict";
/* Process inline math */

@@ -10,17 +9,20 @@ /*

*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const mathjax_1 = require("mathjax-full/js/mathjax");
const tex_1 = require("mathjax-full/js/input/tex");
const svg_1 = require("mathjax-full/js/output/svg");
const liteAdaptor_1 = require("mathjax-full/js/adaptors/liteAdaptor");
const html_1 = require("mathjax-full/js/handlers/html");
const AllPackages_1 = require("mathjax-full/js/input/tex/AllPackages");
const juice_1 = __importDefault(require("juice"));
const adaptor = (0, liteAdaptor_1.liteAdaptor)();
(0, html_1.RegisterHTMLHandler)(adaptor);
const tex = new tex_1.TeX({ packages: AllPackages_1.AllPackages });
const svg = new svg_1.SVG({ fontCache: "none" });
const mathDocument = mathjax_1.mathjax.document("", { InputJax: tex, OutputJax: svg });
import { mathjax } from "mathjax-full/js/mathjax.js";
import { TeX } from "mathjax-full/js/input/tex.js";
import { SVG } from "mathjax-full/js/output/svg.js";
import { liteAdaptor } from "mathjax-full/js/adaptors/liteAdaptor.js";
import { RegisterHTMLHandler } from "mathjax-full/js/handlers/html.js";
import { AllPackages } from "mathjax-full/js/input/tex/AllPackages.js";
import { rehype } from "rehype";
import inlineCss from "rehype-inline-css";
function renderMath(content, options) {
const adaptor = liteAdaptor();
RegisterHTMLHandler(adaptor);
const tex = new TeX({ packages: AllPackages });
const svg = new SVG({ fontCache: "none" });
const mathDocument = mathjax.document(content, { InputJax: tex, OutputJax: svg });
const html = adaptor.outerHTML(mathDocument.convert(content, options));
const stylesheet = adaptor.outerHTML(svg.styleSheet(mathDocument));
return rehype().use(inlineCss).processSync(html + stylesheet).toString();
}
// Test if potential opening or closing delimieter

@@ -157,3 +159,3 @@ // Assumes that there is a "$" at state.src[pos]

}
module.exports = function (md, options) {
export default function (md, options) {
// Default options

@@ -168,21 +170,9 @@ options = options || {};

options.display = false;
return adaptor.outerHTML(mathDocument.convert(tokens[idx].content, options));
return renderMath(tokens[idx].content, options);
};
md.renderer.rules.math_block = function (tokens, idx) {
options.display = true;
return adaptor.outerHTML(mathDocument.convert(tokens[idx].content, options));
return renderMath(tokens[idx].content, options);
};
const render = md.renderer.render.bind(md.renderer);
md.renderer.render = function (tokens, options, env) {
const result = render(tokens, options, env);
const noMath = tokens.every(function isNotMath(token) {
return (token.tag !== "math" &&
(Array.isArray(token.children) ? token.children.every(isNotMath) : true));
});
if (!noMath) {
const styleSheet = adaptor.textContent(svg.styleSheet(mathDocument));
return (0, juice_1.default)(`${result}<style>${styleSheet}</style>`);
}
return result;
};
};
}
;
{
"name": "markdown-it-mathjax3",
"version": "3.0.0-0",
"version": "3.0.0",
"type": "module",
"description": "Fast math support for markdown-it with MathJax",

@@ -21,4 +22,5 @@ "main": "index.js",

"dependencies": {
"juice": "^8.0.0",
"mathjax-full": "^3.2.0"
"mathjax-full": "^3.2.0",
"rehype": "^12.0.0",
"rehype-inline-css": "^0.5.1"
},

@@ -25,0 +27,0 @@ "devDependencies": {

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