Skip to content

nand2/markdown-it-multi-imgsize

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

markdown-it-multi-imgsize

Forked from the original markdown-it-obsidian-imgsize, it adds support for width percentage. It transforms

![A cat|40%](cat.jpg)

to

<p><img src="cat.jpg" alt="A cat" width="40%"></p>

Original documentation

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-multi-imgsize --save

Use

const md = require('markdown-it')();
const mdImgSizePlg = require('markdown-it-multi-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

Related Plugins

markdown-it-renderer-image

markdown-it-obsidian-images

License

MIT

About

A plugin to process Obsidian and other image sizing.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%