Gathering detailed insights and metrics for @ruanyf/markdown-it-implicit-figures
Gathering detailed insights and metrics for @ruanyf/markdown-it-implicit-figures
Render markdown images to a paragraph as a figure
npm install @ruanyf/markdown-it-implicit-figures
Typescript
Module System
Min. Node Version
Node Version
NPM Version
69.1
Supply Chain
99.3
Quality
76.1
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
99
Last Day
1
Last Week
2
Last Month
9
Last Year
99
4 Stars
78 Commits
1 Watching
1 Branches
8 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.1
Package Id
@ruanyf/markdown-it-implicit-figures@1.0.1
Unpacked Size
10.98 kB
Size
3.76 kB
File Count
5
NPM Version
10.8.1
Node Version
22.2.0
Publised On
11 Jun 2024
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
100%
2
Compared to previous week
Last month
350%
9
Compared to previous month
Last year
0%
99
Compared to previous year
3
This repo is forked from @arve0/markdown-it-implicit-figures, adding ESM support.
Render images occurring by itself in a paragraph as <figure><img ...></figure>
, similar to pandoc's implicit figures.
Example input:
1text with ![](img.png) 2 3![](fig.png) 4 5works with links too: 6 7[![](fig.png)](page.html)
Output:
1<p>text with <img src="img.png" alt=""></p> 2<figure><img src="fig.png" alt=""></figure> 3<p>works with links too:</p> 4<figure><a href="page.html"><img src="fig.png" alt=""></a></figure>
$ npm install --save @ruanyf/markdown-it-implicit-figures
Load it in ES module.
1import markdownit from 'markdown-it'; 2import implicitFigures from '@ruanyf/markdown-it-implicit-figures'; 3 4const md = markdownit(); 5 6md.use(implicitFigures, { 7 dataType: false, // <figure data-type="image">, default: false 8 figcaption: false, // <figcaption>alternative text</figcaption>, default: false 9 keepAlt: false // <img alt="alt text" .../><figcaption>alt text</figcaption>, default: false 10 lazyLoading: false, // <img loading="lazy" ...>, default: false 11 link: false // <a href="img.png"><img src="img.png"></a>, default: false 12 tabindex: false, // <figure tabindex="1+n">..., default: false 13}); 14 15const src = 'text with ![](img.png)\n\n![](fig.png)\n\nanother paragraph'; 16const res = md.render(src); 17 18console.log(res);
Or load it in CommonJS module.
1const md = require('markdown-it')(); 2const implicitFigures = require('markdown-it-implicit-figures'); 3 4md.use(implicitFigures, { 5 dataType: false, // <figure data-type="image">, default: false 6 figcaption: false, // <figcaption>alternative text</figcaption>, default: false 7 keepAlt: false // <img alt="alt text" .../><figcaption>alt text</figcaption>, default: false 8 lazyLoading: false, // <img loading="lazy" ...>, default: false 9 link: false // <a href="img.png"><img src="img.png"></a>, default: false 10 tabindex: false, // <figure tabindex="1+n">..., default: false 11}); 12 13const src = 'text with ![](img.png)\n\n![](fig.png)\n\nanother paragraph'; 14const res = md.render(src); 15 16console.log(res);
dataType
: Set dataType
to true
to declare the data-type being wrapped,
e.g.: <figure data-type="image">
. This can be useful for applying special
styling for different kind of figures.
figcaption
: Set figcaption
to true
or alt
to put the alternative text
in a <figcaption>
-block after the image. E.g.: ![text](img.png)
renders to
1<figure> 2 <img src="img.png" alt=""> 3 <figcaption>text</figcaption> 4</figure>
figcaption
to title
to put the title text in a <figcaption>
-block
after the image. E.g.: ![text](img.png "title")
renders to
1<figure> 2 <img src="img.png" alt="text"> 3 <figcaption>title</figcaption> 4</figure>
keepAlt
: Set keepAlt
to true
to prevent it from being cleared when turned
into a figcaption
, E.g.: ![text](img.png)
renders to
1<figure> 2 <img src="img.png" alt="text"> 3 <figcaption>text</figcaption> 4</figure>
tabindex
: Set tabindex
to true
to add a tabindex
property to each
figure, beginning at tabindex="1"
and incrementing for each figure
encountered. Could be used with this css-trick,
which expands figures upon mouse-over.
lazyLoading
: Set lazyLoading
to true
to add loading="lazy"
to image element.
link
: Put a link around the image if there is none yet.
copyAttrs
: Copy attributes matching (RegExp or string) copyAttrs
to figure
element.
MIT
No vulnerabilities found.
No security vulnerabilities found.