Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
3846masa committed Jul 21, 2019
1 parent 433b6cd commit 6babd9c
Show file tree
Hide file tree
Showing 8 changed files with 476 additions and 1,603 deletions.
52 changes: 16 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
{
"name": "@paperist/remark-math",
"description": "wooorm/remark plugin for math likes LaTeX / MathJax",
"author": "3846masa <[email protected]>",
"license": "MIT",
"author": "3846masa <[email protected]>",
"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"
},
Expand All @@ -16,54 +13,37 @@
"files": [
"lib"
],
"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",
"build:peg": "npm-run-all -p build:peg:*",
"build:peg:inlineMath": "pegjs -o ./lib/peg/inlineMath.js ./src/peg/inlineMath.pegjs",
"build:peg:math": "pegjs -o ./lib/peg/math.js ./src/peg/math.pegjs",
"build:tsc": "tsc",
"clean": "rimraf lib",
"precommit": "lint-staged"
"clean": "rimraf lib"
},
"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"
},
"keywords": [
"katex",
"markdown",
"mathjax",
"remark"
],
"lint-staged": {
"package.json": [
"prettier-package-json --write",
"git add"
]
},
"types": "lib/index.d.ts"
]
}
32 changes: 11 additions & 21 deletions src/InlineMathTokenizer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MDAST } from 'mdast';
import * as RemarkParse from 'remark-parse';
import * as mdast from 'mdast';
import RemarkParse from 'remark-parse';

import { parse, ParseResult } from './peg/inlineMath';

Expand All @@ -11,11 +11,7 @@ const InlineMathLocator: RemarkParse.Locator = (value, fromIndex) => {
return location;
};

const InlineMathTokenizerFunction: RemarkParse.TokenizerFunction = (
eat,
value,
silent
) => {
const InlineMathTokenizerFunction = (eat: RemarkParse.Eat, value: string, silent?: boolean) => {
let result: ParseResult;
try {
result = parse(value);
Expand All @@ -27,12 +23,9 @@ const InlineMathTokenizerFunction: RemarkParse.TokenizerFunction = (
return true;
}

const matchStr = value.substring(
result.location.start.offset,
result.location.end.offset
);
const matchStr = value.substring(result.location.start.offset, result.location.end.offset);

const node: MDAST.InlineMath = {
const node: mdast.InlineMath = {
type: 'inlineMath',
value: matchStr,
math: result.math,
Expand All @@ -41,14 +34,11 @@ const InlineMathTokenizerFunction: RemarkParse.TokenizerFunction = (
return eat(matchStr)(node);
};

const InlineMathTokenizer: RemarkParse.Tokenizer = Object.assign(
InlineMathTokenizerFunction,
{
locator: InlineMathLocator,
notInBlock: true,
notInList: true,
notInLink: true,
}
);
const InlineMathTokenizer = Object.assign(InlineMathTokenizerFunction, {
locator: InlineMathLocator,
notInBlock: true,
notInList: true,
notInLink: true,
} as Partial<RemarkParse.Tokenizer>) as RemarkParse.Tokenizer;

export default InlineMathTokenizer;
13 changes: 5 additions & 8 deletions src/MathTokenizer.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { MDAST } from 'mdast';
import * as RemarkParse from 'remark-parse';
import * as mdast from 'mdast';
import RemarkParse from 'remark-parse';

import { parse, ParseResult } from './peg/math';

const MathTokenizer: RemarkParse.Tokenizer = (eat, value, silent) => {
const MathTokenizer = (eat: RemarkParse.Eat, value: string, silent?: boolean) => {
let result: ParseResult;
try {
result = parse(value);
Expand All @@ -15,12 +15,9 @@ const MathTokenizer: RemarkParse.Tokenizer = (eat, value, silent) => {
return true;
}

const matchStr = value.substring(
result.location.start.offset,
result.location.end.offset
);
const matchStr = value.substring(result.location.start.offset, result.location.end.offset);

const node: MDAST.Math = {
const node: mdast.Math = {
type: 'math',
value: matchStr,
math: result.math,
Expand Down
18 changes: 8 additions & 10 deletions src/definitions.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { UNIST } from 'unist';
import * as mdast from 'mdast';

declare module 'mdast' {
export namespace MDAST {
interface Math extends UNIST.Text {
type: 'math';
math: string;
}
export interface Math extends mdast.Literal {
type: 'math';
math: string;
}

interface InlineMath extends UNIST.Text {
type: 'inlineMath';
math: string;
}
export interface InlineMath extends mdast.Literal {
type: 'inlineMath';
math: string;
}
}
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import './definitions';
import * as RemarkParse from 'remark-parse';
import RemarkParse from 'remark-parse';

import MathTokenizer from './MathTokenizer';
import InlineMathTokenizer from './InlineMathTokenizer';
import transformer from './transformer';

function attacher(this: RemarkParse) {
function attacher(this: RemarkParse.Parse) {
const Parser = this.Parser;

const blockTokenizers = Parser.prototype.blockTokenizers;
const blockTokenizers = (Parser.prototype as any).blockTokenizers;
const blockMethods = Parser.prototype.blockMethods;
blockTokenizers['math'] = MathTokenizer;
blockMethods.splice(blockMethods.indexOf('paragraph'), 0, 'math');
Expand Down
4 changes: 2 additions & 2 deletions src/transformer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { UNIST } from 'unist';
import * as unist from 'unist';

export default function transformer(_tree: UNIST.Node, _vfile: any) {}
export default function transformer(_tree: unist.Node, _vfile: any) {}
66 changes: 46 additions & 20 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,58 @@
{
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
// "incremental": true,
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"target": "es2017",
"lib": ["esnext"],
// "allowJs": true,
// "checkJs": true,
// "jsx": "preserve",
"declaration": true,
"lib": ["dom", "es2017"],
"types": ["node", "@paperist/types-remark"],
// "declarationMap": true,
// "sourceMap": true,
// "outFile": "./",
"outDir": "./lib",
// "rootDir": "./",
// "composite": true,
// "tsBuildInfoFile": "./",
// "removeComments": true,
// "noEmit": true,
// "importHelpers": true,
// "downlevelIteration": true,
// "isolatedModules": true,

"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"alwaysStrict": true,

"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitUseStrict": false,
"sourceMap": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"traceResolution": false,
"listFiles": false,
"stripInternal": true,
"skipDefaultLibCheck": true,
"skipLibCheck": false,
"pretty": false,
"noEmitOnError": true
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,

"moduleResolution": "node",
"baseUrl": "./src",
// "paths": {},
// "rootDirs": [],
// "typeRoots": [],
"types": ["node"],
// "allowSyntheticDefaultImports": true,
"esModuleInterop": true
// "preserveSymlinks": true,
// "allowUmdGlobalAccess": true,

// "sourceRoot": "",
// "mapRoot": "",
// "inlineSourceMap": true,
// "inlineSources": true,

// "experimentalDecorators": true,
// "emitDecoratorMetadata": true,
},
"include": ["src/**/*.ts"],
"exclude": ["lib"]
Expand Down
Loading

0 comments on commit 6babd9c

Please sign in to comment.