1.0.2 • Published 4 years ago

remark-change-image-paths v1.0.2

Weekly downloads
7
License
MIT
Repository
github
Last release
4 years ago

remark-change-image-paths

change image paths in your markdown files

install

npm install remark-change-image-paths --save

usage

const fs = require('fs')
const unified = require('unified')
const markdown = require('remark-parse')
const remarkChangeImagesPath = require('remark-change-image-paths')(
	{
		search: /^/,
		replace: "/path/to/imagesFolder/",
	}
)
const remark2rehype = require('remark-rehype')
const stringify = require('rehype-stringify')

unified()
        .use(markdown)
        .use(remark2rehype)
        .use(remarkChangeImagesPath)
        .use(stringify)
        .process(
                `![](img.png)`,
                function (err, file) {
                        if (err) throw err
                        console.log(String(file))
                }
        )

will output :

<img src="/path/to/imagesFolder/img.png">

credits

this if a fork from @h2xd/remark-change-image-paths