@paperist/remark-math
Advanced tools
Comparing version 1.0.3 to 2.0.0
@@ -1,13 +0,11 @@ | ||
import { UNIST } from 'unist'; | ||
import * as mdast from 'mdast'; | ||
declare module 'mdast' { | ||
namespace MDAST { | ||
interface Math extends UNIST.Text { | ||
type: 'math'; | ||
math: string; | ||
} | ||
interface InlineMath extends UNIST.Text { | ||
type: 'inlineMath'; | ||
math: string; | ||
} | ||
interface Math extends mdast.Literal { | ||
type: 'math'; | ||
math: string; | ||
} | ||
interface InlineMath extends mdast.Literal { | ||
type: 'inlineMath'; | ||
math: string; | ||
} | ||
} |
import './definitions'; | ||
import * as RemarkParse from 'remark-parse'; | ||
import RemarkParse from 'remark-parse'; | ||
import transformer from './transformer'; | ||
declare function attacher(this: RemarkParse): typeof transformer; | ||
declare function attacher(this: RemarkParse.Parse): typeof transformer; | ||
export = attacher; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
require("./definitions"); | ||
const MathTokenizer_1 = require("./MathTokenizer"); | ||
const InlineMathTokenizer_1 = require("./InlineMathTokenizer"); | ||
const transformer_1 = require("./transformer"); | ||
var MathTokenizer_1 = __importDefault(require("./MathTokenizer")); | ||
var InlineMathTokenizer_1 = __importDefault(require("./InlineMathTokenizer")); | ||
var transformer_1 = __importDefault(require("./transformer")); | ||
function attacher() { | ||
const Parser = this.Parser; | ||
const blockTokenizers = Parser.prototype.blockTokenizers; | ||
const blockMethods = Parser.prototype.blockMethods; | ||
var Parser = this.Parser; | ||
var blockTokenizers = Parser.prototype.blockTokenizers; | ||
var blockMethods = Parser.prototype.blockMethods; | ||
blockTokenizers['math'] = MathTokenizer_1.default; | ||
blockMethods.splice(blockMethods.indexOf('paragraph'), 0, 'math'); | ||
const inlineTokenizers = Parser.prototype.inlineTokenizers; | ||
const inlineMethods = Parser.prototype.inlineMethods; | ||
var inlineTokenizers = Parser.prototype.inlineTokenizers; | ||
var inlineMethods = Parser.prototype.inlineMethods; | ||
inlineTokenizers['inlineMath'] = InlineMathTokenizer_1.default; | ||
@@ -15,0 +18,0 @@ inlineMethods.splice(inlineMethods.indexOf('escape'), 0, 'inlineMath'); |
@@ -1,3 +0,3 @@ | ||
import * as RemarkParse from 'remark-parse'; | ||
import RemarkParse from 'remark-parse'; | ||
declare const InlineMathTokenizer: RemarkParse.Tokenizer; | ||
export default InlineMathTokenizer; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const inlineMath_1 = require("./peg/inlineMath"); | ||
const InlineMathLocator = (value, fromIndex) => { | ||
let location = value.indexOf('$', fromIndex); | ||
var inlineMath_1 = require("./peg/inlineMath"); | ||
var InlineMathLocator = function (value, fromIndex) { | ||
var location = value.indexOf('$', fromIndex); | ||
if (location === -1) { | ||
@@ -11,4 +11,4 @@ location = value.indexOf('\\(', fromIndex); | ||
}; | ||
const InlineMathTokenizerFunction = (eat, value, silent) => { | ||
let result; | ||
var InlineMathTokenizerFunction = function (eat, value, silent) { | ||
var result; | ||
try { | ||
@@ -23,4 +23,4 @@ result = inlineMath_1.parse(value); | ||
} | ||
const matchStr = value.substring(result.location.start.offset, result.location.end.offset); | ||
const node = { | ||
var matchStr = value.substring(result.location.start.offset, result.location.end.offset); | ||
var node = { | ||
type: 'inlineMath', | ||
@@ -32,3 +32,3 @@ value: matchStr, | ||
}; | ||
const InlineMathTokenizer = Object.assign(InlineMathTokenizerFunction, { | ||
var InlineMathTokenizer = Object.assign(InlineMathTokenizerFunction, { | ||
locator: InlineMathLocator, | ||
@@ -35,0 +35,0 @@ notInBlock: true, |
@@ -1,3 +0,3 @@ | ||
import * as RemarkParse from 'remark-parse'; | ||
declare const MathTokenizer: RemarkParse.Tokenizer; | ||
import RemarkParse from 'remark-parse'; | ||
declare const MathTokenizer: (eat: RemarkParse.Eat, value: string, silent?: boolean | undefined) => boolean | import("unist").Node | undefined; | ||
export default MathTokenizer; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const math_1 = require("./peg/math"); | ||
const MathTokenizer = (eat, value, silent) => { | ||
let result; | ||
var math_1 = require("./peg/math"); | ||
var MathTokenizer = function (eat, value, silent) { | ||
var result; | ||
try { | ||
@@ -15,4 +15,4 @@ result = math_1.parse(value); | ||
} | ||
const matchStr = value.substring(result.location.start.offset, result.location.end.offset); | ||
const node = { | ||
var matchStr = value.substring(result.location.start.offset, result.location.end.offset); | ||
var node = { | ||
type: 'math', | ||
@@ -19,0 +19,0 @@ value: matchStr, |
@@ -1,2 +0,2 @@ | ||
import { UNIST } from 'unist'; | ||
export default function transformer(_tree: UNIST.Node, _vfile: any): void; | ||
import * as unist from 'unist'; | ||
export default function transformer(_tree: unist.Node, _vfile: any): void; |
{ | ||
"name": "@paperist/remark-math", | ||
"description": "wooorm/remark plugin for math likes LaTeX / MathJax", | ||
"license": "MIT", | ||
"author": "3846masa <3846masahiro+git@gmail.com>", | ||
"license": "MIT", | ||
"homepage": "https://github.com/Paperist/remark-math#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Paperist/remark-math.git" | ||
}, | ||
"repository": "git+https://github.com/Paperist/remark-math.git", | ||
"bugs": { | ||
"url": "https://github.com/Paperist/remark-math/issues" | ||
}, | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"main": "lib/index.js", | ||
@@ -19,11 +16,6 @@ "files": [ | ||
], | ||
"directories": { | ||
"lib": "lib" | ||
}, | ||
"scripts": { | ||
"prebuild": "npm-run-all prebuild:clean prebuild:mkdir", | ||
"prebuild": "npm-run-all clean prebuild:mkdir", | ||
"build": "npm-run-all -p build:*", | ||
"postbuild": "npm-run-all -p postbuild:*", | ||
"prebuild:clean": "npm run clean", | ||
"postbuild:copy-d.ts": "cpx \"src/**/*.d.ts\" lib", | ||
"prebuild:mkdir": "mkdirp lib/peg", | ||
@@ -35,23 +27,19 @@ "build:peg": "npm-run-all -p build:peg:*", | ||
"clean": "rimraf lib", | ||
"precommit": "lint-staged" | ||
"test": "exit 0" | ||
}, | ||
"dependencies": {}, | ||
"peerDependencies": { | ||
"remark-parse": "^4.0.0" | ||
"types": "lib/index.d.ts", | ||
"dependencies": { | ||
"@types/mdast": "^3.0.2", | ||
"@types/unist": "^2.0.3", | ||
"remark-parse": "^7.0.0" | ||
}, | ||
"devDependencies": { | ||
"@paperist/types-remark": "^0.1.1", | ||
"@types/node": "^8.0.19", | ||
"@types/pegjs": "^0.10.0", | ||
"cpx": "^1.5.0", | ||
"husky": "^0.14.3", | ||
"lint-staged": "^4.0.2", | ||
"@types/node": "^12.6.8", | ||
"@types/pegjs": "^0.10.1", | ||
"mkdirp": "^0.5.1", | ||
"npm-run-all": "^4.0.2", | ||
"npm-run-all": "^4.1.5", | ||
"pegjs": "^0.10.0", | ||
"prettier-package-json": "^1.4.0", | ||
"remark-parse": "^4.0.0", | ||
"rimraf": "^2.6.1", | ||
"typescript": "^2.4.2", | ||
"unified": "^6.1.5" | ||
"rimraf": "^2.6.3", | ||
"typescript": "^3.5.3", | ||
"unified": "^8.3.2" | ||
}, | ||
@@ -63,10 +51,3 @@ "keywords": [ | ||
"remark" | ||
], | ||
"lint-staged": { | ||
"package.json": [ | ||
"prettier-package-json --write", | ||
"git add" | ||
] | ||
}, | ||
"types": "lib/index.d.ts" | ||
] | ||
} |
@@ -10,21 +10,26 @@ # @paperist/remark-math | ||
[standard-readme]: https://github.com/RichardLitt/standard-readme | ||
[npm-badge]: https://flat.badgen.net/npm/v/@paperist/remark-math | ||
[license-badge]: https://flat.badgen.net/badge/license/MIT/blue | ||
[standard-readme-badge]: https://flat.badgen.net/badge/standard-readme/OK/green | ||
[npm-badge]: https://img.shields.io/npm/v/@paperist/remark-math.svg?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACBVGfHAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAbUExURcwAAOeIiP////G7u/ri4tIZGdpFReJsbPC3t075sZwAAAAvSURBVCjPY2CgDWAThIMEsACjEhwIUCZg0dGCIqASwMAxMgXAgSzOwMAOC2TqAwBvzR4JxLaP0gAAAABJRU5ErkJggg== | ||
[license-badge]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAIGNIUk0AAHomAACAhAAA%2BgAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAVUExURSBTICJcIiNgIiZoJTuhNyt3Kf///%2BCqxSgAAAAGdFJOUwpclbn%2B4Fj6/H8AAAABYktHRAZhZrh9AAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4AkEEjEV7MDQQwAAAGBJREFUCNc1TUEKgDAMi07vE/Q%2BRD8g%2B4BbvAvi/79iMjDQJm1CC6BbDzRsZI3incIpYeYFhCaYnLiyPYnYkwWZFWoFHrSuttCmmbwXh0eJQYVON4JthZTxCzzAmyb8%2BAAKXBRyN6RyZQAAAABJRU5ErkJggg== | ||
[standard-readme-badge]: https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square | ||
> [wooorm/remark] plugin for math likes [KaTeX] / [MathJax] | ||
[wooorm/remark]: https://github.com/wooorm/remark | ||
[KaTeX]: https://khan.github.io/KaTeX/ | ||
[MathJax]: https://www.mathjax.org/ | ||
[katex]: https://khan.github.io/KaTeX/ | ||
[mathjax]: https://www.mathjax.org/ | ||
## Table of Contents | ||
<!-- TOC depthFrom:2 depthTo:3 updateOnSave:false --> | ||
- [Install](#install) | ||
- [Usage](#usage) | ||
- [AST](#ast) | ||
- [`Math`](#math) | ||
- [`InlineMath`](#inlinemath) | ||
- [Contribute](#contribute) | ||
- [License](#license) | ||
<!-- /TOC --> | ||
## Install | ||
@@ -55,6 +60,8 @@ | ||
const processor = unified().use(parser).use(math); | ||
const processor = unified() | ||
.use(parser) | ||
.use(math); | ||
const ast = processor.parse(markdown); | ||
processor.run(ast).then(ast => { | ||
processor.run(ast).then((ast) => { | ||
console.dir(ast, { depth: null }); | ||
@@ -73,6 +80,6 @@ }); | ||
`Math` extends [`Text`][unist-text]. | ||
`Math` extends [`Literal`][unist-literal]. | ||
```typescript | ||
interface Math extends Text { | ||
interface Math extends Literal { | ||
type: 'math'; | ||
@@ -103,6 +110,6 @@ math: string; | ||
`InlineMath` extends [`Text`][unist-text]. | ||
`InlineMath` extends [`Literal`][unist-literal]. | ||
```typescript | ||
interface InlineMath extends Text { | ||
interface InlineMath extends Literal { | ||
type: 'inlineMath'; | ||
@@ -129,3 +136,3 @@ math: string; | ||
[unist-text]: https://github.com/syntax-tree/unist#text | ||
[unist-literal]: https://github.com/syntax-tree/unist#literal | ||
@@ -138,4 +145,2 @@ ## Contribute | ||
![3846masa] MIT (c) 3846masa | ||
[3846masa]: https://www.gravatar.com/avatar/cfeae69aae4f4fc102960f01d35d2d86?s=50 | ||
[MIT (c) 3846masa](https://3846masa.mit-license.org) |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
8
141
45621
3
3
15
1442
1
1
+ Added@types/mdast@^3.0.2
+ Added@types/unist@^2.0.3
+ Addedremark-parse@^7.0.0
+ Added@types/mdast@3.0.15(transitive)
+ Added@types/unist@2.0.11(transitive)
+ Addedremark-parse@7.0.2(transitive)
- Removedremark-parse@4.0.0(transitive)