remark-trim
v0.0.6
Published
Remark plugin to trim unnecessary spaces from `strong`, `emphasis`, `inlineCode`, `image` and `url` nodes
Downloads
2
Maintainers
Readme
remark-trim
remark plugin to trim all unnecessary spaces in
strong
,emphasis
,inlineCode
,url
andimage
nodes
Installation
npm install remark-trim --save
Usage
Say we have the following file, example.md
:
# Title
`code`
`code with a few spaces`
` const param = [ 1, 2, 3 ] `
`const param = false`
```
const block = true
```
Paragraph with ** bold ** text .
Paragraph with ** _ bold italic _ ** text :
Paragraph with [ link with spaces ](https://link.com)
Paragraph with image ![ caption with spaces ](https://images.com/demo.png)
Paragraph with _ italic _ text.
And our script, example.js
, looks as follows:
const vfile = require('to-vfile')
const remark = require('remark')
const trim = require('remark-trim')
const markdown = remark()
.use(trim)
.use({ settings: { fences: true } })
.process(vfile.readSync('example.md'), function (err, file) {
if (err) throw err
console.log(String(file))
})
Now, running node example
yields:
# Title
`code`
`code with a few spaces`
` const param = [ 1, 2, 3 ] `
`const param = false`
```
const block = true
```
Paragraph with **bold** text.
Paragraph with **_bold italic_** text:
Paragraph with [link with spaces](https://link.com)
Paragraph with image ![caption with spaces](https://images.com/demo.png)
Paragraph with _italic_ text.