From a69f4173fe3ca9484e3098494db5b1ffd44f66b1 Mon Sep 17 00:00:00 2001 From: Trivernis Date: Sat, 3 Aug 2019 13:32:39 +0200 Subject: [PATCH] Local MathJax - changed mathjax to local installation --- package-lock.json | 9 ++++++++- package.json | 5 ++--- src/index.ts | 1 + src/lib/utils.ts | 6 ++++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index cbbc577..a4ae85b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -65,7 +65,8 @@ "@types/node": { "version": "12.6.8", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.6.8.tgz", - "integrity": "sha512-aX+gFgA5GHcDi89KG5keey2zf0WfZk/HAQotEamsK2kbey+8yGKcson0hbK8E+v0NArlCJQCqMP161YhV6ZXLg==" + "integrity": "sha512-aX+gFgA5GHcDi89KG5keey2zf0WfZk/HAQotEamsK2kbey+8yGKcson0hbK8E+v0NArlCJQCqMP161YhV6ZXLg==", + "dev": true }, "@types/node-fetch": { "version": "2.5.0", @@ -80,6 +81,7 @@ "version": "1.19.0", "resolved": "https://registry.npmjs.org/@types/puppeteer/-/puppeteer-1.19.0.tgz", "integrity": "sha512-Db9LWOuTm2bR/qgPE7PQCmnsCQ6flHdULuIDWTks8YdQ/SGHKg5WGWG54gl0734NDKCTF5MbqAp2qWuvBiyQ3Q==", + "dev": true, "requires": { "@types/node": "*" } @@ -3597,6 +3599,11 @@ "resolve-dir": "^1.0.0" } }, + "mathjax": { + "version": "2.7.5", + "resolved": "https://registry.npmjs.org/mathjax/-/mathjax-2.7.5.tgz", + "integrity": "sha512-OzsJNitEHAJB3y4IIlPCAvS0yoXwYjlo2Y4kmm9KQzyIBZt2d8yKRalby3uTRNN4fZQiGL2iMXjpdP1u2Rq2DQ==" + }, "mdurl": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", diff --git a/package.json b/package.json index 243bdce..dbe40da 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "@types/node": "^12.6.8", "@types/node-fetch": "^2.5.0", "@types/winston": "^2.4.4", + "@types/puppeteer": "^1.19.0", "delete": "^1.1.0", "gulp": "^4.0.2", "gulp-clean-css": "^4.2.0", @@ -27,13 +28,11 @@ "typescript": "^3.5.3" }, "dependencies": { - "@types/puppeteer": "^1.19.0", "argparse": "^1.0.10", "chokidar": "^3.0.2", "date-format": "^2.1.0", "fs-extra": "^8.1.0", "jsdom": "^15.1.1", - "line-by-line": "^0.1.6", "markdown-it": "^9.0.1", "markdown-it-abbr": "^1.0.4", "markdown-it-anchor": "^5.2.4", @@ -52,7 +51,6 @@ "markdown-it-kbd": "^2.0.0", "markdown-it-mark": "^2.0.0", "markdown-it-math": "^4.1.1", - "markdown-it-mathjax": "^2.0.0", "markdown-it-modify-token": "^1.0.2", "markdown-it-multimd-table": "^3.2.2", "markdown-it-plantuml": "^1.4.1", @@ -62,6 +60,7 @@ "markdown-it-toc-done-right": "^4.0.2", "markdown-it-underline": "^1.0.1", "markdown-it-video": "^0.6.3", + "mathjax": "^2.7.5", "node-fetch": "^2.6.0", "puppeteer": "^1.19.0", "uninstall": "0.0.0", diff --git a/src/index.ts b/src/index.ts index b09b722..0c783c8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,4 @@ +#!/usr/bin/env node import {Renderer} from "./lib/Renderer"; import {writeFile} from 'fs-extra'; import {extname, dirname} from 'path'; diff --git a/src/lib/utils.ts b/src/lib/utils.ts index c053b96..328fed4 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -5,7 +5,8 @@ import fetch from "node-fetch"; import {logger} from "./logger"; import {markdownPlugins} from "./plugins"; -const mathJaxUrl = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML'; +const mathJaxPath: string = __dirname + '../../../node_modules/mathjax/MathJax.js'; +const mathJaxConfig: string = '?config=MML_HTMLorMML'; /** * Bundles all images in the image tags. @@ -48,7 +49,8 @@ export async function bundleImages(dom: JSDOM, mainfile: string): Promise export function includeMathJax(dom: JSDOM): JSDOM { let document = dom.window.document; let scriptTag = document.createElement('script'); - scriptTag.src = mathJaxUrl; + scriptTag.src = mathJaxPath + mathJaxConfig; + scriptTag.type = 'text/javascript'; document.head.appendChild(scriptTag); return dom; }