@nteract/markdown
Advanced tools
Comparing version 3.0.1 to 3.0.3-alpha.0
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/objectSpread")); | ||
var _react = _interopRequireDefault(require("react")); | ||
var _reactMarkdown = _interopRequireDefault(require("react-markdown")); | ||
var _mathjax = _interopRequireDefault(require("@nteract/mathjax")); | ||
var _remarkMath = _interopRequireDefault(require("./remark-math")); | ||
var math = function math(props) { | ||
return _react.default.createElement(_mathjax.default.Node, null, props.value); | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
var inlineMath = function inlineMath(props) { | ||
return _react.default.createElement(_mathjax.default.Node, { | ||
inline: true | ||
}, props.value); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
var MarkdownRender = function MarkdownRender(props) { | ||
var newProps = (0, _objectSpread2.default)({}, props, { | ||
escapeHtml: false, | ||
plugins: [_remarkMath.default], | ||
renderers: (0, _objectSpread2.default)({}, props.renderers, { | ||
math: math, | ||
inlineMath: inlineMath | ||
}) | ||
}); | ||
return _react.default.createElement(_reactMarkdown.default, newProps); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const react_1 = __importDefault(require("react")); | ||
const react_markdown_1 = __importDefault(require("react-markdown")); | ||
const MathJax = __importStar(require("@nteract/mathjax")); | ||
const remark_math_1 = __importDefault(require("./remark-math")); | ||
const math = (props) => (react_1.default.createElement(MathJax.Node, null, props.value)); | ||
const inlineMath = (props) => (react_1.default.createElement(MathJax.Node, { inline: true }, props.value)); | ||
const MarkdownRender = (props) => { | ||
const newProps = Object.assign({}, props, { escapeHtml: false, plugins: [remark_math_1.default], renderers: Object.assign({}, props.renderers, { math, | ||
inlineMath }) }); | ||
return react_1.default.createElement(react_markdown_1.default, Object.assign({}, newProps)); | ||
}; | ||
var _default = MarkdownRender; | ||
exports.default = _default; | ||
exports.default = MarkdownRender; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.blockPlugin = blockPlugin; | ||
exports.default = void 0; | ||
var _trimTrailingLines = _interopRequireDefault(require("trim-trailing-lines")); | ||
var C_NEWLINE = "\n"; | ||
var C_TAB = "\t"; | ||
var C_SPACE = " "; | ||
var C_DOLLAR = "$"; | ||
var MIN_FENCE_COUNT = 2; | ||
var CODE_INDENT_COUNT = 4; // eslint-disable-next-line no-unused-vars | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const trim_trailing_lines_1 = __importDefault(require("trim-trailing-lines")); | ||
const C_NEWLINE = "\n"; | ||
const C_TAB = "\t"; | ||
const C_SPACE = " "; | ||
const C_DOLLAR = "$"; | ||
const MIN_FENCE_COUNT = 2; | ||
const CODE_INDENT_COUNT = 4; | ||
// eslint-disable-next-line no-unused-vars | ||
function blockPlugin(opts) { | ||
function blockTokenizer(eat, value, silent) { | ||
var length = value.length + 1; | ||
var index = 0; | ||
var subvalue = ""; | ||
var fenceCount; | ||
var marker; | ||
var character; | ||
var queue; | ||
var content; | ||
var exdentedContent; | ||
var closing; | ||
var exdentedClosing; | ||
var indent; | ||
var now; | ||
/* Eat initial spacing. */ | ||
while (index < length) { | ||
character = value.charAt(index); | ||
if (character !== C_SPACE && character !== C_TAB) { | ||
break; | ||
} | ||
subvalue += character; | ||
index++; | ||
} | ||
indent = index; | ||
/* Eat the fence. */ | ||
character = value.charAt(index); | ||
if (character !== C_DOLLAR) { | ||
return; | ||
} | ||
index++; | ||
marker = character; | ||
fenceCount = 1; | ||
subvalue += character; | ||
while (index < length) { | ||
character = value.charAt(index); | ||
if (character !== marker) { | ||
break; | ||
} | ||
subvalue += character; | ||
fenceCount++; | ||
index++; | ||
} | ||
if (fenceCount < MIN_FENCE_COUNT) { | ||
return; | ||
} | ||
/* Eat everything after the fence. */ | ||
while (index < length) { | ||
character = value.charAt(index); | ||
if (character === C_NEWLINE) { | ||
break; | ||
} | ||
if (character === C_DOLLAR) { | ||
return; | ||
} | ||
subvalue += character; | ||
index++; | ||
} | ||
character = value.charAt(index); | ||
if (silent) { | ||
return true; | ||
} | ||
now = eat.now(); | ||
now.column += subvalue.length; | ||
now.offset += subvalue.length; | ||
queue = closing = exdentedClosing = content = exdentedContent = ""; | ||
/* Eat content. */ | ||
while (index < length) { | ||
character = value.charAt(index); | ||
content += closing; | ||
exdentedContent += exdentedClosing; | ||
closing = exdentedClosing = ""; | ||
if (character !== C_NEWLINE) { | ||
content += character; | ||
exdentedClosing += character; | ||
index++; | ||
continue; | ||
} | ||
/* Add the newline to `subvalue` if its the first | ||
* character. Otherwise, add it to the `closing` | ||
* queue. */ | ||
if (content) { | ||
closing += character; | ||
exdentedClosing += character; | ||
} else { | ||
subvalue += character; | ||
} | ||
queue = ""; | ||
index++; | ||
while (index < length) { | ||
function blockTokenizer(eat, value, silent) { | ||
const length = value.length + 1; | ||
let index = 0; | ||
let subvalue = ""; | ||
let character; | ||
/* Eat initial spacing. */ | ||
while (index < length) { | ||
character = value.charAt(index); | ||
if (character !== C_SPACE && character !== C_TAB) { | ||
break; | ||
} | ||
subvalue += character; | ||
index++; | ||
} | ||
const indent = index; | ||
/* Eat the fence. */ | ||
character = value.charAt(index); | ||
if (character !== C_SPACE) { | ||
break; | ||
if (character !== C_DOLLAR) { | ||
return; | ||
} | ||
queue += character; | ||
index++; | ||
} | ||
closing += queue; | ||
exdentedClosing += queue.slice(indent); | ||
if (queue.length >= CODE_INDENT_COUNT) { | ||
continue; | ||
} | ||
queue = ""; | ||
while (index < length) { | ||
character = value.charAt(index); | ||
if (character !== marker) { | ||
break; | ||
let marker = character; | ||
let fenceCount = 1; | ||
subvalue += character; | ||
while (index < length) { | ||
character = value.charAt(index); | ||
if (character !== marker) { | ||
break; | ||
} | ||
subvalue += character; | ||
fenceCount++; | ||
index++; | ||
} | ||
queue += character; | ||
index++; | ||
} | ||
closing += queue; | ||
exdentedClosing += queue; | ||
if (queue.length < fenceCount) { | ||
continue; | ||
} | ||
queue = ""; | ||
while (index < length) { | ||
if (fenceCount < MIN_FENCE_COUNT) { | ||
return; | ||
} | ||
/* Eat everything after the fence. */ | ||
while (index < length) { | ||
character = value.charAt(index); | ||
if (character === C_NEWLINE) { | ||
break; | ||
} | ||
if (character === C_DOLLAR) { | ||
return; | ||
} | ||
subvalue += character; | ||
index++; | ||
} | ||
character = value.charAt(index); | ||
if (character === C_NEWLINE) { | ||
break; | ||
if (silent) { | ||
return true; | ||
} | ||
closing += character; | ||
exdentedClosing += character; | ||
index++; | ||
} | ||
break; | ||
const now = eat.now(); | ||
now.column += subvalue.length; | ||
now.offset += subvalue.length; | ||
let closing = ""; | ||
let exdentedClosing = ""; | ||
let content = ""; | ||
let exdentedContent = ""; | ||
/* Eat content. */ | ||
while (index < length) { | ||
character = value.charAt(index); | ||
content += closing; | ||
exdentedContent += exdentedClosing; | ||
closing = exdentedClosing = ""; | ||
if (character !== C_NEWLINE) { | ||
content += character; | ||
exdentedClosing += character; | ||
index++; | ||
continue; | ||
} | ||
/* Add the newline to `subvalue` if its the first | ||
* character. Otherwise, add it to the `closing` | ||
* queue. */ | ||
if (content) { | ||
closing += character; | ||
exdentedClosing += character; | ||
} | ||
else { | ||
subvalue += character; | ||
} | ||
let queue = ""; | ||
index++; | ||
while (index < length) { | ||
character = value.charAt(index); | ||
if (character !== C_SPACE) { | ||
break; | ||
} | ||
queue += character; | ||
index++; | ||
} | ||
closing += queue; | ||
exdentedClosing += queue.slice(indent); | ||
if (queue.length >= CODE_INDENT_COUNT) { | ||
continue; | ||
} | ||
queue = ""; | ||
while (index < length) { | ||
character = value.charAt(index); | ||
if (character !== marker) { | ||
break; | ||
} | ||
queue += character; | ||
index++; | ||
} | ||
closing += queue; | ||
exdentedClosing += queue; | ||
if (queue.length < fenceCount) { | ||
continue; | ||
} | ||
queue = ""; | ||
while (index < length) { | ||
character = value.charAt(index); | ||
if (character === C_NEWLINE) { | ||
break; | ||
} | ||
closing += character; | ||
exdentedClosing += character; | ||
index++; | ||
} | ||
break; | ||
} | ||
subvalue += content + closing; | ||
const trimmedContent = trim_trailing_lines_1.default(exdentedContent); | ||
return eat(subvalue)({ | ||
type: "math", | ||
value: trimmedContent, | ||
data: { | ||
hName: "div", | ||
hProperties: { | ||
className: "math" | ||
}, | ||
hChildren: [ | ||
{ | ||
type: "text", | ||
value: trimmedContent | ||
} | ||
] | ||
} | ||
}); | ||
} | ||
subvalue += content + closing; | ||
var trimmedContent = (0, _trimTrailingLines.default)(exdentedContent); | ||
return eat(subvalue)({ | ||
type: "math", | ||
value: trimmedContent, | ||
data: { | ||
hName: "div", | ||
hProperties: { | ||
className: "math" | ||
}, | ||
hChildren: [{ | ||
type: "text", | ||
value: trimmedContent | ||
}] | ||
} | ||
}); | ||
} | ||
var Parser = this.Parser; // Inject blockTokenizer | ||
var blockTokenizers = Parser.prototype.blockTokenizers; | ||
var blockMethods = Parser.prototype.blockMethods; | ||
blockTokenizers.math = blockTokenizer; | ||
blockMethods.splice(blockMethods.indexOf("fencedCode") + 1, 0, "math"); // Inject math to interrupt rules | ||
var interruptParagraph = Parser.prototype.interruptParagraph; | ||
var interruptList = Parser.prototype.interruptList; | ||
var interruptBlockquote = Parser.prototype.interruptBlockquote; | ||
interruptParagraph.splice(interruptParagraph.indexOf("fencedCode") + 1, 0, ["math"]); | ||
interruptList.splice(interruptList.indexOf("fencedCode") + 1, 0, ["math"]); | ||
interruptBlockquote.splice(interruptBlockquote.indexOf("fencedCode") + 1, 0, ["math"]); | ||
var Compiler = this.Compiler; // Stringify for math block | ||
if (Compiler != null) { | ||
var visitors = Compiler.prototype.visitors; | ||
visitors.math = function (node) { | ||
return "$$\n" + node.value + "\n$$"; | ||
}; | ||
} | ||
const Parser = this.Parser; | ||
// Inject blockTokenizer | ||
const blockTokenizers = Parser.prototype.blockTokenizers; | ||
const blockMethods = Parser.prototype.blockMethods; | ||
blockTokenizers.math = blockTokenizer; | ||
blockMethods.splice(blockMethods.indexOf("fencedCode") + 1, 0, "math"); | ||
// Inject math to interrupt rules | ||
const interruptParagraph = Parser.prototype.interruptParagraph; | ||
const interruptList = Parser.prototype.interruptList; | ||
const interruptBlockquote = Parser.prototype.interruptBlockquote; | ||
interruptParagraph.splice(interruptParagraph.indexOf("fencedCode") + 1, 0, [ | ||
"math" | ||
]); | ||
interruptList.splice(interruptList.indexOf("fencedCode") + 1, 0, ["math"]); | ||
interruptBlockquote.splice(interruptBlockquote.indexOf("fencedCode") + 1, 0, [ | ||
"math" | ||
]); | ||
const Compiler = this.Compiler; | ||
// Stringify for math block | ||
if (Compiler != null) { | ||
const visitors = Compiler.prototype.visitors; | ||
visitors.math = function (node) { | ||
return "$$\n" + node.value + "\n$$"; | ||
}; | ||
} | ||
} | ||
var _default = blockPlugin; | ||
exports.default = _default; | ||
exports.blockPlugin = blockPlugin; | ||
exports.default = blockPlugin; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const inline_1 = __importDefault(require("./inline")); | ||
const block_1 = __importDefault(require("./block")); | ||
function mathPlugin(opts = {}) { | ||
block_1.default.call(this, opts); | ||
inline_1.default.call(this, opts); | ||
} | ||
exports.mathPlugin = mathPlugin; | ||
exports.default = void 0; | ||
var _inline = _interopRequireDefault(require("./inline.js")); | ||
var _block = _interopRequireDefault(require("./block.js")); | ||
function mathPlugin() { | ||
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
_block.default.call(this, opts); | ||
_inline.default.call(this, opts); | ||
} | ||
var _default = mathPlugin; | ||
exports.default = _default; | ||
exports.default = mathPlugin; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.inlinePlugin = inlinePlugin; | ||
exports.default = void 0; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function locator(value, fromIndex) { | ||
return value.indexOf("$", fromIndex); | ||
return value.indexOf("$", fromIndex); | ||
} | ||
var ESCAPED_INLINE_MATH = /^\\\$/; | ||
var INLINE_MATH = /^\$((?:\\\$|[^$])+)\$/; | ||
var INLINE_MATH_DOUBLE = /^\$\$((?:\\\$|[^$])+)\$\$/; // eslint-disable-next-line no-unused-vars | ||
const ESCAPED_INLINE_MATH = /^\\\$/; | ||
const INLINE_MATH = /^\$((?:\\\$|[^$])+)\$/; | ||
const INLINE_MATH_DOUBLE = /^\$\$((?:\\\$|[^$])+)\$\$/; | ||
// eslint-disable-next-line no-unused-vars | ||
function inlinePlugin(opts) { | ||
function inlineTokenizer(eat, value, silent) { | ||
var isDouble = true; | ||
var match = INLINE_MATH_DOUBLE.exec(value); | ||
if (!match) { | ||
match = INLINE_MATH.exec(value); | ||
isDouble = false; | ||
function inlineTokenizer(eat, value, silent) { | ||
let isDouble = true; | ||
let match = INLINE_MATH_DOUBLE.exec(value); | ||
if (!match) { | ||
match = INLINE_MATH.exec(value); | ||
isDouble = false; | ||
} | ||
const escaped = ESCAPED_INLINE_MATH.exec(value); | ||
if (escaped) { | ||
/* istanbul ignore if - never used (yet) */ | ||
if (silent) { | ||
return true; | ||
} | ||
return eat(escaped[0])({ | ||
type: "text", | ||
value: "$" | ||
}); | ||
} | ||
if (value.slice(-2) === "\\$") { | ||
return eat(value)({ | ||
type: "text", | ||
value: value.slice(0, -2) + "$" | ||
}); | ||
} | ||
if (match) { | ||
/* istanbul ignore if - never used (yet) */ | ||
if (silent) { | ||
return true; | ||
} | ||
const endingDollarInBackticks = match[0].includes("`") && value.slice(match[0].length).includes("`"); | ||
if (endingDollarInBackticks) { | ||
const toEat = value.slice(0, value.indexOf("`")); | ||
return eat(toEat)({ | ||
type: "text", | ||
value: toEat | ||
}); | ||
} | ||
const trimmedContent = match[1].trim(); | ||
if (isDouble) { | ||
return eat(match[0])({ | ||
type: "math", | ||
value: trimmedContent, | ||
data: { | ||
hName: "div", | ||
hProperties: { | ||
className: "math" | ||
}, | ||
hChildren: [ | ||
{ | ||
type: "text", | ||
value: trimmedContent | ||
} | ||
] | ||
} | ||
}); | ||
} | ||
return eat(match[0])({ | ||
type: "inlineMath", | ||
value: trimmedContent, | ||
data: { | ||
hName: "span", | ||
hProperties: { | ||
className: "inlineMath" | ||
}, | ||
hChildren: [ | ||
{ | ||
type: "text", | ||
value: trimmedContent | ||
} | ||
] | ||
} | ||
}); | ||
} | ||
} | ||
var escaped = ESCAPED_INLINE_MATH.exec(value); | ||
if (escaped) { | ||
/* istanbul ignore if - never used (yet) */ | ||
if (silent) { | ||
return true; | ||
} | ||
return eat(escaped[0])({ | ||
type: "text", | ||
value: "$" | ||
}); | ||
inlineTokenizer.locator = locator; | ||
const Parser = this.Parser; | ||
// Inject inlineTokenizer | ||
const inlineTokenizers = Parser.prototype.inlineTokenizers; | ||
const inlineMethods = Parser.prototype.inlineMethods; | ||
inlineTokenizers.math = inlineTokenizer; | ||
inlineMethods.splice(inlineMethods.indexOf("text"), 0, "math"); | ||
const Compiler = this.Compiler; | ||
// Stringify for math inline | ||
if (Compiler != null) { | ||
const visitors = Compiler.prototype.visitors; | ||
visitors.inlineMath = function (node) { | ||
return "$" + node.value + "$"; | ||
}; | ||
} | ||
if (value.slice(-2) === "\\$") { | ||
return eat(value)({ | ||
type: "text", | ||
value: value.slice(0, -2) + "$" | ||
}); | ||
} | ||
if (match) { | ||
/* istanbul ignore if - never used (yet) */ | ||
if (silent) { | ||
return true; | ||
} | ||
var endingDollarInBackticks = match[0].includes("`") && value.slice(match[0].length).includes("`"); | ||
if (endingDollarInBackticks) { | ||
var toEat = value.slice(0, value.indexOf("`")); | ||
return eat(toEat)({ | ||
type: "text", | ||
value: toEat | ||
}); | ||
} | ||
var trimmedContent = match[1].trim(); | ||
if (isDouble) { | ||
return eat(match[0])({ | ||
type: "math", | ||
value: trimmedContent, | ||
data: { | ||
hName: "div", | ||
hProperties: { | ||
className: "math" | ||
}, | ||
hChildren: [{ | ||
type: "text", | ||
value: trimmedContent | ||
}] | ||
} | ||
}); | ||
} | ||
return eat(match[0])({ | ||
type: "inlineMath", | ||
value: trimmedContent, | ||
data: { | ||
hName: "span", | ||
hProperties: { | ||
className: "inlineMath" | ||
}, | ||
hChildren: [{ | ||
type: "text", | ||
value: trimmedContent | ||
}] | ||
} | ||
}); | ||
} | ||
} | ||
inlineTokenizer.locator = locator; | ||
var Parser = this.Parser; // Inject inlineTokenizer | ||
var inlineTokenizers = Parser.prototype.inlineTokenizers; | ||
var inlineMethods = Parser.prototype.inlineMethods; | ||
inlineTokenizers.math = inlineTokenizer; | ||
inlineMethods.splice(inlineMethods.indexOf("text"), 0, "math"); | ||
var Compiler = this.Compiler; // Stringify for math inline | ||
if (Compiler != null) { | ||
var visitors = Compiler.prototype.visitors; | ||
visitors.inlineMath = function (node) { | ||
return "$" + node.value + "$"; | ||
}; | ||
} | ||
} | ||
var _default = inlinePlugin; | ||
exports.default = _default; | ||
exports.inlinePlugin = inlinePlugin; | ||
exports.default = inlinePlugin; |
{ | ||
"name": "@nteract/markdown", | ||
"version": "3.0.1", | ||
"version": "3.0.3-alpha.0", | ||
"description": "Markdown/MathJax renderer for nteract", | ||
"main": "lib/index.js", | ||
"nteractDesktop": "src/index.js", | ||
"types": "lib/index.d.ts", | ||
"nteractDesktop": "src/index.ts", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"prepare": "npm run build", | ||
"prepublishOnly": "npm run build && npm run build:flow", | ||
"build": "npm run build:clean && npm run build:lib", | ||
"build:clean": "rimraf lib", | ||
"build:flow": "flow-copy-source -v -i '**/__tests__/**' src lib", | ||
"build:lib": "babel -d lib src --ignore '**/__tests__/**' --config-file ../../babel.config.js", | ||
"build:lib:watch": "npm run build:lib -- --watch", | ||
"build:watch": "npm run build:clean && npm run build:lib:watch && npm run build:flow" | ||
}, | ||
"scripts": {}, | ||
"repository": "https://github.com/nteract/nteract/tree/master/packages/markdown", | ||
@@ -28,8 +20,6 @@ "keywords": [ | ||
"dependencies": { | ||
"@babel/runtime-corejs2": "^7.0.0", | ||
"@nteract/mathjax": "^3.0.1", | ||
"babel-runtime": "^6.26.0", | ||
"@nteract/mathjax": "^3.0.3-alpha.0", | ||
"react-markdown": "^4.0.0" | ||
}, | ||
"gitHead": "e4bdb34c3c0402b67e32c6f224f793558157977d" | ||
"gitHead": "9ef8b723c581862d5c56b7ffd62a21393e7d83b9" | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
42036
2
20
942
0
42
2
1
+ Added@nteract/mathjax@3.0.3-alpha.0(transitive)
- Removed@babel/runtime-corejs2@^7.0.0
- Removedbabel-runtime@^6.26.0
- Removed@babel/runtime-corejs2@7.26.9(transitive)
- Removed@nteract/mathjax@3.0.1(transitive)
- Removedbabel-runtime@6.26.0(transitive)
- Removedcore-js@2.6.12(transitive)
- Removedregenerator-runtime@0.11.10.14.1(transitive)