remark-trim

    0.0.6 • Public • Published

    remark-trim

    remark plugin to trim all unnecessary spaces in strong, emphasis, inlineCode, url and image 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.

    Install

    npm i remark-trim

    DownloadsWeekly Downloads

    6

    Version

    0.0.6

    License

    none

    Unpacked Size

    9.03 kB

    Total Files

    11

    Last publish

    Collaborators

    • andreystepanov