Giter Club home page Giter Club logo

markdown-it-multi-imgsize's Introduction

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

markdown-it-multi-imgsize's People

Contributors

peaceroad avatar nand2 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.