markdown-it-obsidian-imgsize

0.1.1 • Public • Published

markdown-it-obsidian-imgsize

language: English | 中文

A markdown-it plugin, adding width (and height) attributes to image elements.

According to the syntax of external images in Obsidian , it transforms

![A cat|100](cat.jpg)
![A cat|100x200](cat.jpg)

to

<p><img src="cat.jpg" alt="A cat" width="100px"></p>
<p><img src="cat.jpg" alt="A cat" width="100px" height="200px"></p>

More cases are in examples.md. Different from markdown-it-renderer-image, this plugin does not use the Internet when processing online images.

Install

npm i markdown-it-obsidian-imgsize --save

Use

const md = require('markdown-it')();
const mdImgSizePlg = require('markdown-it-obsidian-imgsize');
md.use(mdImgSizePlg);

const content = '![A cat|100](cat.jpg)';
console.log(md.render(content));
// <p><img src="cat.jpg" alt="A cat" width="100px"></p>
// See './test/examples.md' for more examples

markdown-it-renderer-image

markdown-it-obsidian-images

License

MIT

Package Sidebar

Install

npm i markdown-it-obsidian-imgsize

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

5.1 kB

Total Files

4

Last publish

Collaborators

  • wuanqin