Comparing version 0.1.12 to 0.2.0
677
History.md
@@ -0,33 +1,48 @@ | ||
0.2.0 / 2015-02-02 | ||
================== | ||
* Fix `mdast.js` | ||
* Merge branch 'feature/add-line-and-column-position' | ||
* Add `position` objects to nodes | ||
* Add `trimRightLines` function to `lib/utilities.js` | ||
* Add `build-usage` task to render `example.js` to `Readme.md` | ||
* Add `example.js` to lint tasks | ||
* Add `example.js` | ||
* Remove `requireMultipleVarDecl` rule from `.jscs.json` | ||
* Add `mdast`, `mdast-usage` as dev-dependencies | ||
* Fix markdown formatting in `History.md` by using `mdast` | ||
* Fix markdown formatting in `Readme.md` by using `mdast` | ||
* Fix build | ||
0.1.12 / 2015-01-26 | ||
================== | ||
=================== | ||
* Add test for throwing on errors in plug-ins | ||
* Add throwing on errors in plug-ins | ||
* Update eslint | ||
* Add test for throwing on errors in plug-ins | ||
* Add throwing on errors in plug-ins | ||
* Update eslint | ||
0.1.11 / 2015-01-25 | ||
================== | ||
=================== | ||
* Remove `backpedal` from `tokenizeBlock` in `lib/parse.js` | ||
* Merge branch 'feature/simplify-escapes' | ||
* Add support for `escape` node | ||
* Fix fixtures for new escape node | ||
* Add new `escape` node to `doc/Nodes.md` | ||
* Add test support for new `escape` node | ||
* Add docs for `--output`, `-o` CLI flags to `Readme.md` | ||
* Add `--output`, `-o` CLI flags | ||
* Add tests for `--output` CLI flag | ||
* Add docs for `mdast.use()` to `Readme.md` | ||
* Add `build.js` to `.gitignore`, `.npmignore`, `bower.json` ignore | ||
* Remove `backpedal` from `tokenizeBlock` in `lib/parse.js` | ||
* Merge branch 'feature/simplify-escapes' | ||
* Add support for `escape` node | ||
* Fix fixtures for new escape node | ||
* Add new `escape` node to `doc/Nodes.md` | ||
* Add test support for new `escape` node | ||
* Add docs for `--output`, `-o` CLI flags to `Readme.md` | ||
* Add `--output`, `-o` CLI flags | ||
* Add tests for `--output` CLI flag | ||
* Add docs for `mdast.use()` to `Readme.md` | ||
* Add `build.js` to `.gitignore`, `.npmignore`, `bower.json` ignore | ||
0.1.10 / 2015-01-24 | ||
================== | ||
=================== | ||
* Update build | ||
* Merge branch 'bug/fix-linked-image' | ||
* Add fixtures for links, images in links | ||
* Add check to inline tokenizer if a match is eaten | ||
* Add link check to nested image/links | ||
* Fix typo in `Readme.md` | ||
* Update build | ||
* Merge branch 'bug/fix-linked-image' | ||
* Add fixtures for links, images in links | ||
* Add check to inline tokenizer if a match is eaten | ||
* Add link check to nested image/links | ||
* Fix typo in `Readme.md` | ||
@@ -37,13 +52,13 @@ 0.1.9 / 2015-01-24 | ||
* Add UMD as an installation method in `Readme.md` | ||
* Add `index.js`, `lib/` to bower ignore | ||
* Remove bower dependencies due to UMD build | ||
* Add `mdast.js` to bowers `main` instead of `index.js` | ||
* Add `mdast.js`, `mdast.min.js` | ||
* Add `mdast.js`, `mdast.min.js` to `.npmignore` | ||
* Add `postbuild-bundle` npm script target to compress module | ||
* Add `bundle` npm script target to browserify module | ||
* Add esmangle as a dev-dependency | ||
* Add browserify as a dev-dependency | ||
* Fix bug in node@0.10 re require error exit code | ||
* Add UMD as an installation method in `Readme.md` | ||
* Add `index.js`, `lib/` to bower ignore | ||
* Remove bower dependencies due to UMD build | ||
* Add `mdast.js` to bowers `main` instead of `index.js` | ||
* Add `mdast.js`, `mdast.min.js` | ||
* Add `mdast.js`, `mdast.min.js` to `.npmignore` | ||
* Add `postbuild-bundle` npm script target to compress module | ||
* Add `bundle` npm script target to browserify module | ||
* Add esmangle as a dev-dependency | ||
* Add browserify as a dev-dependency | ||
* Fix bug in node@0.10 re require error exit code | ||
@@ -53,14 +68,14 @@ 0.1.8 / 2015-01-21 | ||
* Add missing `lib/utilities.js` to `component.json` | ||
* Merge branch 'feature/add-plugin-support' | ||
* Add assertions for plugins to `test/cli.sh` | ||
* Add failure on invalid plugin to cli | ||
* Add assertions for plugins to `test/index.js` | ||
* Rename `ware` internally from `parser` to `ware` | ||
* Add cli plugin usage to `Readme.md` | ||
* Add plugin support to cli | ||
* Fix plugin implementation | ||
* Add example plugin to `test/plugin.js` | ||
* Add initial draft of plugin implementation | ||
* Add ware as a dependency | ||
* Add missing `lib/utilities.js` to `component.json` | ||
* Merge branch 'feature/add-plugin-support' | ||
* Add assertions for plugins to `test/cli.sh` | ||
* Add failure on invalid plugin to cli | ||
* Add assertions for plugins to `test/index.js` | ||
* Rename `ware` internally from `parser` to `ware` | ||
* Add cli plugin usage to `Readme.md` | ||
* Add plugin support to cli | ||
* Fix plugin implementation | ||
* Add example plugin to `test/plugin.js` | ||
* Add initial draft of plugin implementation | ||
* Add ware as a dependency | ||
@@ -70,29 +85,29 @@ 0.1.7 / 2015-01-20 | ||
* Update copyright notice in `LICENSE` to include 2015 | ||
* Refactor license in `Readme.md` | ||
* Add link to whole license in `Readme.md` | ||
* Refactor fences code blocks in `Readme.md` | ||
* Update npm script targets in `package.json` | ||
* Update eslint | ||
* Fix incorrect links in documentation | ||
* Update `doc/Options.md` with footnote definitions | ||
* Merge branch 'feature/footnote-definition-node' | ||
* Update `lib/stringify.js` to compile footnote definitions | ||
* Update `lib/parse.js` to expose footnote definitions | ||
* Update `test/index.js` to validate footnote definition | ||
* Update fixtures for footnote definition | ||
* Add docs for footnote definition to `doc/Nodes.md` | ||
* Merge branch 'feature/empty-fenced-code-blocks' | ||
* Add stringification as fenced code blocks when missing value and language | ||
* Add support for missing `value` in `renderCodeBlock` | ||
* Fix expression for empty fenced code blocks | ||
* Add fixtures for empty fences code blocks | ||
* Add `options.closeAtx` to `Readme.md` | ||
* Merge branch 'feature/stringification/escape-less-dashes' | ||
* Remove extraneous escapes on invalid list bullets | ||
* Merge branch 'feature/stringification/prefer-closed-atx' | ||
* Add docs for `options.closeAtx` | ||
* Add support for `closeAtx` | ||
* Add tests for incorrect `closeAtx` options | ||
* Add fixtures for closed ATX styles | ||
* Update copyright notice in `LICENSE` to include 2015 | ||
* Refactor license in `Readme.md` | ||
* Add link to whole license in `Readme.md` | ||
* Refactor fences code blocks in `Readme.md` | ||
* Update npm script targets in `package.json` | ||
* Update eslint | ||
* Fix incorrect links in documentation | ||
* Update `doc/Options.md` with footnote definitions | ||
* Merge branch 'feature/footnote-definition-node' | ||
* Update `lib/stringify.js` to compile footnote definitions | ||
* Update `lib/parse.js` to expose footnote definitions | ||
* Update `test/index.js` to validate footnote definition | ||
* Update fixtures for footnote definition | ||
* Add docs for footnote definition to `doc/Nodes.md` | ||
* Merge branch 'feature/empty-fenced-code-blocks' | ||
* Add stringification as fenced code blocks when missing value and language | ||
* Add support for missing `value` in `renderCodeBlock` | ||
* Fix expression for empty fenced code blocks | ||
* Add fixtures for empty fences code blocks | ||
* Add `options.closeAtx` to `Readme.md` | ||
* Merge branch 'feature/stringification/escape-less-dashes' | ||
* Remove extraneous escapes on invalid list bullets | ||
* Merge branch 'feature/stringification/prefer-closed-atx' | ||
* Add docs for `options.closeAtx` | ||
* Add support for `closeAtx` | ||
* Add tests for incorrect `closeAtx` options | ||
* Add fixtures for closed ATX styles | ||
@@ -102,42 +117,42 @@ 0.1.6 / 2015-01-13 | ||
* Add missing jsdoc comments to `test/index.js` | ||
* Add custom compiler to `mdast.stringify()` | ||
* Add custom parser to `mdast.parse()` | ||
* Add test for custom compiler to `mdast.stringify()` | ||
* Add test for custom parser to `mdast.parse()` | ||
* Add exposure of `Compiler` on `mdast.stringify` | ||
* Add exposure of `Parser` on `mdast.parse` | ||
* Merge branch 'feature/add-line-and-column-position' | ||
* Add duo to install methods | ||
* Add links to install methods to `Readme.md` | ||
* Add standardised state methods | ||
* Remove description of `gfm` parse option being better at paragraphs | ||
* Add better description to `pedantic` parse option | ||
* Refactor `lib/parse.js` | ||
* Refactor `lib/parse.js` to merge `BlockLexer`, `InlineLexer`, `Parser` | ||
* Refactor to prepare `Parser` to tokenise with less context | ||
* Refactor to prepare `BlockLexer` to tokenise with less context | ||
* Refactor to construct `InlineLexer` when constructing `Parser` | ||
* Add shared lexer info to new `shared` object in `lib/parse.js` | ||
* Remove `footnote` property on `root` when `footnotes: false` | ||
* Rename `Lexer` to `BlockLexer` in `lib/parse.js` | ||
* Remove `Parser.parse` method in `lib/parse.js` | ||
* Remove `top` parameter for block-level tokenizers | ||
* Add `trimLeft` and `trimRight` to `lib/utilities` | ||
* Refactor `InlineLexer` in `lib/parse.js` | ||
* Refactor Lexer in `lib/parse.js` | ||
* Remove `footnote-` prefix from generated footnote IDs | ||
* Merge branch 'master' into feature/add-line-and-column-position | ||
* Merge branch 'feature/stringification/preferred-code-fence-style' | ||
* Remove `markdown` language tag from code-fences to fix GitHub | ||
* Add example for `options.fence` | ||
* Add support for preferred code fence markers | ||
* Fix missing comma | ||
* Add fixture for code fence markers | ||
* Add test for incorrect code fence marker | ||
* Add better handling of incorrect parse options | ||
* Add copy to stringification settings in | ||
* Move `raise` method to `lib/utilities.js` | ||
* Refactor lots of regular expressions to be simpler | ||
* Add error when stringifying unknown nodes | ||
* Add missing jsdoc comments to `test/index.js` | ||
* Add custom compiler to `mdast.stringify()` | ||
* Add custom parser to `mdast.parse()` | ||
* Add test for custom compiler to `mdast.stringify()` | ||
* Add test for custom parser to `mdast.parse()` | ||
* Add exposure of `Compiler` on `mdast.stringify` | ||
* Add exposure of `Parser` on `mdast.parse` | ||
* Merge branch 'feature/add-line-and-column-position' | ||
* Add duo to install methods | ||
* Add links to install methods to `Readme.md` | ||
* Add standardised state methods | ||
* Remove description of `gfm` parse option being better at paragraphs | ||
* Add better description to `pedantic` parse option | ||
* Refactor `lib/parse.js` | ||
* Refactor `lib/parse.js` to merge `BlockLexer`, `InlineLexer`, `Parser` | ||
* Refactor to prepare `Parser` to tokenise with less context | ||
* Refactor to prepare `BlockLexer` to tokenise with less context | ||
* Refactor to construct `InlineLexer` when constructing `Parser` | ||
* Add shared lexer info to new `shared` object in `lib/parse.js` | ||
* Remove `footnote` property on `root` when `footnotes: false` | ||
* Rename `Lexer` to `BlockLexer` in `lib/parse.js` | ||
* Remove `Parser.parse` method in `lib/parse.js` | ||
* Remove `top` parameter for block-level tokenizers | ||
* Add `trimLeft` and `trimRight` to `lib/utilities` | ||
* Refactor `InlineLexer` in `lib/parse.js` | ||
* Refactor Lexer in `lib/parse.js` | ||
* Remove `footnote-` prefix from generated footnote IDs | ||
* Merge branch 'master' into feature/add-line-and-column-position | ||
* Merge branch 'feature/stringification/preferred-code-fence-style' | ||
* Remove `markdown` language tag from code-fences to fix GitHub | ||
* Add example for `options.fence` | ||
* Add support for preferred code fence markers | ||
* Fix missing comma | ||
* Add fixture for code fence markers | ||
* Add test for incorrect code fence marker | ||
* Add better handling of incorrect parse options | ||
* Add copy to stringification settings in | ||
* Move `raise` method to `lib/utilities.js` | ||
* Refactor lots of regular expressions to be simpler | ||
* Add error when stringifying unknown nodes | ||
@@ -147,13 +162,13 @@ 0.1.5 / 2015-01-01 | ||
* Remove `cli.js` form `.npmignore` | ||
* Remove options description from `Readme.md` | ||
* Refactor API in `Readme.md` | ||
* Add build script to generate `Options.md` | ||
* Add `script/` and `doc/` to bower ignore, `.npmignore` | ||
* Add `doc/Options.md` | ||
* Add missing new-line character in `Readme.md` | ||
* Update CLI usage in `Readme.md` | ||
* Remove nodes containing information from `Readme.md` | ||
* Add `doc/Nodes.md` containing refactored AST information | ||
* Fix overflowing `logo.svg` | ||
* Remove `cli.js` form `.npmignore` | ||
* Remove options description from `Readme.md` | ||
* Refactor API in `Readme.md` | ||
* Add build script to generate `Options.md` | ||
* Add `script/` and `doc/` to bower ignore, `.npmignore` | ||
* Add `doc/Options.md` | ||
* Add missing new-line character in `Readme.md` | ||
* Update CLI usage in `Readme.md` | ||
* Remove nodes containing information from `Readme.md` | ||
* Add `doc/Nodes.md` containing refactored AST information | ||
* Fix overflowing `logo.svg` | ||
@@ -163,26 +178,26 @@ 0.1.4 / 2014-12-30 | ||
* Update benchmark results in `Readme.md` | ||
* Update stringification options in `Readme.md` to reflect changes in 3f5d136 | ||
* Rename `horizontal-rule` stringification options to `rule` | ||
* Rename `setext-headings` stringification option to `setext` | ||
* Remove `prefer` before several stirngification options | ||
* Remove multiple new lines from CLI by using stdout instead of console | ||
* Remove multiple new lines after the stringified AST | ||
* Fix bug in CLI with exit code when provided with invalid file path | ||
* Add mention of same file input output to `cli.js` | ||
* Update code example in `Readme.md` to reflect changes in a1a5a09 | ||
* Fix bug in longest-repetition at end of input | ||
* Merge branch 'feature/add-cli' | ||
* Add CLI useage to `Readme.md` | ||
* Fix typo in CLIs options | ||
* Fix typo in package description | ||
* Add test for missing input to `test/cli.sh` | ||
* Remove commented tests in `test/cli.sh` | ||
* Fix comment in CLIs help | ||
* Add `test-cli` npm script target to `package.json` | ||
* Add `test/cli.sh` | ||
* Add `lint-cli` npm script target to `package.json` | ||
* Add CLI | ||
* Add `cli.js` | ||
* Add `cli`, `bin` to package keywords | ||
* Update benchmark results in `Readme.md` | ||
* Update stringification options in `Readme.md` to reflect changes in 3f5d136 | ||
* Rename `horizontal-rule` stringification options to `rule` | ||
* Rename `setext-headings` stringification option to `setext` | ||
* Remove `prefer` before several stirngification options | ||
* Remove multiple new lines from CLI by using stdout instead of console | ||
* Remove multiple new lines after the stringified AST | ||
* Fix bug in CLI with exit code when provided with invalid file path | ||
* Add mention of same file input output to `cli.js` | ||
* Update code example in `Readme.md` to reflect changes in a1a5a09 | ||
* Fix bug in longest-repetition at end of input | ||
* Merge branch 'feature/add-cli' | ||
* Add CLI useage to `Readme.md` | ||
* Fix typo in CLIs options | ||
* Fix typo in package description | ||
* Add test for missing input to `test/cli.sh` | ||
* Remove commented tests in `test/cli.sh` | ||
* Fix comment in CLIs help | ||
* Add `test-cli` npm script target to `package.json` | ||
* Add `test/cli.sh` | ||
* Add `lint-cli` npm script target to `package.json` | ||
* Add CLI | ||
* Add `cli.js` | ||
* Add `cli`, `bin` to package keywords | ||
@@ -192,28 +207,28 @@ 0.1.3 / 2014-12-28 | ||
* Merge branch 'feature/stringification/preferred-code-block-style' | ||
* Add documentation for preferred code block-style | ||
* Add support for preferred code block-style | ||
* Add tests for incorrect code block-style options | ||
* Add fixtures preferred code block-style | ||
* Merge branch 'feature/stringification/preferred-footnote-style' | ||
* Add documentation for stringification with reference footnote options | ||
* Add support for stringification with reference footnote options | ||
* Move internal copy method over to `lib/utilities.js` | ||
* Add tests for incorrect reference footnote options | ||
* Add fixtures for stringification of inline- and reference-style footnotes | ||
* Merge branch 'bug/parse/formatting-in-nested-footnotes' | ||
* Fix a bug when nested footnotes contain formatting | ||
* Merge branch 'bug/parse/fix-generating-unique-footnote-ids' | ||
* Fix a bug when generating footnote ids | ||
* Merge branch 'feature/stringification/preferred-link-style' | ||
* Add documentation for stringification with reference link options | ||
* Add support for stringification with reference link options | ||
* Add tests for incorrect setext header options | ||
* Add tests for incorrect reference link options | ||
* Add fixtures for stringification of inline- and reference-style links | ||
* Merge branch 'feature/stringification/less-escaped-characters' | ||
* Remove escape from exclamation-marks | ||
* Remove escape from dots when not preceded by a digit | ||
* Remove superfluous escaped full-stops from fixtures | ||
* Update jscs-jsdoc | ||
* Merge branch 'feature/stringification/preferred-code-block-style' | ||
* Add documentation for preferred code block-style | ||
* Add support for preferred code block-style | ||
* Add tests for incorrect code block-style options | ||
* Add fixtures preferred code block-style | ||
* Merge branch 'feature/stringification/preferred-footnote-style' | ||
* Add documentation for stringification with reference footnote options | ||
* Add support for stringification with reference footnote options | ||
* Move internal copy method over to `lib/utilities.js` | ||
* Add tests for incorrect reference footnote options | ||
* Add fixtures for stringification of inline- and reference-style footnotes | ||
* Merge branch 'bug/parse/formatting-in-nested-footnotes' | ||
* Fix a bug when nested footnotes contain formatting | ||
* Merge branch 'bug/parse/fix-generating-unique-footnote-ids' | ||
* Fix a bug when generating footnote ids | ||
* Merge branch 'feature/stringification/preferred-link-style' | ||
* Add documentation for stringification with reference link options | ||
* Add support for stringification with reference link options | ||
* Add tests for incorrect setext header options | ||
* Add tests for incorrect reference link options | ||
* Add fixtures for stringification of inline- and reference-style links | ||
* Merge branch 'feature/stringification/less-escaped-characters' | ||
* Remove escape from exclamation-marks | ||
* Remove escape from dots when not preceded by a digit | ||
* Remove superfluous escaped full-stops from fixtures | ||
* Update jscs-jsdoc | ||
@@ -223,19 +238,19 @@ 0.1.2 / 2014-12-26 | ||
* Merge branch 'feature/stringification/emphasis-and-strong' | ||
* Add support for stringification with emphasis options | ||
* Add support for stringification with emphasis options | ||
* Add tests for incorrect emphasis options | ||
* Add fixtures for setting strong and emphasis style | ||
* Refactor table-stringification | ||
* Merge branch 'feature/add-prefered-horizontal-rule-stringification' | ||
* Add docs for `options.horizontalRule` to `Readme.md` | ||
* Add support for stringification with horizontal-rule options | ||
* Add tests for incorrect horizontal-rule options | ||
* Add fixtures for setting horizontal-rule styles | ||
* Merge branch 'feature/add-prefered-bullet-stringification' | ||
* Add docs for `options.button` to `Readme.md` | ||
* Add test for stringification with invalid bullet option | ||
* Add support for stringification with bullet options for unordered lists | ||
* Add fixtures for setting bullets for unordered lists | ||
* Add support for testing fixtures with options | ||
* Merge branch 'feature/stringification/emphasis-and-strong' | ||
* Add support for stringification with emphasis options | ||
* Add support for stringification with emphasis options | ||
* Add tests for incorrect emphasis options | ||
* Add fixtures for setting strong and emphasis style | ||
* Refactor table-stringification | ||
* Merge branch 'feature/add-prefered-horizontal-rule-stringification' | ||
* Add docs for `options.horizontalRule` to `Readme.md` | ||
* Add support for stringification with horizontal-rule options | ||
* Add tests for incorrect horizontal-rule options | ||
* Add fixtures for setting horizontal-rule styles | ||
* Merge branch 'feature/add-prefered-bullet-stringification' | ||
* Add docs for `options.button` to `Readme.md` | ||
* Add test for stringification with invalid bullet option | ||
* Add support for stringification with bullet options for unordered lists | ||
* Add fixtures for setting bullets for unordered lists | ||
* Add support for testing fixtures with options | ||
@@ -245,20 +260,20 @@ 0.1.1 / 2014-12-25 | ||
* Fix incorrect IDL in `Readme.md` | ||
* Fix incorrect link in `Readme.md` | ||
* Add proper `parse`, `stringify` docs to `Readme.md` | ||
* Add useage example for setext-heading stringification to docs | ||
* Add support for stringification to setex-style headings | ||
* Add fixtures for setex style headings | ||
* Add support for testing stringified output | ||
* Add stringification of final new-line | ||
* Remove stringification of superfluous new-lines | ||
* Refactor `lib/parse.js` to cache expressions | ||
* Refactor `test/index.js` to use constants | ||
* Refactor `lib/stringify.js` to use constants | ||
* Refactor `lib/parse.js` to use constants | ||
* Refactor to adhere to strict jsdoc style | ||
* Add jscs-jsdoc configuration to `.jscs.json` | ||
* Add jscs-jsdoc as a dev-dependency | ||
* Refactor npm scripts for changes in npm | ||
* Update markdown-table | ||
* Fix incorrect IDL in `Readme.md` | ||
* Fix incorrect link in `Readme.md` | ||
* Add proper `parse`, `stringify` docs to `Readme.md` | ||
* Add useage example for setext-heading stringification to docs | ||
* Add support for stringification to setex-style headings | ||
* Add fixtures for setex style headings | ||
* Add support for testing stringified output | ||
* Add stringification of final new-line | ||
* Remove stringification of superfluous new-lines | ||
* Refactor `lib/parse.js` to cache expressions | ||
* Refactor `test/index.js` to use constants | ||
* Refactor `lib/stringify.js` to use constants | ||
* Refactor `lib/parse.js` to use constants | ||
* Refactor to adhere to strict jsdoc style | ||
* Add jscs-jsdoc configuration to `.jscs.json` | ||
* Add jscs-jsdoc as a dev-dependency | ||
* Refactor npm scripts for changes in npm | ||
* Update markdown-table | ||
@@ -268,73 +283,73 @@ 0.1.0 / 2014-12-11 | ||
* Refactor `benchmark.js` | ||
* Update keywords, description in `package.json`, `component.json`, `bower.json` | ||
* Refactor `Readme.md` | ||
* Add badges for travis, coveralls to `Readme.md` | ||
* Add `logo.svg` | ||
* Add missing `new` operator to `lib/stringify.js` | ||
* Fix malformed `bower.json` | ||
* Fix incorrect script reference in `component.json` | ||
* Add strict mode to `index.js` | ||
* Refactor `bower.json` | ||
* Move `lib/stringify/index.js` to `lib/stringify.js` | ||
* Move `lib/parse/index.js` to `lib/parse.js` | ||
* Add npm deployment to `.travis.yml` | ||
* Remove `before_install` script in `.travis.yml` | ||
* Remove `Makefile` | ||
* Refactor `.npmignore` | ||
* Refactor `.gitignore` | ||
* Add broader version ranges to `package.json` | ||
* Update eslint | ||
* Update matcha | ||
* Update mocha | ||
* Refactor npm scripts in `package.json` | ||
* Move `test/mdast.spec.js` to `test/index.js` | ||
* Move `spec/` to `test/` | ||
* Move `benchmark/index.js` to `benchmark.js` | ||
* Refactor to disallow spaces after object keys | ||
* Add `.eslintrc` | ||
* Fix spacing around inline-code containing backticks | ||
* Refactor to simplify `spec/mdast.spec.js` | ||
* Add benchmark for `mdast.stringify` | ||
* Merge branch 'bug/fix-links' | ||
* Remove failing fixtures | ||
* Refactor `benchmark.js` | ||
* Update keywords, description in `package.json`, `component.json`, `bower.json` | ||
* Refactor `Readme.md` | ||
* Add badges for travis, coveralls to `Readme.md` | ||
* Add `logo.svg` | ||
* Add missing `new` operator to `lib/stringify.js` | ||
* Fix malformed `bower.json` | ||
* Fix incorrect script reference in `component.json` | ||
* Add strict mode to `index.js` | ||
* Refactor `bower.json` | ||
* Move `lib/stringify/index.js` to `lib/stringify.js` | ||
* Move `lib/parse/index.js` to `lib/parse.js` | ||
* Add npm deployment to `.travis.yml` | ||
* Remove `before_install` script in `.travis.yml` | ||
* Remove `Makefile` | ||
* Refactor `.npmignore` | ||
* Refactor `.gitignore` | ||
* Add broader version ranges to `package.json` | ||
* Update eslint | ||
* Update matcha | ||
* Update mocha | ||
* Refactor npm scripts in `package.json` | ||
* Move `test/mdast.spec.js` to `test/index.js` | ||
* Move `spec/` to `test/` | ||
* Move `benchmark/index.js` to `benchmark.js` | ||
* Refactor to disallow spaces after object keys | ||
* Add `.eslintrc` | ||
* Fix spacing around inline-code containing backticks | ||
* Refactor to simplify `spec/mdast.spec.js` | ||
* Add benchmark for `mdast.stringify` | ||
* Merge branch 'bug/fix-links' | ||
* Remove failing fixtures | ||
0.1.0-rc.2 / 2014-12-10 | ||
================== | ||
======================= | ||
* Add block-level nodes to every list-item | ||
* Add block-level nodes to every list-item | ||
0.1.0-rc.1 / 2014-12-07 | ||
================== | ||
======================= | ||
* Add near-finished stringifier | ||
* Fix test for changes in inline-code/code | ||
* Fix loose list-items by adding paragraph-nodes where needed | ||
* Fix multiple direct sibling blockquotes from appearing | ||
* Fix `undefined` in strings when using line-breaks inside list-items | ||
* Add inline-code node for code-spans | ||
* Remove null-type for table alignment | ||
* Add better errors for fixtures in spec | ||
* Add white-space trimming to code-blocks | ||
* Refactor position of `title` attribute in parse-output | ||
* Add he to API to decode HTML entities in `text` | ||
* Fix style issues in API | ||
* Update copyright in Readme.md | ||
* Remove testling | ||
* Refactor property order in bower.json, package.json, component.json | ||
* Update .gitignore, .npmignore | ||
* Add he as a dependency | ||
* Update eslint, jscs, mocha | ||
* Fix incorrect repo url | ||
* Refactor table output | ||
* Add initial work for both parse and stringify functionality | ||
* Refactor inline lexer | ||
* Add missing continue statement | ||
* Remove extraneous rule in eslint target | ||
* Refactor outputting similar nodes | ||
* Remove conditional assignment | ||
* Add benchmark to docs | ||
* Add a faster option setting mechanism | ||
* Add a simpler regular expression builder | ||
* Remove unneeded noop | ||
* Add near-finished stringifier | ||
* Fix test for changes in inline-code/code | ||
* Fix loose list-items by adding paragraph-nodes where needed | ||
* Fix multiple direct sibling blockquotes from appearing | ||
* Fix `undefined` in strings when using line-breaks inside list-items | ||
* Add inline-code node for code-spans | ||
* Remove null-type for table alignment | ||
* Add better errors for fixtures in spec | ||
* Add white-space trimming to code-blocks | ||
* Refactor position of `title` attribute in parse-output | ||
* Add he to API to decode HTML entities in `text` | ||
* Fix style issues in API | ||
* Update copyright in Readme.md | ||
* Remove testling | ||
* Refactor property order in bower.json, package.json, component.json | ||
* Update .gitignore, .npmignore | ||
* Add he as a dependency | ||
* Update eslint, jscs, mocha | ||
* Fix incorrect repo url | ||
* Refactor table output | ||
* Add initial work for both parse and stringify functionality | ||
* Refactor inline lexer | ||
* Add missing continue statement | ||
* Remove extraneous rule in eslint target | ||
* Refactor outputting similar nodes | ||
* Remove conditional assignment | ||
* Add benchmark to docs | ||
* Add a faster option setting mechanism | ||
* Add a simpler regular expression builder | ||
* Remove unneeded noop | ||
@@ -344,8 +359,8 @@ 0.0.3 / 2014-08-02 | ||
* Add documentation for settings | ||
* Fix option mechanism so different settings can work together | ||
* Add functionality to merge HTML nodes | ||
* Fix mailto removal in implicit links | ||
* Add more verbose comments | ||
* Fix typo in docs | ||
* Add documentation for settings | ||
* Fix option mechanism so different settings can work together | ||
* Add functionality to merge HTML nodes | ||
* Fix mailto removal in implicit links | ||
* Add more verbose comments | ||
* Fix typo in docs | ||
@@ -355,54 +370,54 @@ 0.0.2 / 2014-07-31 | ||
* Add docs for nodes | ||
* Rename cells > rows for tables | ||
* Fix a typo where images had an "href" attribute instead of "src" | ||
* Fix a bug where an internal type (looseItem) was exposed | ||
* Fix documentation for b7b5b44 | ||
* Refactored API so results are wrapped in a root token, resulting in easier footnote finding | ||
* Fininshed renaming: marked > mdast | ||
* Added initial functionality for footnotes | ||
* Fix a bug where multiple text tokens were not merged | ||
* Refactor fixture-loading mechanism | ||
* Refactored readme | ||
* Renamed README > Readme | ||
* Removed build.js | ||
* Added changelog | ||
* Update travis | ||
* Refactor bower.json | ||
* Refactor component.json | ||
* Added testling | ||
* Update mocha | ||
* Refactored package.json | ||
* Removed robotskirt, showdown, markdown | ||
* Added benchmark | ||
* Fixed npm script targets; initial benchmark | ||
* Removed bin, doc, man | ||
* Renamed lib/mdast.js > index.js | ||
* Removed marked tests | ||
* Added more istanbul ignore comments for error reporting code | ||
* Added a unit test for images with empty alt attributes | ||
* Made token types and variables more verbose | ||
* Inlined peek in api | ||
* Added unit tests for automatic email detection | ||
* Added two istanbul ignore comments for error reporting code | ||
* Removed an extraneous debug message, removed a dead statement | ||
* Fixed an istanbul-ignore comment | ||
* Added unit tests for pedantic list items (stricter definition) | ||
* Added unit tests for pedantic code blocks (persistant trailing whitespace) | ||
* Added a unit test for images with a title | ||
* Removed two uncovered branches from spec | ||
* Added inline pedantic fixtures | ||
* Removed functionality to exposing inline lexer | ||
* removed smartLists options and moved it to pedantic; added fixtures | ||
* Added a tables:false fixture | ||
* Added functionality to use options through fixture filenames | ||
* Refactored merge; added istanbul ignore coverage comments | ||
* Add unit test linting; add coverage | ||
* Fixed style | ||
* Refactor; things are working | ||
* Major refactor, JSON is now given instead of HTML | ||
* Refactored .jscs.json to indent with 2 instead of four spaces | ||
* Add myself as a copyright holder to LICENSE | ||
* Refactor for mdast | ||
* Add docs for nodes | ||
* Rename cells > rows for tables | ||
* Fix a typo where images had an "href" attribute instead of "src" | ||
* Fix a bug where an internal type (looseItem) was exposed | ||
* Fix documentation for b7b5b44 | ||
* Refactored API so results are wrapped in a root token, resulting in easier footnote finding | ||
* Fininshed renaming: marked > mdast | ||
* Added initial functionality for footnotes | ||
* Fix a bug where multiple text tokens were not merged | ||
* Refactor fixture-loading mechanism | ||
* Refactored readme | ||
* Renamed README > Readme | ||
* Removed build.js | ||
* Added changelog | ||
* Update travis | ||
* Refactor bower.json | ||
* Refactor component.json | ||
* Added testling | ||
* Update mocha | ||
* Refactored package.json | ||
* Removed robotskirt, showdown, markdown | ||
* Added benchmark | ||
* Fixed npm script targets; initial benchmark | ||
* Removed bin, doc, man | ||
* Renamed lib/mdast.js > index.js | ||
* Removed marked tests | ||
* Added more istanbul ignore comments for error reporting code | ||
* Added a unit test for images with empty alt attributes | ||
* Made token types and variables more verbose | ||
* Inlined peek in api | ||
* Added unit tests for automatic email detection | ||
* Added two istanbul ignore comments for error reporting code | ||
* Removed an extraneous debug message, removed a dead statement | ||
* Fixed an istanbul-ignore comment | ||
* Added unit tests for pedantic list items (stricter definition) | ||
* Added unit tests for pedantic code blocks (persistant trailing whitespace) | ||
* Added a unit test for images with a title | ||
* Removed two uncovered branches from spec | ||
* Added inline pedantic fixtures | ||
* Removed functionality to exposing inline lexer | ||
* removed smartLists options and moved it to pedantic; added fixtures | ||
* Added a tables:false fixture | ||
* Added functionality to use options through fixture filenames | ||
* Refactored merge; added istanbul ignore coverage comments | ||
* Add unit test linting; add coverage | ||
* Fixed style | ||
* Refactor; things are working | ||
* Major refactor, JSON is now given instead of HTML | ||
* Refactored .jscs.json to indent with 2 instead of four spaces | ||
* Add myself as a copyright holder to LICENSE | ||
* Refactor for mdast | ||
Forked from [marked](https://github.com/chjj/marked). |
891
lib/parse.js
@@ -20,2 +20,3 @@ 'use strict'; | ||
trimRight, | ||
trimRightLines, | ||
clean; | ||
@@ -26,2 +27,3 @@ | ||
trimRight = utilities.trimRight; | ||
trimRightLines = utilities.trimRightLines; | ||
clean = utilities.clean; | ||
@@ -58,8 +60,4 @@ | ||
EXPRESSION_SPACES_ONLY_LINE, | ||
EXPRESSION_FINAL_NEW_LINES, | ||
EXPRESSION_TABLE_FENCE, | ||
EXPRESSION_TABLE_FENCE_PADDED, | ||
EXPRESSION_TABLE_INITIAL_OR_FINAL_FENCE, | ||
EXPRESSION_TABLE_BORDER, | ||
EXPRESSION_TABLE_LAST_FENCE, | ||
EXPRESSION_BLOCK_QUOTE, | ||
@@ -79,12 +77,12 @@ EXPRESSION_BULLET, | ||
EXPRESSION_SPACES_ONLY_LINE = /^ +$/gm; | ||
EXPRESSION_FINAL_NEW_LINES = /\n+$/; | ||
EXPRESSION_TABLE_FENCE = /^ *|\| *$/g; | ||
EXPRESSION_TABLE_FENCE_PADDED = /^ *| *\| *$/g; | ||
EXPRESSION_TABLE_INITIAL_OR_FINAL_FENCE = /^ *\| *| *\| *$/g; | ||
var EXPRESSION_TABLE_INITIAL = /^ *\| */g; | ||
var EXPRESSION_TABLE_CONTENT = /([\s\S]+?)( *\| *\n?|\n?$)/g; | ||
EXPRESSION_TABLE_BORDER = / *\| */; | ||
EXPRESSION_TABLE_LAST_FENCE = /(?: *\| *)?\n$/; | ||
EXPRESSION_BLOCK_QUOTE = /^ *> ?/gm; | ||
EXPRESSION_BULLET = /^ *([*+-]|\d+\.) +/; | ||
EXPRESSION_INITIAL_INDENT = /^ {1,4}/gm; | ||
EXPRESSION_INITIAL_TAB = /^ {4}/gm; | ||
EXPRESSION_INITIAL_TAB = /^( {4})?/gm; | ||
EXPRESSION_HTML_LINK_OPEN = /^<a /i; | ||
@@ -207,10 +205,10 @@ EXPRESSION_HTML_LINK_CLOSE = /^<\/a>/i; | ||
block.horizontalRule = /^( *[-*_]){3,} *(?:\n+|$)/; | ||
block.horizontalRule = /^( *[-*_]){3,} *(?=\n|$)/; | ||
block.heading = /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/; | ||
block.heading = /^ *((#{1,6}) *)([^\n]+?) *#* *(?=\n|$)/; | ||
block.lineHeading = /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/; | ||
block.lineHeading = /^([^\n]+)\n *(=|-){2,} *(?=\n|$)/; | ||
block.linkDefinition = | ||
/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/; | ||
/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?=\n|$)/; | ||
@@ -239,3 +237,3 @@ block.text = /^[^\n]+/; | ||
'\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))' + | ||
'\\n+(?=\\1?(?:[-*_] *){3,}(?=\\n|$))' + | ||
'|' + | ||
@@ -337,5 +335,5 @@ | ||
gfmLooseTable = | ||
/^( *(\S.*\|.*)\n)( *([-:]+ *\|[-| :]*)\n)((?:.*\|.*(?:\n|$))*)/; | ||
/^( *(\S.*\|.*))\n( *([-:]+ *\|[-| :]*)\n)((?:.*\|.*(?:\n|$))*)/; | ||
gfmTable = /^( *\|(.+)\n)( *\|( *[-:]+[-| :]*)\n)((?: *\|.*(?:\n|$))*)/; | ||
gfmTable = /^( *\|(.+))\n( *\|( *[-:]+[-| :]*)\n)((?: *\|.*(?:\n|$))*)/; | ||
@@ -349,3 +347,3 @@ /* | ||
gfmCodeFences = /^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/; | ||
gfmCodeFences = /^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]*?)\s*\1 *(?=\n|$)/; | ||
@@ -383,3 +381,3 @@ gfmParagraph = new RegExp( | ||
inline.invalidLink = /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/; | ||
inline.invalidLink = /^(!?\[)((?:\[[^\]]*\]|[^\[\]])*)\]/; | ||
@@ -401,3 +399,3 @@ inline.strong = /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/; | ||
inline.link = new RegExp( | ||
'^!?\\[(' + | ||
'^(!?\\[)(' + | ||
cleanExpression(inline.inside) + | ||
@@ -410,3 +408,3 @@ ')\\]\\(' + | ||
inline.referenceLink = new RegExp( | ||
'^!?\\[(' + | ||
'^(!?\\[)(' + | ||
cleanExpression(inline.inside) + | ||
@@ -478,3 +476,3 @@ ')\\]\\s*\\[([^\\]]*)\\]' | ||
MERGEABLE_NODES.html = function (prev, token) { | ||
prev.value += token.value; | ||
prev.value += '\n\n' + token.value; | ||
@@ -491,4 +489,4 @@ return prev; | ||
*/ | ||
MERGEABLE_NODES.text = function (prev, token) { | ||
prev.value += '\n' + token.value; | ||
MERGEABLE_NODES.text = function (prev, token, type) { | ||
prev.value += (type === 'block' ? '\n' : '') + token.value; | ||
@@ -528,2 +526,4 @@ return prev; | ||
function tokenizeCode(eat, $0) { | ||
$0 = trimRightLines($0); | ||
eat($0)(this.renderCodeBlock($0)); | ||
@@ -550,7 +550,16 @@ } | ||
* @param {string} $0 - Whole heading. | ||
* @param {string} $1 - Hashes. | ||
* @param {string} $2 - Content. | ||
* @param {string} $1 - Initial hashes and spacing. | ||
* @param {string} $2 - Hashes. | ||
* @param {string} $3 - Content. | ||
*/ | ||
function tokenizeHeading(eat, $0, $1, $2) { | ||
eat($0)(this.renderHeading($2, $1.length)); | ||
function tokenizeHeading(eat, $0, $1, $2, $3) { | ||
var offset, | ||
line; | ||
offset = this.offset; | ||
line = eat.now().line; | ||
offset[line] = (offset[line] || 0) + $1.length; | ||
eat($0)(this.renderHeading($3, $2.length)); | ||
} | ||
@@ -587,3 +596,7 @@ | ||
function tokenizeBlockquote(eat, $0) { | ||
eat($0)(this.renderBlockquote($0)); | ||
var now; | ||
now = eat.now(); | ||
eat($0)(this.renderBlockquote($0, now)); | ||
} | ||
@@ -601,2 +614,3 @@ | ||
var self, | ||
now, | ||
matches, | ||
@@ -608,2 +622,3 @@ firstBullet, | ||
add, | ||
item, | ||
enterTop, | ||
@@ -618,6 +633,12 @@ exitBlockquote, | ||
/* | ||
* Remove indent. | ||
*/ | ||
$0 = trimRight($0); | ||
/* | ||
* Parse the list. | ||
*/ | ||
matches = trimRight($0).match(self.blockRules.item); | ||
matches = $0.match(self.blockRules.item); | ||
@@ -644,2 +665,3 @@ length = matches.length; | ||
matches = matches.slice(0, index); | ||
length = matches.length; | ||
@@ -649,8 +671,2 @@ break; | ||
} | ||
if (matches.length !== length) { | ||
$0 = matches.join(NEW_LINE); | ||
length = matches.length; | ||
} | ||
} | ||
@@ -660,3 +676,3 @@ | ||
add = eat($0); | ||
add = eat(''); | ||
@@ -669,5 +685,13 @@ enterTop = self.exitTop(); | ||
while (++index < length) { | ||
add(list, self.renderListItem(matches[index])); | ||
item = matches[index]; | ||
now = eat.now(); | ||
item = eat(item)(list, self.renderListItem(item, now)); | ||
eat(NEW_LINE); | ||
} | ||
list.position.end.line = item.position.end.line; | ||
list.position.end.column = item.position.end.column; | ||
enterTop(); | ||
@@ -684,2 +708,4 @@ exitBlockquote(); | ||
function tokenizeHtml(eat, $0) { | ||
$0 = trimRightLines($0); | ||
eat($0)(this.renderRaw('html', $0)); | ||
@@ -721,8 +747,25 @@ } | ||
var self, | ||
token; | ||
token, | ||
now, | ||
line, | ||
offset; | ||
self = this; | ||
token = eat($0)({}, self.renderFootnoteDefinition( | ||
$2.toLowerCase(), $3.replace(EXPRESSION_INITIAL_TAB, '') | ||
now = eat.now(); | ||
line = now.line; | ||
offset = self.offset; | ||
$3 = $3.replace(EXPRESSION_INITIAL_TAB, function (value) { | ||
offset[line] = (offset[line] || 0) + value.length; | ||
line++; | ||
return ''; | ||
}); | ||
now.column += $1.length; | ||
token = eat($0)({}, | ||
self.renderFootnoteDefinition($2.toLowerCase(), $3, now | ||
)); | ||
@@ -750,30 +793,78 @@ | ||
var self, | ||
add, | ||
token, | ||
table, | ||
index, | ||
length, | ||
values, | ||
value, | ||
row, | ||
rowIndex, | ||
rowLength; | ||
length; | ||
self = this; | ||
add = eat(''); | ||
$0 = trimRightLines($0); | ||
$5 = trimRightLines($5); | ||
token = add({ | ||
table = eat('')({ | ||
'type': 'table', | ||
'align': [] | ||
'align': [], | ||
'children': [] | ||
}); | ||
/** | ||
* Eat a fence. | ||
* | ||
* @param {string} value | ||
* @return {string} - Empty. | ||
*/ | ||
function eatFence(value) { | ||
eat(value); | ||
return ''; | ||
} | ||
/** | ||
* Factory to eat a cell to a bound `row`. | ||
* | ||
* @param {Object} row | ||
* @return {Function} | ||
*/ | ||
function eatCellFactory(row) { | ||
/** | ||
* Eat a cell. | ||
* | ||
* @param {string} value | ||
* @param {string} content | ||
* @param {string} pipe | ||
* @return {string} - Empty. | ||
*/ | ||
return function (value, content, pipe) { | ||
eat(content)(row, self.renderBlock('tableCell', content)); | ||
eat(pipe); | ||
return ''; | ||
}; | ||
} | ||
/** | ||
* Eat a row of type `type`. | ||
* | ||
* @param {string} type | ||
* @param {string} value | ||
*/ | ||
function renderRow(type, value) { | ||
var row; | ||
row = eat('')(table, self.renderBlock(type, [])); | ||
value | ||
.replace(EXPRESSION_TABLE_INITIAL, eatFence) | ||
.replace(EXPRESSION_TABLE_CONTENT, eatCellFactory(row)); | ||
row.position.end = eat.now(); | ||
} | ||
/* | ||
* Add the table header to table's children. | ||
* Add the table's header. | ||
*/ | ||
$2 = $2 | ||
.replace(EXPRESSION_TABLE_FENCE_PADDED, '') | ||
.split(EXPRESSION_TABLE_BORDER); | ||
renderRow('tableHeader', $1); | ||
eat($1)(token, self.renderBlock('tableHeader', $2)); | ||
eat(NEW_LINE); | ||
@@ -790,3 +881,3 @@ /* | ||
token.align = getAlignment($4); | ||
table.align = getAlignment($4); | ||
@@ -797,8 +888,4 @@ /* | ||
eat($5); | ||
$5 = $5.split(NEW_LINE); | ||
$5 = $5 | ||
.replace(EXPRESSION_TABLE_LAST_FENCE, '') | ||
.split(NEW_LINE); | ||
index = -1; | ||
@@ -808,28 +895,10 @@ length = $5.length; | ||
while (++index < length) { | ||
value = $5[index] | ||
.replace(EXPRESSION_TABLE_INITIAL_OR_FINAL_FENCE, '') | ||
.split(EXPRESSION_TABLE_BORDER); | ||
renderRow('tableRow', $5[index]); | ||
add(token, self.renderBlock('tableRow', value)); | ||
if (index !== length - 1) { | ||
eat(NEW_LINE); | ||
} | ||
} | ||
/* | ||
* Add table cells in each row (incl. header). | ||
*/ | ||
values = token.children; | ||
index = -1; | ||
length = values.length; | ||
while (++index < length) { | ||
row = values[index].children; | ||
rowIndex = -1; | ||
rowLength = row.length; | ||
while (++rowIndex < rowLength) { | ||
row[rowIndex] = add({}, self.renderBlock( | ||
'tableCell', row[rowIndex] | ||
)); | ||
} | ||
} | ||
table.position.end = eat.now(); | ||
} | ||
@@ -875,4 +944,3 @@ | ||
'lang': language || null, | ||
'value': removeIndent(value || '') | ||
.replace(EXPRESSION_FINAL_NEW_LINES, '') | ||
'value': trimRightLines(removeIndent(value || '')) | ||
}; | ||
@@ -902,12 +970,16 @@ } | ||
*/ | ||
function renderListItem(token) { | ||
function renderListItem(token, position) { | ||
var space, | ||
expression, | ||
loose; | ||
loose, | ||
offset, | ||
line; | ||
space = 0; | ||
offset = this.offset; | ||
line = position.line; | ||
/* | ||
* Remove the list token's bullet so it is seen as the | ||
* next token. | ||
* Remove the list token's bullet. | ||
*/ | ||
@@ -918,2 +990,11 @@ | ||
offset[line] = (offset[line] || 0) + space; | ||
/* | ||
* Make sure that the first nine numbered list items | ||
* can indent with an extra space: | ||
*/ | ||
space = Math.ceil(space / 2) * 2; | ||
return ''; | ||
@@ -926,10 +1007,15 @@ }); | ||
if (token.indexOf('\n ') !== -1) { | ||
expression = this.options.pedantic ? | ||
EXPRESSION_INITIAL_INDENT : | ||
new RegExp('^ {1,' + space + '}', 'gm'); | ||
token = token.replace(expression, ''); | ||
if (this.options.pedantic) { | ||
expression = EXPRESSION_INITIAL_INDENT; | ||
} else { | ||
expression = new RegExp('^( {0,' + space + '})', 'gm'); | ||
} | ||
token = token.replace(expression, function ($0) { | ||
offset[line] = (offset[line] || 0) + $0.length; | ||
line++; | ||
return ''; | ||
}); | ||
/* | ||
@@ -945,3 +1031,3 @@ * Determine whether token is loose or not. | ||
'loose': loose, | ||
'children': this.tokenizeBlock(token) | ||
'children': this.tokenizeBlock(token, position) | ||
}; | ||
@@ -957,3 +1043,3 @@ } | ||
*/ | ||
function renderFootnoteDefinition(id, value) { | ||
function renderFootnoteDefinition(id, value, position) { | ||
var self, | ||
@@ -970,3 +1056,3 @@ token, | ||
'id': id, | ||
'children': self.tokenizeBlock(value) | ||
'children': self.tokenizeBlock(value, position) | ||
}; | ||
@@ -1002,16 +1088,26 @@ | ||
*/ | ||
function renderBlockquote(value) { | ||
function renderBlockquote(value, position) { | ||
var self, | ||
token, | ||
exitBlockquote; | ||
exitBlockquote, | ||
offset, | ||
line; | ||
self = this; | ||
line = position.line; | ||
offset = self.offset; | ||
exitBlockquote = self.enterBlockquote(); | ||
value = value.replace(EXPRESSION_BLOCK_QUOTE, ''); | ||
value = value.replace(EXPRESSION_BLOCK_QUOTE, function ($0) { | ||
offset[line] = (offset[line] || 0) + $0.length; | ||
line++; | ||
return ''; | ||
}); | ||
token = { | ||
'type': 'blockquote', | ||
'children': this.tokenizeBlock(value) | ||
'children': this.tokenizeBlock(value, position) | ||
}; | ||
@@ -1073,3 +1169,3 @@ | ||
*/ | ||
function renderLink(isLink, href, text, title) { | ||
function renderLink(isLink, href, text, title, position) { | ||
var token, | ||
@@ -1087,3 +1183,3 @@ exitLink; | ||
token.href = href; | ||
token.children = this.tokenizeInline(text); | ||
token.children = this.tokenizeInline(text, position); | ||
@@ -1119,6 +1215,6 @@ exitLink(); | ||
*/ | ||
function renderInline(type, value) { | ||
function renderInline(type, value, location) { | ||
return { | ||
'type': type, | ||
'children': this.tokenizeInline(value) | ||
'children': this.tokenizeInline(value, location) | ||
}; | ||
@@ -1149,3 +1245,5 @@ } | ||
var href, | ||
text; | ||
text, | ||
now, | ||
offset; | ||
@@ -1155,2 +1253,8 @@ href = $1; | ||
/* | ||
* `1` is for the length of an opening angle bracket. | ||
*/ | ||
offset = 1; | ||
if ($2 === AT_SIGN) { | ||
@@ -1161,6 +1265,10 @@ if (text.substr(0, MAILTO_PROTOCOL.length) !== MAILTO_PROTOCOL) { | ||
text = text.substr(MAILTO_PROTOCOL.length); | ||
offset += MAILTO_PROTOCOL.length; | ||
} | ||
} | ||
eat($0)(this.renderLink(true, href, text)); | ||
now = eat.now(); | ||
now.column += offset; | ||
eat($0)(this.renderLink(true, href, text, null, now)); | ||
} | ||
@@ -1179,3 +1287,7 @@ | ||
function tokenizeURL(eat, $0, $1) { | ||
eat($0)(this.renderLink(true, $1, $1)); | ||
var now; | ||
now = eat.now(); | ||
eat($0)(this.renderLink(true, $1, $1, null, now)); | ||
} | ||
@@ -1214,4 +1326,5 @@ | ||
*/ | ||
function tokenizeLink(eat, $0, $1, $2, $3) { | ||
var isLink; | ||
function tokenizeLink(eat, $0, $1, $2, $3, $4) { | ||
var isLink, | ||
now; | ||
@@ -1221,3 +1334,7 @@ isLink = $0.charAt(0) !== EXCLAMATION_MARK; | ||
if (!isLink || !this.inLink) { | ||
eat($0)(this.renderLink(isLink, $2, $1, $3)); | ||
now = eat.now(); | ||
now.column += $1.length; | ||
eat($0)(this.renderLink(isLink, $3, $2, $4, now)); | ||
} | ||
@@ -1233,14 +1350,16 @@ } | ||
* @param {string} $0 - Whole link. | ||
* @param {string} $1 - URL. | ||
* @param {string} $2 - Content. | ||
* @param {string} $1 - Prefix. | ||
* @param {string} $2 - URL. | ||
* @param {string} $3 - Content. | ||
*/ | ||
function tokenizeReferenceLink(eat, $0, $1, $2) { | ||
function tokenizeReferenceLink(eat, $0, $1, $2, $3) { | ||
var self, | ||
text, | ||
url, | ||
token; | ||
token, | ||
now; | ||
self = this; | ||
text = ($2 || $1).replace(EXPRESSION_WHITE_SPACES, SPACE); | ||
text = ($3 || $2).replace(EXPRESSION_WHITE_SPACES, SPACE); | ||
url = self.links[text.toLowerCase()]; | ||
@@ -1279,4 +1398,12 @@ | ||
now = eat.now(); | ||
/* | ||
* Add initial bracket plus caret. | ||
*/ | ||
now.column += $1.length + 1; | ||
token = self.renderFootnoteDefinition( | ||
String(self.footnoteCounter), text.substr(1) | ||
String(self.footnoteCounter), text.substr(1), now | ||
); | ||
@@ -1291,4 +1418,8 @@ | ||
} else { | ||
now = eat.now($1); | ||
now.column += $1.length; | ||
eat($0)(self.renderLink( | ||
$0.charAt(0) !== EXCLAMATION_MARK, url.href, $1, url.title | ||
$0.charAt(0) !== EXCLAMATION_MARK, url.href, $2, url.title, now | ||
)); | ||
@@ -1309,3 +1440,9 @@ } | ||
function tokenizeStrong(eat, $0, $1, $2) { | ||
eat($0)(this.renderInline('strong', $2 || $1)); | ||
var now; | ||
now = eat.now(); | ||
now.column += 2; | ||
eat($0)(this.renderInline('strong', $2 || $1, now)); | ||
} | ||
@@ -1322,3 +1459,9 @@ | ||
function tokenizeEmphasis(eat, $0, $1, $2) { | ||
eat($0)(this.renderInline('emphasis', $2 || $1)); | ||
var now; | ||
now = eat.now(); | ||
now.column += 1; | ||
eat($0)(this.renderInline('emphasis', $2 || $1, now)); | ||
} | ||
@@ -1334,3 +1477,9 @@ | ||
function tokenizeDeletion(eat, $0, $1) { | ||
eat($0)(this.renderInline('delete', $1)); | ||
var now; | ||
now = eat.now(); | ||
now.column += 2; | ||
eat($0)(this.renderInline('delete', $1, now)); | ||
} | ||
@@ -1455,6 +1604,15 @@ | ||
index, | ||
token; | ||
token, | ||
start, | ||
last; | ||
self = this; | ||
/* | ||
* Add an `offset` matrix, used to keep track of | ||
* syntax and white space indentation per line. | ||
*/ | ||
self.offset = {}; | ||
value = self.tokenizeAll(self.tokenizeBlock(clean(value))); | ||
@@ -1479,2 +1637,13 @@ | ||
last = token.children[token.children.length - 1]; | ||
token.position = { | ||
'start': { | ||
'line': 1, | ||
'column': 1 | ||
} | ||
}; | ||
token.position.end = last ? last.position.end : start; | ||
return token; | ||
@@ -1517,9 +1686,4 @@ }; | ||
var self, | ||
type, | ||
children, | ||
cells, | ||
index, | ||
cellIterator, | ||
length, | ||
cellLength; | ||
pos, | ||
type; | ||
@@ -1529,29 +1693,21 @@ self = this; | ||
type = token.type; | ||
pos = token.position; | ||
if (type === 'text') { | ||
token = self.tokenizeOne(self.renderBlock('paragraph', token.value)); | ||
} else if (type === 'table') { | ||
index = -1; | ||
children = token.children; | ||
length = children.length; | ||
while (++index < length) { | ||
cellIterator = -1; | ||
cells = children[index].children; | ||
cellLength = cells.length; | ||
while (++cellIterator < cellLength) { | ||
cells[cellIterator].children = | ||
self.tokenizeInline(cells[cellIterator].children); | ||
} | ||
} | ||
token = self.renderBlock('paragraph', token.value); | ||
token.position = pos; | ||
token = self.tokenizeOne(token); | ||
} else if ( | ||
type === 'heading' || | ||
type === 'paragraph' | ||
type === 'paragraph' || | ||
type === 'tableCell' | ||
) { | ||
token.children = self.tokenizeInline(token.children); | ||
token.children = self.tokenizeInline(token.children, pos.start); | ||
} else if ( | ||
type === 'blockquote' || | ||
type === 'list' || | ||
type === 'listItem' | ||
type === 'listItem' || | ||
type === 'table' || | ||
type === 'tableHeader' || | ||
type === 'tableRow' | ||
) { | ||
@@ -1609,130 +1765,265 @@ token.children = self.tokenizeAll(token.children); | ||
/** | ||
* Lex `value`. | ||
* Construct a tokenizer. | ||
* | ||
* @param {string} value | ||
* @return {Array.<Object>} | ||
* @param {string} type | ||
* @return {function(string, Object?): Array.<Object>} | ||
*/ | ||
Parser.prototype.tokenizeBlock = function (value) { | ||
var self, | ||
tokens, | ||
blockMethods, | ||
blockTokenizers, | ||
blockRules, | ||
index, | ||
length, | ||
method, | ||
name, | ||
match, | ||
matched, | ||
valueLength; | ||
function tokenizeFactory(type) { | ||
/** | ||
* Tokenizer for a bound `type` | ||
* | ||
* @param {string} value | ||
* @return {Array.<Object>} | ||
*/ | ||
return function (value, location) { | ||
var self, | ||
line, | ||
column, | ||
offset, | ||
tokens, | ||
methods, | ||
tokenizers, | ||
rules, | ||
index, | ||
length, | ||
method, | ||
name, | ||
match, | ||
matched, | ||
valueLength; | ||
self = this; | ||
self = this; | ||
value = value.replace(EXPRESSION_SPACES_ONLY_LINE, ''); | ||
offset = self.offset; | ||
tokens = []; | ||
tokens = []; | ||
blockMethods = self.blockMethods; | ||
blockTokenizers = self.blockTokenizers; | ||
blockRules = self.blockRules; | ||
/* | ||
* Trim white space only lines. | ||
*/ | ||
/** | ||
* Add `token` to `parent`, or `tokens`. | ||
* | ||
* @param {Object} parent | ||
* @param {Object?} token | ||
* @return {Object} The added or merged token. | ||
*/ | ||
function add(parent, token) { | ||
var prev, | ||
children; | ||
value = (value || '').replace(EXPRESSION_SPACES_ONLY_LINE, ''); | ||
if (!token) { | ||
children = tokens; | ||
token = parent; | ||
} else { | ||
if (!parent.children) { | ||
parent.children = []; | ||
if (!value) { | ||
return tokens; | ||
} | ||
methods = self[type + 'Methods']; | ||
tokenizers = self[type + 'Tokenizers']; | ||
rules = self[type + 'Rules']; | ||
/* | ||
* Positional information. | ||
*/ | ||
line = location ? location.line : 1; | ||
column = location ? location.column : 1; | ||
/** | ||
* Update line and column based on `value`. | ||
* | ||
* @param {string} subvalue | ||
*/ | ||
function updatePosition(subvalue) { | ||
var lines, | ||
lastIndex; | ||
lines = subvalue.match(/\n/g); | ||
if (lines) { | ||
line += lines.length; | ||
} | ||
children = parent.children; | ||
lastIndex = subvalue.lastIndexOf('\n'); | ||
if (lastIndex === -1) { | ||
column = column + subvalue.length; | ||
} else { | ||
column = subvalue.length - lastIndex; | ||
} | ||
if (line in offset) { | ||
if (lines) { | ||
column += offset[line]; | ||
} else if (column <= offset[line]) { | ||
column = offset[line] + 1; | ||
} | ||
} | ||
} | ||
prev = children[children.length - 1]; | ||
/** | ||
* Get the current position. | ||
* | ||
* @return {Object} | ||
*/ | ||
function now() { | ||
return { | ||
'line': line, | ||
'column': column | ||
}; | ||
} | ||
if ( | ||
prev && | ||
token.type === prev.type && | ||
token.type in MERGEABLE_NODES | ||
) { | ||
token = MERGEABLE_NODES[token.type](prev, token); | ||
} else { | ||
children.push(token); | ||
/** | ||
* Store position information for a node. | ||
* | ||
* @param {Object} start | ||
*/ | ||
function Position(start) { | ||
this.start = start; | ||
this.end = now(); | ||
} | ||
return token; | ||
} | ||
/** | ||
* Mark position and patch `node.position`. | ||
* | ||
* @returns {function(Node): Node} | ||
*/ | ||
function position() { | ||
var start; | ||
/** | ||
* Remove `subvalue` from `value`. | ||
* Expects `subvalue` to be at the start from `value`, | ||
* and applies no validation. | ||
* | ||
* @param {string} subvalue | ||
* @return {Function} See add. | ||
*/ | ||
function eat(subvalue) { | ||
value = value.substring(subvalue.length); | ||
start = now(); | ||
return add; | ||
} | ||
return function (node) { | ||
start = node.position ? node.position.start : start; | ||
/* | ||
* Iterate over `value`, and iterate over all | ||
* block-expressions. When one matches, invoke | ||
* its companion function. If no expression | ||
* matches, something failed (should not happen) | ||
* and an expression is thrown. | ||
*/ | ||
node.position = new Position(start); | ||
while (value) { | ||
index = -1; | ||
length = blockMethods.length; | ||
matched = false; | ||
return node; | ||
}; | ||
} | ||
while (++index < length) { | ||
name = blockMethods[index]; | ||
/** | ||
* Add `token` to `parent`, or `tokens`. | ||
* | ||
* @param {Object} parent | ||
* @param {Object?} token | ||
* @return {Object} The added or merged token. | ||
*/ | ||
function add(parent, token) { | ||
var prev, | ||
children; | ||
method = blockTokenizers[name]; | ||
if (!token) { | ||
children = tokens; | ||
token = parent; | ||
} else { | ||
if (!parent.children) { | ||
parent.children = []; | ||
} | ||
match = blockRules[name] && | ||
(!method.onlyAtTop || self.atTop) && | ||
(!method.notInBlockquote || !self.inBlockquote) && | ||
blockRules[name].exec(value); | ||
children = parent.children; | ||
} | ||
if (match) { | ||
valueLength = value.length; | ||
prev = children[children.length - 1]; | ||
method.apply(self, [eat].concat(match)); | ||
if (type === 'inline' && token.type === 'text') { | ||
token.value = he.decode(token.value); | ||
} | ||
matched = valueLength !== value.length; | ||
if ( | ||
prev && | ||
token.type === prev.type && | ||
token.type in MERGEABLE_NODES | ||
) { | ||
token = MERGEABLE_NODES[token.type](prev, token, type); | ||
} else { | ||
children.push(token); | ||
} | ||
/* istanbul ignore else */ | ||
if (matched) { | ||
break; | ||
return token; | ||
} | ||
/** | ||
* Remove `subvalue` from `value`. | ||
* Expects `subvalue` to be at the start from `value`, | ||
* and applies no validation. | ||
* | ||
* @param {string} subvalue | ||
* @return {Function} See add. | ||
*/ | ||
function eat(subvalue) { | ||
var pos; | ||
pos = position(); | ||
value = value.substring(subvalue.length); | ||
updatePosition(subvalue); | ||
return function () { | ||
return pos(add.apply(null, arguments)); | ||
}; | ||
} | ||
/* | ||
* Expose `now` on `eat`. | ||
*/ | ||
eat.now = now; | ||
/* | ||
* Sync initial offset. | ||
*/ | ||
updatePosition(''); | ||
/* | ||
* Iterate over `value`, and iterate over all | ||
* block-expressions. When one matches, invoke | ||
* its companion function. If no expression | ||
* matches, something failed (should not happen) | ||
* and an expression is thrown. | ||
*/ | ||
while (value) { | ||
index = -1; | ||
length = methods.length; | ||
matched = false; | ||
while (++index < length) { | ||
name = methods[index]; | ||
method = tokenizers[name]; | ||
match = rules[name] && | ||
(!method.onlyAtTop || self.atTop) && | ||
(!method.notInBlockquote || !self.inBlockquote) && | ||
(!method.notInLink || !self.inLink) && | ||
rules[name].exec(value); | ||
if (match) { | ||
valueLength = value.length; | ||
method.apply(self, [eat].concat(match)); | ||
matched = valueLength !== value.length; | ||
/* istanbul ignore else */ | ||
if (matched) { | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
/* istanbul ignore if */ | ||
if (!matched) { | ||
throw new Error( | ||
'Infinite loop on byte: ' + value.charCodeAt(0) | ||
); | ||
/* istanbul ignore if */ | ||
if (!matched) { | ||
throw new Error( | ||
'Infinite loop on byte: ' + value.charCodeAt(0) | ||
); | ||
} | ||
} | ||
} | ||
return tokens; | ||
}; | ||
return tokens; | ||
}; | ||
} | ||
/** | ||
* Lex `value`. | ||
* | ||
* @param {string} value | ||
* @return {Array.<Object>} | ||
*/ | ||
Parser.prototype.tokenizeBlock = tokenizeFactory('block'); | ||
/* | ||
@@ -1794,109 +2085,5 @@ * Expose helpers | ||
*/ | ||
Parser.prototype.tokenizeInline = function (value) { | ||
var self, | ||
tokens, | ||
inlineMethods, | ||
inlineTokenizers, | ||
inlineRules, | ||
index, | ||
length, | ||
method, | ||
name, | ||
match, | ||
matched, | ||
valueLength; | ||
self = this; | ||
Parser.prototype.tokenizeInline = tokenizeFactory('inline'); | ||
tokens = []; | ||
inlineMethods = self.inlineMethods; | ||
inlineTokenizers = self.inlineTokenizers; | ||
inlineRules = self.inlineRules; | ||
/** | ||
* Add `token` to `children`. | ||
* | ||
* @param {Object?} token | ||
* @return {Object} The added or merged token. | ||
*/ | ||
function add(token) { | ||
var prev; | ||
prev = tokens[tokens.length - 1]; | ||
if (token.type === 'text') { | ||
token.value = he.decode(token.value); | ||
} | ||
if (prev && prev.type === token.type && 'value' in prev) { | ||
prev.value += token.value; | ||
token = prev; | ||
} else { | ||
tokens.push(token); | ||
} | ||
return token; | ||
} | ||
/** | ||
* Remove `subvalue` from `value`. | ||
* Expects `subvalue` to be at the start from `value`, | ||
* and applies no validation. | ||
* | ||
* @param {string} subvalue | ||
* @return {Function} See add. | ||
*/ | ||
function eat(subvalue) { | ||
value = value.substring(subvalue.length); | ||
return add; | ||
} | ||
/* | ||
* Iterate over `value`, and iterate over all | ||
* block-expressions. When one matches, invoke | ||
* its companion function. If no expression | ||
* matches, something failed (should not happen) | ||
* and an expression is thrown. | ||
*/ | ||
while (value) { | ||
index = -1; | ||
length = inlineMethods.length; | ||
matched = false; | ||
while (++index < length) { | ||
name = inlineMethods[index]; | ||
method = inlineTokenizers[name]; | ||
match = inlineRules[name] && | ||
(!method.notInLink || !self.inLink) && | ||
inlineRules[name].exec(value); | ||
if (match) { | ||
valueLength = value.length; | ||
method.apply(self, [eat].concat(match)); | ||
matched = valueLength !== value.length; | ||
if (matched) { | ||
break; | ||
} | ||
} | ||
} | ||
/* istanbul ignore if */ | ||
if (!matched) { | ||
throw new Error( | ||
'Infinite loop on byte: ' + value.charCodeAt(0) | ||
); | ||
} | ||
} | ||
return tokens; | ||
}; | ||
/** | ||
@@ -1903,0 +2090,0 @@ * Construct a state toggler. |
@@ -37,5 +37,7 @@ 'use strict'; | ||
var INDENT, | ||
var HALF, | ||
INDENT, | ||
MINIMUM_CODE_FENCE_LENGTH; | ||
HALF = 2; | ||
INDENT = 4; | ||
@@ -443,2 +445,3 @@ MINIMUM_CODE_FENCE_LENGTH = 3; | ||
length, | ||
bullet, | ||
indent; | ||
@@ -454,6 +457,7 @@ | ||
while (++index < length) { | ||
indent = (index + 1) + DOT + SPACE; | ||
bullet = (index + 1) + DOT + SPACE; | ||
indent = Math.ceil(bullet.length / HALF) * HALF; | ||
values[index] = indent + | ||
self.listItem(tokens[index], token, level, indent.length); | ||
values[index] = bullet + | ||
self.listItem(tokens[index], token, level, indent); | ||
} | ||
@@ -477,2 +481,3 @@ | ||
length, | ||
bullet, | ||
indent; | ||
@@ -487,7 +492,8 @@ | ||
indent = this.options.bullet + SPACE; | ||
bullet = this.options.bullet + SPACE; | ||
indent = Math.ceil(bullet.length / HALF) * HALF; | ||
while (++index < length) { | ||
values[index] = indent + | ||
self.listItem(tokens[index], token, level, indent.length); | ||
values[index] = bullet + | ||
self.listItem(tokens[index], token, level, indent); | ||
} | ||
@@ -524,7 +530,3 @@ | ||
/* | ||
* `html` tokens include their ending new lines. | ||
*/ | ||
if (prevType && prevType !== 'html') { | ||
if (prevType) { | ||
/* | ||
@@ -531,0 +533,0 @@ * Duplicate tokens, such as a list |
@@ -16,2 +16,3 @@ 'use strict'; | ||
var WHITE_SPACE_FINAL, | ||
NEW_LINE_FINAL, | ||
WHITE_SPACE_INITIAL, | ||
@@ -24,2 +25,3 @@ EXPRESSION_TAB, | ||
WHITE_SPACE_FINAL = /\s+$/; | ||
NEW_LINE_FINAL = /\n+$/; | ||
WHITE_SPACE_INITIAL = /^\s+/; | ||
@@ -76,2 +78,12 @@ EXPRESSION_LINE_BREAKS = /\r\n|\r/g; | ||
/** | ||
* Remove final new line characters from `value`. | ||
* | ||
* @param {string} value | ||
* @return {string} | ||
*/ | ||
function trimRightLines(value) { | ||
return String(value).replace(NEW_LINE_FINAL, ''); | ||
} | ||
/** | ||
* Remove initial white space from `value`. | ||
@@ -95,3 +107,3 @@ * | ||
.replace(EXPRESSION_LINE_BREAKS, '\n') | ||
.replace(EXPRESSION_TAB, ' ') | ||
.replace(EXPRESSION_TAB, ' ') | ||
.replace(EXPRESSION_NO_BREAK_SPACE, ' ') | ||
@@ -119,2 +131,3 @@ .replace(EXPRESSION_SYMBOL_FOR_NEW_LINE, '\n'); | ||
exports.trimRight = trimRight; | ||
exports.trimRightLines = trimRightLines; | ||
@@ -121,0 +134,0 @@ /* |
{ | ||
"name": "mdast", | ||
"version": "0.1.12", | ||
"version": "0.2.0", | ||
"description": "Speedy Markdown parser/stringifier for multipurpose analysis", | ||
@@ -45,2 +45,4 @@ "license": "MIT", | ||
"matcha": "^0.6.0", | ||
"mdast": "^0.1.12", | ||
"mdast-usage": "^0.1.0", | ||
"mocha": "^2.0.0" | ||
@@ -58,14 +60,15 @@ }, | ||
"lint-cli": "eslint --rule no-process-exit:false cli.js", | ||
"lint-script": "eslint script/build-options.js", | ||
"lint-script": "eslint script/build-options.js example.js", | ||
"lint-test": "eslint --env mocha test/index.js test/fixtures.js test/plugin.js", | ||
"lint-style": "jscs --reporter inline index.js benchmark.js cli.js script/build-options.js lib/parse.js lib/stringify.js lib/utilities.js test/index.js test/fixtures.js test/plugin.js", | ||
"lint-style": "jscs --reporter inline index.js benchmark.js cli.js example.js script/build-options.js lib/parse.js lib/stringify.js lib/utilities.js test/index.js test/fixtures.js test/plugin.js", | ||
"lint": "npm run lint-api && npm run lint-benchmark && npm run lint-cli && npm run lint-script && npm run lint-test && npm run lint-style", | ||
"make": "npm run lint && npm run test-coverage", | ||
"benchmark": "matcha benchmark.js", | ||
"build-usage": "mdast --use mdast-usage Readme.md -o Readme.md", | ||
"build-options": "node script/build-options.js", | ||
"build-bundle": "browserify index.js -s mdast > mdast.js", | ||
"postbuild-bundle": "esmangle mdast.js > mdast.min.js", | ||
"build": "npm run build-options && npm run build-bundle", | ||
"build": "npm run build-usage && npm run build-options && npm run build-bundle", | ||
"prepublish": "npm run build" | ||
} | ||
} |
192
Readme.md
@@ -49,3 +49,7 @@ # ![mdast](https://cdn.rawgit.com/wooorm/mdast/master/logo.svg) | ||
var mdast = require('mdast'); | ||
``` | ||
Parse markdown with `mdast.parse`: | ||
```javascript | ||
var ast = mdast.parse('Some *emphasis*, **strongness**, and `code`.'); | ||
@@ -58,4 +62,4 @@ ``` | ||
{ | ||
"type" : "root", | ||
"children" : [ | ||
"type": "root", | ||
"children": [ | ||
{ | ||
@@ -66,37 +70,151 @@ "type": "paragraph", | ||
"type": "text", | ||
"value": "Some " | ||
"value": "Some ", | ||
"position": { | ||
"start": { | ||
"line": 1, | ||
"column": 1 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 6 | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "emphasis", | ||
"children": [{ | ||
"type": "text", | ||
"value": "emphasis" | ||
}] | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"value": "emphasis", | ||
"position": { | ||
"start": { | ||
"line": 1, | ||
"column": 7 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 15 | ||
} | ||
} | ||
} | ||
], | ||
"position": { | ||
"start": { | ||
"line": 1, | ||
"column": 6 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 16 | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "text", | ||
"value": ", " | ||
"value": ", ", | ||
"position": { | ||
"start": { | ||
"line": 1, | ||
"column": 16 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 19 | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "strong", | ||
"children": [{ | ||
"type": "text", | ||
"value": "strongness" | ||
}] | ||
"children": [ | ||
{ | ||
"type": "text", | ||
"value": "strongness", | ||
"position": { | ||
"start": { | ||
"line": 1, | ||
"column": 21 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 31 | ||
} | ||
} | ||
} | ||
], | ||
"position": { | ||
"start": { | ||
"line": 1, | ||
"column": 19 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 33 | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "text", | ||
"value": ", and " | ||
"value": ", and ", | ||
"position": { | ||
"start": { | ||
"line": 1, | ||
"column": 33 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 39 | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "inlineCode", | ||
"value": "code" | ||
"value": "code", | ||
"position": { | ||
"start": { | ||
"line": 1, | ||
"column": 39 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 45 | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "text", | ||
"value": "." | ||
"value": ".", | ||
"position": { | ||
"start": { | ||
"line": 1, | ||
"column": 45 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 46 | ||
} | ||
} | ||
} | ||
] | ||
], | ||
"position": { | ||
"start": { | ||
"line": 1, | ||
"column": 1 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 46 | ||
} | ||
} | ||
} | ||
] | ||
], | ||
"position": { | ||
"start": { | ||
"line": 1, | ||
"column": 1 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 46 | ||
} | ||
} | ||
} | ||
@@ -108,3 +226,3 @@ ``` | ||
```javascript | ||
mdast.stringify(ast); | ||
var doc = mdast.stringify(ast); | ||
``` | ||
@@ -126,7 +244,7 @@ | ||
- `options` (`Object`, `null`, `undefined`) — Optional options: | ||
- `gfm` (`boolean`, default: `true`). See [Github Flavoured Markdown](doc/Options.md#github-flavoured-markdown); | ||
- `tables` (`boolean`, default: `true`). See [Tables](doc/Options.md#tables); | ||
- `footnotes` (`boolean`, default: `false`). See [Footnotes](doc/Options.md#footnotes). | ||
- `pedantic` (`boolean`, default: `false`). See [Pedantic](doc/Options.md#pedantic); | ||
- `breaks` (`boolean`, default: `false`). See [Breaks](doc/Options.md#breaks); | ||
- `gfm` (`boolean`, default: `true`). See [Github Flavoured Markdown](doc/Options.md#github-flavoured-markdown); | ||
- `tables` (`boolean`, default: `true`). See [Tables](doc/Options.md#tables); | ||
- `footnotes` (`boolean`, default: `false`). See [Footnotes](doc/Options.md#footnotes). | ||
- `pedantic` (`boolean`, default: `false`). See [Pedantic](doc/Options.md#pedantic); | ||
- `breaks` (`boolean`, default: `false`). See [Breaks](doc/Options.md#breaks); | ||
@@ -143,13 +261,13 @@ All options (including the options object itself) can be `null` or `undefined` to default to their default values. | ||
- `options` (`Object`) — Optional options: | ||
- `setext` (`boolean`, default: `false`). See [Setext Headings](doc/Options.md#setext-headings); | ||
- `closeAtx` (`boolean`, default: `false`). See [Closed ATX Headings](doc/Options.md#closed-atx-headings); | ||
- `referenceLinks` (`boolean`, default: `false`). See [Reference Links](doc/Options.md#reference-links); | ||
- `referenceFootnotes` (`boolean`, default: `true`). See [Inline Footnotes](doc/Options.md#inline-footnotes); | ||
- `fences` (`boolean`, default: `false`). See [Fences](doc/Options.md#fences); | ||
- `bullet` (`"-"`, `"*"`, or `"+"`, default: `"-"`). See [List Item Bullets](doc/Options.md#list-item-bullets); | ||
- `rule` (`"-"`, `"*"`, or `"_"`, default: `"*"`). See [Horizontal Rules](doc/Options.md#horizontal-rules); | ||
- `ruleRepetition` (`number`, default: 3). See [Horizontal Rules](doc/Options.md#horizontal-rules); | ||
- `ruleSpaces` (`boolean`, default `true`). See [Horizontal Rules](doc/Options.md#horizontal-rules); | ||
- `strong` (`"_"`, or `"*"`, default `"*"`). See [Emphasis Markers](doc/Options.md#emphasis-markers); | ||
- `emphasis` (`"_"`, or `"*"`, default `"_"`). See [Emphasis Markers](doc/Options.md#emphasis-markers). | ||
- `setext` (`boolean`, default: `false`). See [Setext Headings](doc/Options.md#setext-headings); | ||
- `closeAtx` (`boolean`, default: `false`). See [Closed ATX Headings](doc/Options.md#closed-atx-headings); | ||
- `referenceLinks` (`boolean`, default: `false`). See [Reference Links](doc/Options.md#reference-links); | ||
- `referenceFootnotes` (`boolean`, default: `true`). See [Inline Footnotes](doc/Options.md#inline-footnotes); | ||
- `fences` (`boolean`, default: `false`). See [Fences](doc/Options.md#fences); | ||
- `bullet` (`"-"`, `"*"`, or `"+"`, default: `"-"`). See [List Item Bullets](doc/Options.md#list-item-bullets); | ||
- `rule` (`"-"`, `"*"`, or `"_"`, default: `"*"`). See [Horizontal Rules](doc/Options.md#horizontal-rules); | ||
- `ruleRepetition` (`number`, default: 3). See [Horizontal Rules](doc/Options.md#horizontal-rules); | ||
- `ruleSpaces` (`boolean`, default `true`). See [Horizontal Rules](doc/Options.md#horizontal-rules); | ||
- `strong` (`"_"`, or `"*"`, default `"*"`). See [Emphasis Markers](doc/Options.md#emphasis-markers); | ||
- `emphasis` (`"_"`, or `"*"`, default `"_"`). See [Emphasis Markers](doc/Options.md#emphasis-markers). | ||
@@ -217,5 +335,5 @@ All options (including the options object itself) can be `null` or `undefined` to default to their default values. | ||
```text | ||
benchmarks * 76 fixtures (total: 50Kb markdown) | ||
63 op/s » mdast.parse | ||
145 op/s » mdast.stringify | ||
benchmarks * 76 fixtures (total: 50Kb markdown) | ||
63 op/s » mdast.parse | ||
145 op/s » mdast.stringify | ||
``` | ||
@@ -222,0 +340,0 @@ |
107274
10
3118
341
12