@paperist/remark-mathjax
Advanced tools
Comparing version 0.0.1 to 0.1.0
@@ -27,3 +27,3 @@ /** | ||
*/ | ||
declare function attacher(remark: any): void; | ||
declare function attacher(this: any, ...args: any[]): void; | ||
export default attacher; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* Static | ||
*/ | ||
const C_NEWLINE = '\n'; | ||
const C_SPACE = '\x20'; | ||
const C_TAB = '\t'; | ||
const C_ESCAPE = '\\'; | ||
const C_DOLLAR = '$'; | ||
const C_OPEN_BRACKET = '['; | ||
const C_CLOSE_BRACKET = ']'; | ||
const C_OPEN_PARENTHESIS = '('; | ||
const C_CLOSE_PARENTHESIS = ')'; | ||
var C_NEWLINE = '\n'; | ||
var C_SPACE = '\x20'; | ||
var C_TAB = '\t'; | ||
var C_ESCAPE = '\\'; | ||
var C_DOLLAR = '$'; | ||
var C_OPEN_BRACKET = '['; | ||
var C_CLOSE_BRACKET = ']'; | ||
var C_OPEN_PARENTHESIS = '('; | ||
var C_CLOSE_PARENTHESIS = ')'; | ||
/** | ||
@@ -21,8 +22,9 @@ * Tokenise a cross-ref label. | ||
*/ | ||
function tokenizeBlockMathjax(eat, value, silent = false) { | ||
const length = value.length; | ||
let content = ''; | ||
let mathjax = ''; | ||
let char = ''; | ||
let idx = 0; | ||
function tokenizeBlockMathjax(eat, value, silent) { | ||
if (silent === void 0) { silent = false; } | ||
var length = value.length; | ||
var content = ''; | ||
var mathjax = ''; | ||
var char = ''; | ||
var idx = 0; | ||
for (; idx < length; idx++) { | ||
@@ -35,3 +37,3 @@ char = value.charAt(idx); | ||
} | ||
const wrapType = (char === C_DOLLAR) ? C_DOLLAR : (char === C_ESCAPE) ? C_OPEN_BRACKET : ''; | ||
var wrapType = (char === C_DOLLAR) ? C_DOLLAR : (char === C_ESCAPE) ? C_OPEN_BRACKET : ''; | ||
if (!wrapType) { | ||
@@ -49,5 +51,5 @@ return; | ||
if (wrapType === C_DOLLAR && char === C_DOLLAR) { | ||
const char = value.charAt(++idx); | ||
if (char === C_DOLLAR) { | ||
content += char; | ||
var char_1 = value.charAt(++idx); | ||
if (char_1 === C_DOLLAR) { | ||
content += char_1; | ||
break; | ||
@@ -79,3 +81,3 @@ } | ||
value: content, | ||
mathjax, | ||
mathjax: mathjax, | ||
}); | ||
@@ -90,10 +92,11 @@ } | ||
*/ | ||
function tokenizeInlineMathjax(eat, value, silent = false) { | ||
const length = value.length; | ||
let content = ''; | ||
let mathjax = ''; | ||
let char = ''; | ||
let idx = 0; | ||
function tokenizeInlineMathjax(eat, value, silent) { | ||
if (silent === void 0) { silent = false; } | ||
var length = value.length; | ||
var content = ''; | ||
var mathjax = ''; | ||
var char = ''; | ||
var idx = 0; | ||
char = value.charAt(idx++); | ||
const wrapType = (char === C_DOLLAR) ? C_DOLLAR : | ||
var wrapType = (char === C_DOLLAR) ? C_DOLLAR : | ||
(char === C_ESCAPE) ? C_OPEN_PARENTHESIS : ''; | ||
@@ -140,3 +143,3 @@ if (!wrapType) { | ||
value: content, | ||
mathjax, | ||
mathjax: mathjax, | ||
}); | ||
@@ -153,3 +156,3 @@ } | ||
function locateInlineMathjax(value, fromIndex) { | ||
let idx = value.indexOf('$', fromIndex); | ||
var idx = value.indexOf('$', fromIndex); | ||
if (idx === -1) { | ||
@@ -164,6 +167,19 @@ idx = value.indexOf('\\(', fromIndex); | ||
*/ | ||
function attacher(remark) { | ||
const proto = remark.Parser.prototype; | ||
const blockMethods = proto.blockMethods; | ||
const inlineMethods = proto.inlineMethods; | ||
function attacher() { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
var remark; | ||
if (args[0] && args[0].Parser && args[0].Compiler) { | ||
// remark < v7.x | ||
remark = args[0]; | ||
} | ||
else { | ||
// remark >= v7.x | ||
remark = this; | ||
} | ||
var proto = remark.Parser.prototype; | ||
var blockMethods = proto.blockMethods; | ||
var inlineMethods = proto.inlineMethods; | ||
/** | ||
@@ -178,3 +194,5 @@ * Add a tokenizer to the `Parser`. | ||
} | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* Expose. | ||
*/ | ||
exports.default = attacher; |
{ | ||
"name": "@paperist/remark-mathjax", | ||
"description": "wooorm/remark plugin for mathjax", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@types/node": "^6.0.48", | ||
"ava": "^0.17.0", | ||
"npm-run-all": "^3.1.1", | ||
"rimraf": "^2.5.4", | ||
"ava": "^0.18.1", | ||
"greenkeeper-postpublish": "^1.0.1", | ||
"npm-run-all": "^4.0.2", | ||
"rimraf": "^2.6.1", | ||
"typescript": "^2.0.10" | ||
@@ -34,4 +35,5 @@ }, | ||
"test:build": "cd ./test && tsc", | ||
"test:ava": "ava" | ||
"test:ava": "ava", | ||
"postpublish": "greenkeeper-postpublish" | ||
} | ||
} |
10050
219
6