Skip to content

Commit 6b42465

Browse files
committed
Change to use micromark
This is a giant change for remark. It replaces the 5+ year old internals with a new low-level parser: <https://github.com/micromark/micromark> The old internals have served billions of users well over the years, but markdown has changed over that time. micromark comes with 100% CommonMark (and GFM as an extension) compliance, and (WIP) docs on parsing rules for how to tokenize markdown with a state machine: <https://github.com/micromark/common-markup-state-machine>. micromark, and micromark in remark, is a good base for the future. `remark-parse` now defers its work to [`micromark`][micromark] and [`mdast-util-from-markdown`][from-markdown]. `micromark` is a new, small, complete, and CommonMark compliant low-level markdown parser. `from-markdown` turns its tokens into the previously (and still) used syntax tree: [mdast][]. Extensions to `remark-parse` work differently: they’re a two-part act. See for example [`micromark-extension-footnote`][micromark-footnote] and [`mdast-util-footnote`][from-markdown-footnote]. * change: `commonmark` is no longer an option — it’s the default * move: `gfm` is no longer an option — moved to `remark-gfm` * remove: `pedantic` is no longer an option — this legacy and buggy flavor of markdown is no longer widely used * remove: `blocks` is no longer an options — it’s no longer suggested to change the internal list of HTML “block” tag names remark-stringify now defers its work to [`mdast-util-to-markdown`][to-markdown]. It’s a new and better serializer with powerful features to ensure serialized markdown represents the syntax tree (mdast), no matter what plugins do. Extensions to it work differently: see for example [`mdast-util-footnote`][to-markdown-footnote]. * change: `commonmark` is no longer an option, it’s the default * change: `emphasis` now defaults to `*` * change: `bullet` now defaults to `*` * move: `gfm` is no longer an option — moved to `remark-gfm` * move: `tableCellPadding` — moved to `remark-gfm` * move: `tablePipeAlign` — moved to `remark-gfm` * move: `stringLength` — moved to `remark-gfm` * remove: `pedantic` is no longer an option — this legacy and buggy flavor of markdown is no longer widely used * remove: `entities` is no longer an option — with CommonMark there is almost never a need to use character references, as character escapes are preferred * new: `quote` — you can now prefer single quotes (`'`) over double quotes (`"`) in titles All of these are for CommonMark compatibility. Most of them are inconsequential. * **notable**: references (as in, links `[text][id]` and images `![alt][id]`) are no longer present as such in the syntax tree if they don’t have a corresponding definition (`[id]: example.com`). The reason for this is that CommonMark requires `[text *emphasis start][undefined] emphasis end*` to be emphasis. * **notable**: it is no longer possible to use two blank lines between two lists or a list and indented code. CommonMark prohibits it. For a solution, use an empty comment to end lists (`<!---->`) * inconsequential: whitespace at the start and end of lines in paragraphs is now ignored * inconsequential: `<mailto:foobarbaz>` are now correctly parsed, and the scheme is part of the tree * inconsequential: indented code can now follow a block quote w/o blank line * inconsequential: trailing indented blank lines after indented code are no longer part of that code * inconsequential: character references and escapes are no longer present as separate text nodes * inconsequential: character references which HTML allows but CommonMark doesn’t, such as `&copy` w/o the semicolon, are no longer recognized * inconsequential: the `indent` field is no longer available on `position` * fix: multiline setext headings * fix: lazy lists * fix: attention (emphasis, strong) * fix: tabs * fix: empty alt on images is now present as an empty string * …plus a ton of other minor previous differences from CommonMark * get folks to use this and report problems! * make `remark-gfm` * start making next branches for plugins * get types into {from,to}-markdown and use them here Closes GH-218. Closes GH-306. Closes GH-315. Closes GH-324. Closes GH-398. Closes GH-402. Closes GH-407. Closes GH-439. Closes GH-450. Closes GH-459. Closes GH-493. Closes GH-494. Closes GH-497. Closes GH-504. Closes GH-517. Closes GH-521. Closes GH-523. Closes remarkjs/remark-lint#111. [micromark]: https://github.com/micromark/micromark [from-markdown]: https://github.com/syntax-tree/mdast-util-from-markdown [to-markdown]: https://github.com/syntax-tree/mdast-util-to-markdown [micromark-footnote]: https://github.com/micromark/micromark-extension-footnote/blob/main/index.js [to-markdown-footnote]: https://github.com/syntax-tree/mdast-util-footnote/blob/main/to-markdown.js [from-markdown-footnote]: https://github.com/syntax-tree/mdast-util-footnote/blob/main/from-markdown.js [mdast]: https://github.com/syntax-tree/mdast
1 parent 9ce4ae1 commit 6b42465

