remark-parse
Advanced tools
Comparing version 9.0.0 to 10.0.0
25
index.js
@@ -1,24 +0,3 @@ | ||
'use strict' | ||
import remarkParse from './lib/index.js' | ||
module.exports = parse | ||
var fromMarkdown = require('mdast-util-from-markdown') | ||
function parse(options) { | ||
var self = this | ||
this.Parser = parse | ||
function parse(doc) { | ||
return fromMarkdown( | ||
doc, | ||
Object.assign({}, self.data('settings'), options, { | ||
// Note: these options are not in the readme. | ||
// The goal is for them to be set by plugins on `data` instead of being | ||
// passed by users. | ||
extensions: self.data('micromarkExtensions') || [], | ||
mdastExtensions: self.data('fromMarkdownExtensions') || [] | ||
}) | ||
) | ||
} | ||
} | ||
export default remarkParse |
{ | ||
"name": "remark-parse", | ||
"version": "9.0.0", | ||
"description": "remark plugin to parse Markdown", | ||
"version": "10.0.0", | ||
"description": "remark plugin to parse markdown", | ||
"license": "MIT", | ||
@@ -19,3 +19,2 @@ "keywords": [ | ||
], | ||
"types": "types/index.d.ts", | ||
"homepage": "https://remark.js.org", | ||
@@ -36,13 +35,27 @@ "repository": "https://github.com/remarkjs/remark/tree/main/packages/remark-parse", | ||
], | ||
"sideEffects": false, | ||
"type": "module", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"index.js", | ||
"types/index.d.ts" | ||
"lib/", | ||
"index.d.ts", | ||
"index.js" | ||
], | ||
"dependencies": { | ||
"mdast-util-from-markdown": "^0.8.0" | ||
"@types/mdast": "^3.0.0", | ||
"mdast-util-from-markdown": "^1.0.0", | ||
"unified": "^10.0.0" | ||
}, | ||
"scripts": { | ||
"test": "tape test.js" | ||
"test": "node --conditions development test.js", | ||
"build": "rimraf \"test.d.ts\" \"lib/**/*.d.ts\" && tsc && type-coverage" | ||
}, | ||
"xo": false | ||
"xo": false, | ||
"typeCoverage": { | ||
"atLeast": 100, | ||
"detail": true, | ||
"strict": true, | ||
"ignoreCatch": true | ||
} | ||
} |
@@ -12,10 +12,13 @@ # remark-parse | ||
[Parser][] for [**unified**][unified]. | ||
Parses Markdown to [**mdast**][mdast] syntax trees. | ||
Parses markdown to [**mdast**][mdast] syntax trees. | ||
Built on [`micromark`][micromark] and | ||
[`mdast-util-from-markdown`][from-markdown]. | ||
Used in the [**remark** processor][remark] but can be used on its own as well. | ||
Can be [extended][extend] to change how Markdown is parsed. | ||
Can be [extended][extend] to change how markdown is parsed. | ||
## Install | ||
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c): | ||
Node 12+ is needed to use it and it must be `import`ed instead of `require`d. | ||
[npm][]: | ||
@@ -30,11 +33,24 @@ | ||
```js | ||
var unified = require('unified') | ||
var createStream = require('unified-stream') | ||
var markdown = require('remark-parse') | ||
var remark2rehype = require('remark-rehype') | ||
var html = require('rehype-stringify') | ||
import {unified} from 'unified' | ||
import remarkParse from 'remark-parse' | ||
import remarkGfm from 'remark-gfm' | ||
import remarkRehype from 'remark-rehype' | ||
import rehypeStringify from 'rehype-stringify' | ||
var processor = unified().use(markdown).use(remark2rehype).use(html) | ||
unified() | ||
.use(remarkParse) | ||
.use(remarkGfm) | ||
.use(remarkRehype) | ||
.use(rehypeStringify) | ||
.process('# Hi\n\n*Hello*, world!') | ||
.then((file) => { | ||
console.log(String(file)) | ||
}) | ||
``` | ||
process.stdin.pipe(createStream(processor)).pipe(process.stdout) | ||
Yields: | ||
```html | ||
<h1>Hi</h1> | ||
<p><em>Hello</em>, world!</p> | ||
``` | ||
@@ -48,5 +64,8 @@ | ||
### `processor().use(parse)` | ||
This package exports no identifiers. | ||
The default export is `remarkParse`. | ||
Configure the `processor` to read Markdown as input and process | ||
### `unified().use(remarkParse)` | ||
Configure the `processor` to read markdown as input and process | ||
[**mdast**][mdast] syntax trees. | ||
@@ -61,3 +80,3 @@ | ||
As Markdown is sometimes used for HTML, and improper use of HTML can open you up | ||
As markdown is sometimes used for HTML, and improper use of HTML can open you up | ||
to a [cross-site scripting (XSS)][xss] attack, use of remark can also be unsafe. | ||
@@ -137,5 +156,5 @@ When going to HTML, use remark in combination with the [**rehype**][rehype] | ||
[build-badge]: https://img.shields.io/travis/remarkjs/remark.svg | ||
[build-badge]: https://github.com/remarkjs/remark/workflows/main/badge.svg | ||
[build]: https://travis-ci.org/remarkjs/remark | ||
[build]: https://github.com/remarkjs/remark/actions | ||
@@ -142,0 +161,0 @@ [coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark.svg |
10827
7
39
217
Yes
3
+ Added@types/mdast@^3.0.0
+ Addedunified@^10.0.0
+ Added@types/debug@4.1.12(transitive)
+ Added@types/ms@0.7.34(transitive)
+ Addedbail@2.0.2(transitive)
+ Addedcharacter-entities@2.0.2(transitive)
+ Addeddecode-named-character-reference@1.0.2(transitive)
+ Addeddequal@2.0.3(transitive)
+ Addeddiff@5.2.0(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedis-buffer@2.0.5(transitive)
+ Addedis-plain-obj@4.1.0(transitive)
+ Addedkleur@4.1.5(transitive)
+ Addedmdast-util-from-markdown@1.3.1(transitive)
+ Addedmdast-util-to-string@3.2.0(transitive)
+ Addedmicromark@3.2.0(transitive)
+ Addedmicromark-core-commonmark@1.1.0(transitive)
+ Addedmicromark-factory-destination@1.1.0(transitive)
+ Addedmicromark-factory-label@1.1.0(transitive)
+ Addedmicromark-factory-space@1.1.0(transitive)
+ Addedmicromark-factory-title@1.1.0(transitive)
+ Addedmicromark-factory-whitespace@1.1.0(transitive)
+ Addedmicromark-util-character@1.2.0(transitive)
+ Addedmicromark-util-chunked@1.1.0(transitive)
+ Addedmicromark-util-classify-character@1.1.0(transitive)
+ Addedmicromark-util-combine-extensions@1.1.0(transitive)
+ Addedmicromark-util-decode-numeric-character-reference@1.1.0(transitive)
+ Addedmicromark-util-decode-string@1.1.0(transitive)
+ Addedmicromark-util-encode@1.1.0(transitive)
+ Addedmicromark-util-html-tag-name@1.2.0(transitive)
+ Addedmicromark-util-normalize-identifier@1.1.0(transitive)
+ Addedmicromark-util-resolve-all@1.1.0(transitive)
+ Addedmicromark-util-sanitize-uri@1.2.0(transitive)
+ Addedmicromark-util-subtokenize@1.1.0(transitive)
+ Addedmicromark-util-symbol@1.1.0(transitive)
+ Addedmicromark-util-types@1.1.0(transitive)
+ Addedmri@1.2.0(transitive)
+ Addedsade@1.8.1(transitive)
+ Addedtrough@2.2.0(transitive)
+ Addedunified@10.1.2(transitive)
+ Addedunist-util-stringify-position@3.0.3(transitive)
+ Addeduvu@0.5.6(transitive)
+ Addedvfile@5.3.7(transitive)
+ Addedvfile-message@3.1.4(transitive)
- Removedcharacter-entities@1.2.4(transitive)
- Removedcharacter-entities-legacy@1.1.4(transitive)
- Removedcharacter-reference-invalid@1.1.4(transitive)
- Removedis-alphabetical@1.0.4(transitive)
- Removedis-alphanumerical@1.0.4(transitive)
- Removedis-decimal@1.0.4(transitive)
- Removedis-hexadecimal@1.0.4(transitive)
- Removedmdast-util-from-markdown@0.8.5(transitive)
- Removedmdast-util-to-string@2.0.0(transitive)
- Removedmicromark@2.11.4(transitive)
- Removedparse-entities@2.0.0(transitive)
- Removedunist-util-stringify-position@2.0.3(transitive)