UNPKG

4.47 kBMarkdownView Raw
1# remark-breaks
2
3[![Build][build-badge]][build]
4[![Coverage][coverage-badge]][coverage]
5[![Downloads][downloads-badge]][downloads]
6[![Size][size-badge]][size]
7[![Sponsors][sponsors-badge]][collective]
8[![Backers][backers-badge]][collective]
9[![Chat][chat-badge]][chat]
10
11[**remark**][remark] plugin to add break support, without needing spaces.
12
13## Note!
14
15This plugin is ready for the new parser in remark
16([`micromark`](https://github.com/micromark/micromark),
17see [`remarkjs/remark#536`](https://github.com/remarkjs/remark/pull/536)).
18A patch version was released (`2.0.1`) that works with old and new remark.
19
20## Install
21
22This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):
23Node 12+ is needed to use it and it must be `import`ed instead of `require`d.
24
25[npm][]:
26
27```sh
28npm install remark-breaks
29```
30
31## Use
32
33Say we have the following file, `example.md` (note: there are no spaces after
34`a`):
35
36```markdown
37This is a
38paragraph.
39```
40
41And our module, `example.js`, looks as follows:
42
43```js
44import {readSync} from 'to-vfile'
45import {unified} from 'unified'
46import remarkParse from 'remark-parse'
47import remarkBreaks from 'remark-breaks'
48import remarkRehype from 'remark-rehype'
49import rehypeStringify from 'rehype-stringify'
50
51const file = readSync('example.md')
52
53unified()
54 .use(remarkParse)
55 .use(remarkBreaks)
56 .use(remarkRehype)
57 .use(rehypeStringify)
58 .process(file)
59 .then((file) => {
60 console.log(String(file))
61 })
62```
63
64Now, running `node example` yields:
65
66```html
67<p>This is a<br>
68paragraph.</p>
69```
70
71Without `remark-breaks`, you’d get:
72
73```html
74<p>This is a
75paragraph.</p>
76```
77
78## API
79
80This package exports no identifiers.
81The default export is `remarkBreaks`.
82
83### `unified().use(remarkBreaks)`
84
85Plugin to add break support without needing spaces.
86This adds support for GitHub style (in issues, pull requests, comments, and
87releases) hard breaks without needing spaces before newlines.
88
89## Security
90
91Use of `remark-breaks` does not involve [**rehype**][rehype] ([**hast**][hast])
92or user content so there are no openings for [cross-site scripting (XSS)][xss]
93attacks.
94
95## Related
96
97* [`remark-gfm`](https://github.com/remarkjs/remark-gfm)
98 — GitHub Flavored Markdown
99* [`remark-github`](https://github.com/remarkjs/remark-github)
100 — Auto-link references like in GitHub issues, PRs, and comments
101* [`remark-footnotes`](https://github.com/remarkjs/remark-footnotes)
102 — Footnotes
103* [`remark-frontmatter`](https://github.com/remarkjs/remark-frontmatter)
104 — Frontmatter (YAML, TOML, and more) support
105* [`remark-math`](https://github.com/remarkjs/remark-math)
106 — Math
107
108## Contribute
109
110See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
111to get started.
112See [`support.md`][support] for ways to get help.
113
114This project has a [code of conduct][coc].
115By interacting with this repository, organization, or community you agree to
116abide by its terms.
117
118## License
119
120[MIT][license] © [Titus Wormer][author]
121
122<!-- Definitions -->
123
124[build-badge]: https://github.com/remarkjs/remark-breaks/workflows/main/badge.svg
125
126[build]: https://github.com/remarkjs/remark-breaks/actions
127
128[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-breaks.svg
129
130[coverage]: https://codecov.io/github/remarkjs/remark-breaks
131
132[downloads-badge]: https://img.shields.io/npm/dm/remark-breaks.svg
133
134[downloads]: https://www.npmjs.com/package/remark-breaks
135
136[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-breaks.svg
137
138[size]: https://bundlephobia.com/result?p=remark-breaks
139
140[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
141
142[backers-badge]: https://opencollective.com/unified/backers/badge.svg
143
144[collective]: https://opencollective.com/unified
145
146[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
147
148[chat]: https://github.com/remarkjs/remark/discussions
149
150[npm]: https://docs.npmjs.com/cli/install
151
152[health]: https://github.com/remarkjs/.github
153
154[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
155
156[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
157
158[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
159
160[license]: license
161
162[author]: https://wooorm.com
163
164[remark]: https://github.com/remarkjs/remark
165
166[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
167
168[rehype]: https://github.com/rehypejs/rehype
169
170[hast]: https://github.com/syntax-tree/hast