File tree

625 files changed

+10110
-342243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

625 files changed

+10110
-342243
lines changed

doc/getting-started.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ and written:
2424
# Alpha #
2525
Bravo charlie **delta** __echo__.
2626
- Foxtrot
27-
* Golf
28-
+ Hotel
2927
```
3028

3129
Yields:
@@ -35,14 +33,12 @@ Yields:
3533

3634
Bravo charlie **delta** **echo**.
3735

38-
- Foxtrot
39-
- Golf
40-
- Hotel
36+
* Foxtrot
4137
```
4238

4339
But, much more can be done, [through plugins][plugins].
4440

45-
## Command-line
41+
## Command line
4642

4743
**remark**’s CLI is a simple way to process Markdown files from the
4844
command line. Its interface is provided by [**unified-args**][unified-args].
@@ -108,9 +104,9 @@ The `--save-dev` option stores the dependencies in our `package.json`:
108104
"name": "my-package",
109105
"version": "1.0.0",
110106
+ "devDependencies": {
111-
+ "remark-cli": "^6.0.0",
112-
+ "remark-html": "^8.0.0",
113-
+ "remark-preset-lint-markdown-style-guide": "^2.0.0"
107+
+ "remark-cli": "^8.0.0",
108+
+ "remark-html": "^12.0.0",
109+
+ "remark-preset-lint-markdown-style-guide": "^3.0.0"
114110
+ },
115111
"scripts": {
116112
"test": "node test.js"
@@ -126,9 +122,9 @@ configuration:
126122
"name": "my-package",
127123
"version": "1.0.0",
128124
"devDependencies": {
129-
"remark-cli": "^6.0.0",
130-
"remark-html": "^8.0.0",
131-
"remark-preset-lint-markdown-style-guide": "^2.0.0"
125+
"remark-cli": "^8.0.0",
126+
"remark-html": "^12.0.0",
127+
"remark-preset-lint-markdown-style-guide": "^3.0.0"
132128
},
133129
"scripts": {
134130
- "test": "node test.js"

doc/plugins.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,10 @@ virtual files.
287287

288288
## Using plugins
289289

290-
To use a plugin programmatically, invoke the [`use()`][unified-use]
291-
function.
290+
To use a plugin programmatically, call the [`use()`][unified-use] function.
292291

293-
To use plugin with `remark-cli`, pass a [`--use` flag][unified-args-use]
294-
or specify it in a [configuration file][config-file-use].
292+
To use plugin with `remark-cli`, pass a [`--use` flag][unified-args-use] or
293+
specify it in a [configuration file][config-file-use].
295294

296295
## Creating plugins
297296

license

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(The MIT License)
22

3-
Copyright (c) 2014-2016 Titus Wormer <[email protected]>
3+
Copyright (c) 2014-2020 Titus Wormer <[email protected]>
44
Copyright (c) 2011-2014, Christopher Jeffrey (https://github.com/chjj/)
55

66
Permission is hereby granted, free of charge, to any person obtaining a copy

log.txt

Whitespace-only changes.

package.json

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,32 @@
1010
"url": "https://opencollective.com/unified"
1111
},
1212
"devDependencies": {
13-
"bail": "^1.0.0",
1413
"browserify": "^16.0.0",
1514
"camelcase": "^6.0.0",
16-
"clone": "^2.0.0",
1715
"dtslint": "^4.0.0",
1816
"execa": "^4.0.0",
1917
"lerna": "^3.0.0",
2018
"mdast-util-assert": "^3.0.0",
21-
"mdast-util-compact": "^2.0.0",
22-
"mdast-zone": "^4.0.0",
19+
"mdast-util-gfm": "^0.1.0",
20+
"micromark-extension-gfm": "^0.3.0",
2321
"nyc": "^15.0.0",
2422
"prettier": "^2.0.0",
2523
"remark-preset-wooorm": "^7.0.0",
2624
"tape": "^5.0.0",
2725
"tinyify": "^3.0.0",
2826
"typescript": "^4.0.0",
2927
"unified": "^9.1.0",
30-
"unist-builder": "^2.0.0",
3128
"unist-util-remove-position": "^3.0.0",
32-
"unist-util-visit": "^2.0.0",
33-
"vfile": "^4.0.0",
34-
"wcwidth": "^1.0.0",
3529
"xo": "^0.33.0"
3630
},
3731
"scripts": {
3832
"postinstall": "lerna bootstrap --no-ci",
39-
"format": "packages/remark-cli/cli.js . -qfo && prettier . --write && xo --fix",
33+
"format": "prettier . -w --loglevel warn && xo --fix",
4034
"build-bundle": "browserify packages/remark -s remark > remark.js",
4135
"build-mangle": "browserify packages/remark -s remark -p tinyify > remark.min.js",
4236
"build": "npm run build-bundle && npm run build-mangle",
4337
"test-api": "tape \"packages/*/test.js\" \"test/index.js\"",
44-
"test-api-extensive": "TEST_EXTENDED=true npm run test-api",
45-
"test-coverage": "nyc --reporter lcov tape \"test/index.js\" \"packages/*/test.js\"",
38+
"test-coverage": "nyc --reporter lcov tape \"packages/*/test.js\" \"test/index.js\"",
4639
"test-types": "dtslint packages/remark-parse/types && dtslint packages/remark-stringify/types && dtslint packages/remark/types",
4740
"test": "npm run format && npm run build && npm run test-coverage && npm run test-types"
4841
},
@@ -89,7 +82,6 @@
8982
},
9083
"remarkConfig": {
9184
"plugins": [
92-
"./script/list-of-methods",
9385
"preset-wooorm",
9486
[
9587
"toc",

packages/remark-cli/readme.md

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -17,53 +17,6 @@ Command line interface for [**remark**][remark].
1717
* Uses configuration from [`remarkConfig` fields in `package.json`
1818
files][config-file]
1919

20-
## Sponsors
21-
22-
Support this effort and give back by sponsoring on [OpenCollective][collective]!
23-
24-
<!--lint ignore no-html-->
25-
26-
<table>
27-
<tr valign="middle">
28-
<td width="20%" align="center" colspan="2">
29-
<a href="https://www.gatsbyjs.org">Gatsby</a> 🥇<br><br>
30-
<a href="https://www.gatsbyjs.org"><img src="https://avatars1.githubusercontent.com/u/12551863?s=256&v=4" width="128"></a>
31-
</td>
32-
<td width="20%" align="center" colspan="2">
33-
<a href="https://vercel.com">Vercel</a> 🥇<br><br>
34-
<a href="https://vercel.com"><img src="https://avatars1.githubusercontent.com/u/14985020?s=256&v=4" width="128"></a>
35-
</td>
36-
<td width="20%" align="center" colspan="2">
37-
<a href="https://www.netlify.com">Netlify</a><br><br>
38-
<!--OC has a sharper image-->
39-
<a href="https://www.netlify.com"><img src="https://images.opencollective.com/netlify/4087de2/logo/256.png" width="128"></a>
40-
</td>
41-
<td width="10%" align="center">
42-
<a href="https://www.holloway.com">Holloway</a><br><br>
43-
<a href="https://www.holloway.com"><img src="https://avatars1.githubusercontent.com/u/35904294?s=128&v=4" width="64"></a>
44-
</td>
45-
<td width="10%" align="center">
46-
<a href="https://themeisle.com">ThemeIsle</a><br><br>
47-
<a href="https://themeisle.com"><img src="https://avatars1.githubusercontent.com/u/58979018?s=128&v=4" width="64"></a>
48-
</td>
49-
<td width="10%" align="center">
50-
<a href="https://boostio.co">BoostIO</a><br><br>
51-
<a href="https://boostio.co"><img src="https://avatars1.githubusercontent.com/u/13612118?s=128&v=4" width="64"></a>
52-
</td>
53-
<td width="10%" align="center">
54-
<a href="https://expo.io">Expo</a><br><br>
55-
<a href="https://expo.io"><img src="https://avatars1.githubusercontent.com/u/12504344?s=128&v=4" width="64"></a>
56-
</td>
57-
</tr>
58-
<tr valign="middle">
59-
<td width="100%" align="center" colspan="10">
60-
<br>
61-
<a href="https://opencollective.com/unified"><strong>You?</strong></a>
62-
<br><br>
63-
</td>
64-
</tr>
65-
</table>
66-
6720
## Install
6821

6922
[npm][]:
@@ -154,6 +107,53 @@ This project has a [code of conduct][coc].
154107
By interacting with this repository, organization, or community you agree to
155108
abide by its terms.
156109

110+
## Sponsor
111+
112+
Support this effort and give back by sponsoring on [OpenCollective][collective]!
113+
114+
<!--lint ignore no-html-->
115+
116+
<table>
117+
<tr valign="middle">
118+
<td width="20%" align="center" colspan="2">
119+
<a href="https://www.gatsbyjs.org">Gatsby</a> 🥇<br><br>
120+
<a href="https://www.gatsbyjs.org"><img src="https://avatars1.githubusercontent.com/u/12551863?s=256&v=4" width="128"></a>
121+
</td>
122+
<td width="20%" align="center" colspan="2">
123+
<a href="https://vercel.com">Vercel</a> 🥇<br><br>
124+
<a href="https://vercel.com"><img src="https://avatars1.githubusercontent.com/u/14985020?s=256&v=4" width="128"></a>
125+
</td>
126+
<td width="20%" align="center" colspan="2">
127+
<a href="https://www.netlify.com">Netlify</a><br><br>
128+
<!--OC has a sharper image-->
129+
<a href="https://www.netlify.com"><img src="https://images.opencollective.com/netlify/4087de2/logo/256.png" width="128"></a>
130+
</td>
131+
<td width="10%" align="center">
132+
<a href="https://www.holloway.com">Holloway</a><br><br>
133+
<a href="https://www.holloway.com"><img src="https://avatars1.githubusercontent.com/u/35904294?s=128&v=4" width="64"></a>
134+
</td>
135+
<td width="10%" align="center">
136+
<a href="https://themeisle.com">ThemeIsle</a><br><br>
137+
<a href="https://themeisle.com"><img src="https://avatars1.githubusercontent.com/u/58979018?s=128&v=4" width="64"></a>
138+
</td>
139+
<td width="10%" align="center">
140+
<a href="https://boostio.co">BoostIO</a><br><br>
141+
<a href="https://boostio.co"><img src="https://avatars1.githubusercontent.com/u/13612118?s=128&v=4" width="64"></a>
142+
</td>
143+
<td width="10%" align="center">
144+
<a href="https://expo.io">Expo</a><br><br>
145+
<a href="https://expo.io"><img src="https://avatars1.githubusercontent.com/u/12504344?s=128&v=4" width="64"></a>
146+
</td>
147+
</tr>
148+
<tr valign="middle">
149+
<td width="100%" align="center" colspan="10">
150+
<br>
151+
<a href="https://opencollective.com/unified"><strong>You?</strong></a>
152+
<br><br>
153+
</td>
154+
</tr>
155+
</table>
156+
157157
## License
158158

159159
[MIT][license] © [Titus Wormer][author]

packages/remark-parse/index.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
'use strict'
22

3-
var unherit = require('unherit')
4-
var xtend = require('xtend')
5-
var Parser = require('./lib/parser.js')
6-
73
module.exports = parse
8-
parse.Parser = Parser
4+
5+
var fromMarkdown = require('mdast-util-from-markdown')
96

107
function parse(options) {
11-
var settings = this.data('settings')
12-
var Local = unherit(Parser)
8+
var self = this
139

14-
Local.prototype.options = xtend(Local.prototype.options, settings, options)
10+
this.Parser = parse
1511

16-
this.Parser = Local
12+
function parse(doc) {
13+
var settings = Object.assign({}, self.data('settings'), options)
14+
// Note: these options are not in the readme.
15+
// The goal is for them to be set by plugins on `data` instead of being
16+
// passed by users.
17+
settings.extensions = settings.micromarkExtensions
18+
settings.mdastExtensions = settings.fromMarkdownExtensions
19+
return fromMarkdown(doc, settings)
20+
}
1721
}

packages/remark-parse/lib/block-elements.js

Lines changed: 0 additions & 70 deletions
This file was deleted.

packages/remark-parse/lib/decode.js

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)