remark-with-images
remark plugin to get all images from
markdown
as anarray
and optionally update/replace them
Installation
npm install remark-with-images --save
Usage
Say we have the following file, example.md
:
# Title Some text with inline ![image 1](https://images.com/1.jpg) Some other text... ![image 2](https://images.com/2.jpg) Rest of the text...
And the javascript
might look like:
const parse = await { const contents: markdown data: images } = await // do something with markdown and images array return markdown images }
images
array would have this schema:
You also might want to reupload those images to some other place and then replace all the references. It's easy to do by just providing replace
option:
const replace = async { return { }} const parse = await { const contents: markdown data: images } = await // do something with updated markdown and images array return markdown images }
markdown
will become:
# Title Some text with inline ![image 1](https://cloud.images.com/1.jpg) Some other text... ![image 2](https://cloud.images.com/2.jpg) Rest of the text...
And images
array would be: