@peaceroad/markdown-it-figure-with-p-caption 0.4.4 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -20
- package/index.js +26 -10
- package/package.json +2 -2
- package/test/examples.txt +71 -6
- package/test/test.js +13 -1
package/README.md
CHANGED
|
@@ -121,7 +121,7 @@ A paragraph.
|
|
|
121
121
|
[Markdown]
|
|
122
122
|
A paragraph.
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
Source. A Caption.
|
|
125
125
|
|
|
126
126
|
> A quoted paragraph.
|
|
127
127
|
|
|
@@ -130,7 +130,7 @@ A paragraph.
|
|
|
130
130
|
[HTML]
|
|
131
131
|
<p>A paragraph.</p>
|
|
132
132
|
<figure class="f-blockquote">
|
|
133
|
-
<figcaption><span class="f-blockquote-label">
|
|
133
|
+
<figcaption><span class="f-blockquote-label">Source<span class="f-blockquote-label-joint">.</span></span> A Caption.</figcaption>
|
|
134
134
|
<blockquote>
|
|
135
135
|
<p>A quoted paragraph.</p>
|
|
136
136
|
</blockquote>
|
|
@@ -216,23 +216,6 @@ A paragraph.
|
|
|
216
216
|
<p>A paragraph.</p>
|
|
217
217
|
|
|
218
218
|
|
|
219
|
-
[Markdown]
|
|
220
|
-
A paragraph.
|
|
221
|
-
|
|
222
|
-
Quote. Twitter Post.
|
|
223
|
-
|
|
224
|
-
<blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>— User (@twitter) <a href="https://twitter.com/UserID/status/XXXXX">August 4, 2022</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
|
|
225
|
-
|
|
226
|
-
A paragraph.
|
|
227
|
-
[HTML]
|
|
228
|
-
<p>A paragraph.</p>
|
|
229
|
-
<figure class="f-blockquote">
|
|
230
|
-
<figcaption><span class="f-blockquote-label">Quote<span class="f-blockquote-label-joint">.</span></span> Twitter Post.</figcaption>
|
|
231
|
-
<blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>— User (@twitter) <a href="https://twitter.com/UserID/status/XXXXX">August 4, 2022</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
|
|
232
|
-
</figure>
|
|
233
|
-
<p>A paragraph.</p>
|
|
234
|
-
|
|
235
|
-
|
|
236
219
|
[Markdown]
|
|
237
220
|
A paragraph.
|
|
238
221
|
|
|
@@ -317,7 +300,9 @@ A paragraph.
|
|
|
317
300
|
<p>A paragraph.</p>
|
|
318
301
|
~~~
|
|
319
302
|
|
|
320
|
-
## Option
|
|
303
|
+
## Option
|
|
304
|
+
|
|
305
|
+
### Convert one image paragraph without caption
|
|
321
306
|
|
|
322
307
|
Convert one image paragraph without a caption paragraph to figure element.
|
|
323
308
|
|
|
@@ -340,3 +325,67 @@ A paragraph.
|
|
|
340
325
|
</figure>
|
|
341
326
|
<p>A paragraph.</p>
|
|
342
327
|
~~~
|
|
328
|
+
|
|
329
|
+
#### Convert one iframe without caption
|
|
330
|
+
|
|
331
|
+
Convert one iframe without a caption paragraph to iframe element. (adn twitter blockquote embed eelment.)
|
|
332
|
+
|
|
333
|
+
```js
|
|
334
|
+
md.use(mdFigureWithPCaption, {iframeWithoutCaption: true});
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
~~~
|
|
338
|
+
[Markdown]
|
|
339
|
+
<iframe src="https://example.com/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="400" allowfullscreen="allowfullscreen"></iframe><script src="https://exapmle.com/embed.js" async="async"></script>
|
|
340
|
+
[HTML]
|
|
341
|
+
<figure class="f-iframe">
|
|
342
|
+
<iframe src="https://example.com/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="400" allowfullscreen="allowfullscreen"></iframe><script src="https://exapmle.com/embed.js" async="async"></script>
|
|
343
|
+
</figure>
|
|
344
|
+
|
|
345
|
+
[Markdown]
|
|
346
|
+
A paragraph.
|
|
347
|
+
|
|
348
|
+
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/XXXXXXXXXXX" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
|
349
|
+
|
|
350
|
+
A paragraph.
|
|
351
|
+
[HTML]
|
|
352
|
+
<p>A paragraph.</p>
|
|
353
|
+
<figure class="f-video">
|
|
354
|
+
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/XXXXXXXXXXX" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
|
355
|
+
</figure>
|
|
356
|
+
<p>A paragraph.</p>
|
|
357
|
+
|
|
358
|
+
[Markdown]
|
|
359
|
+
<iframe src="https://player.vimeo.com/video/xxxxxxxxxxxxxxx" width="640" height="360" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>
|
|
360
|
+
[HTML]
|
|
361
|
+
<figure class="f-video">
|
|
362
|
+
<iframe src="https://player.vimeo.com/video/xxxxxxxxxxxxxxx" width="640" height="360" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>
|
|
363
|
+
</figure>
|
|
364
|
+
|
|
365
|
+
[Markdown]
|
|
366
|
+
A paragraph. iframeWithoutCaption: true.
|
|
367
|
+
|
|
368
|
+
<blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>— User (@twitter) <a href="https://twitter.com/UserID/status/XXXXX">August 4, 2022</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
|
|
369
|
+
|
|
370
|
+
A paragraph.
|
|
371
|
+
[HTML]
|
|
372
|
+
<p>A paragraph. iframeWithoutCaption: true.</p>
|
|
373
|
+
<figure class="f-iframe">
|
|
374
|
+
<blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>— User (@twitter) <a href="https://twitter.com/UserID/status/XXXXX">August 4, 2022</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
|
|
375
|
+
</figure>
|
|
376
|
+
<p>A paragraph.</p>
|
|
377
|
+
|
|
378
|
+
[Markdown]
|
|
379
|
+
<iframe src="https://example.com/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="400" allowfullscreen="allowfullscreen"></iframe><script src="https://exapmle.com/embed.js" async="async"></script>
|
|
380
|
+
[HTML]
|
|
381
|
+
<figure class="f-iframe">
|
|
382
|
+
<iframe src="https://example.com/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="400" allowfullscreen="allowfullscreen"></iframe><script src="https://exapmle.com/embed.js" async="async"></script>
|
|
383
|
+
</figure>
|
|
384
|
+
|
|
385
|
+
[Markdown]
|
|
386
|
+
<iframe class="speakerdeck-iframe" style="border: 0px none; background: rgba(0, 0, 0, 0.1) padding-box; margin: 0px; padding: 0px; border-radius: 6px; box-shadow: rgba(0, 0, 0, 0.2) 0px 5px 40px; width: 100%; height: auto; aspect-ratio: 560 / 314;" src="https://speakerdeck.com/player/xxxxxxxxxxxxxx" title="xxxxxxxxxxx" allowfullscreen="true" data-ratio="1.78343949044586" frameborder="0"></iframe>
|
|
387
|
+
[HTML]
|
|
388
|
+
<figure class="f-iframe">
|
|
389
|
+
<iframe class="speakerdeck-iframe" style="border: 0px none; background: rgba(0, 0, 0, 0.1) padding-box; margin: 0px; padding: 0px; border-radius: 6px; box-shadow: rgba(0, 0, 0, 0.2) 0px 5px 40px; width: 100%; height: auto; aspect-ratio: 560 / 314;" src="https://speakerdeck.com/player/xxxxxxxxxxxxxx" title="xxxxxxxxxxx" allowfullscreen="true" data-ratio="1.78343949044586" frameborder="0"></iframe>
|
|
390
|
+
</figure>
|
|
391
|
+
~~~
|
package/index.js
CHANGED
|
@@ -14,6 +14,7 @@ module.exports = function figure_with_caption_plugin(md, option) {
|
|
|
14
14
|
strongLabel: false,
|
|
15
15
|
jointSpaceUseHalfWidth: false,
|
|
16
16
|
oneImageWithoutCaption: false,
|
|
17
|
+
iframeWithoutCaption: false,
|
|
17
18
|
removeUnnumberedLabel: false,
|
|
18
19
|
};
|
|
19
20
|
if (option !== undefined) {
|
|
@@ -126,8 +127,12 @@ module.exports = function figure_with_caption_plugin(md, option) {
|
|
|
126
127
|
const figureStartToken = new state.Token('figure_open', 'figure', 1);
|
|
127
128
|
figureStartToken.attrSet('class', 'f-' + tagName);
|
|
128
129
|
if (sp) {
|
|
129
|
-
if (sp.isTwitterBlock
|
|
130
|
-
|
|
130
|
+
if (sp.isTwitterBlock) {
|
|
131
|
+
if (sp.hasImgCaption) {
|
|
132
|
+
figureStartToken.attrSet('class', 'f-img');
|
|
133
|
+
} else {
|
|
134
|
+
figureStartToken.attrSet('class', 'f-iframe');
|
|
135
|
+
}
|
|
131
136
|
}
|
|
132
137
|
}
|
|
133
138
|
if(/pre-(?:code|samp)/.test(tagName)) {
|
|
@@ -236,18 +241,19 @@ module.exports = function figure_with_caption_plugin(md, option) {
|
|
|
236
241
|
let ctj = 0;
|
|
237
242
|
let sp = {};
|
|
238
243
|
while (ctj < tags.length) {
|
|
239
|
-
const hasTag = token.content.match(new RegExp('^<'+ tags[ctj] + ' ?[^>]*?>[\\s\\S]*?<\\/' + tags[ctj] + '> *?(?:<script [^>]*?>(?:</script>)?)
|
|
244
|
+
const hasTag = token.content.match(new RegExp('^<'+ tags[ctj] + ' ?[^>]*?>[\\s\\S]*?<\\/' + tags[ctj] + '> *?(?:<script [^>]*?>(?:</script>)?)?(\\n|$)'));
|
|
240
245
|
if (!hasTag) {
|
|
241
246
|
ctj++;
|
|
242
247
|
continue;
|
|
243
248
|
}
|
|
249
|
+
if (hasTag[hasTag.length - 1] !== '\n') {
|
|
250
|
+
token.content += '\n'
|
|
251
|
+
}
|
|
244
252
|
tagName = tags[ctj];
|
|
245
253
|
if (tagName === 'iframe') {
|
|
246
|
-
if(/^<[^>]*?
|
|
254
|
+
if(/^<[^>]*? src="https:\/\/(?:www.youtube-nocookie.com|player.vimeo.com)\//i.test(token.content)) {
|
|
247
255
|
tagName = 'video'; // figure.f-video used.
|
|
248
256
|
}
|
|
249
|
-
// Non Youtube iframe currently use figure.f-iframe.
|
|
250
|
-
// Class in caption uses actual caption identifier.
|
|
251
257
|
}
|
|
252
258
|
if (tagName === 'blockquote') {
|
|
253
259
|
if(/^<[^>]*? class="twitter-tweet"/.test(token.content)) {
|
|
@@ -255,9 +261,16 @@ module.exports = function figure_with_caption_plugin(md, option) {
|
|
|
255
261
|
if (n > 2) {
|
|
256
262
|
if (state.tokens[n-2].children.length > 1) {
|
|
257
263
|
if (state.tokens[n-2].children[1].attrs.length > 0) {
|
|
258
|
-
if (state.tokens[n-2].children[1].attrs[0][0] === 'class'
|
|
259
|
-
state.tokens[n-2].children[1].attrs[0][1] === 'f-img-label') {
|
|
260
|
-
|
|
264
|
+
if (state.tokens[n-2].children[1].attrs[0][0] === 'class') {
|
|
265
|
+
if (state.tokens[n-2].children[1].attrs[0][1] === 'f-img-label') {
|
|
266
|
+
sp.hasImgCaption = true;
|
|
267
|
+
/* under consideration. I think I should use figure instead of blockquoe for caption.
|
|
268
|
+
} else {
|
|
269
|
+
if (state.tokens[n-2].children[1].attrs[0][1] === 'f-blockquote-label') {
|
|
270
|
+
state.tokens[n-2].children[1].attrs[0][1] = 'f-iframe-label'
|
|
271
|
+
state.tokens[n-2].children[3].attrs[0][1] = 'f-iframe-label-joint'
|
|
272
|
+
} */
|
|
273
|
+
}
|
|
261
274
|
}
|
|
262
275
|
}
|
|
263
276
|
}
|
|
@@ -276,8 +289,11 @@ module.exports = function figure_with_caption_plugin(md, option) {
|
|
|
276
289
|
}
|
|
277
290
|
checkToken = true;
|
|
278
291
|
caption = checkCaption(state, n, en, tagName, caption);
|
|
279
|
-
if (caption.hasPrev || caption.hasNext) {
|
|
292
|
+
if (opt.iframeWithoutCaption || caption.hasPrev || caption.hasNext) {
|
|
280
293
|
range = wrapWithFigure(state, range, tagName, false, sp);
|
|
294
|
+
if (opt.iframeWithoutCaption && (!caption.hasPrev || !caption.hasNext)) {
|
|
295
|
+
n = en + 2;
|
|
296
|
+
}
|
|
281
297
|
break;
|
|
282
298
|
}
|
|
283
299
|
ctj++
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peaceroad/markdown-it-figure-with-p-caption",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "A markdown-it plugin. For a paragraph with only one image, a table or code block or blockquote, and by writing a caption paragraph immediately before or after, they are converted into the figure element with the figcaption element.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -17,6 +17,6 @@
|
|
|
17
17
|
"markdown-it-attrs": "^4.1.4"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"p7d-markdown-it-p-captions": "^0.9.
|
|
20
|
+
"p7d-markdown-it-p-captions": "^0.9.1"
|
|
21
21
|
}
|
|
22
22
|
}
|
package/test/examples.txt
CHANGED
|
@@ -456,15 +456,15 @@ A paragraph.
|
|
|
456
456
|
[Markdown]
|
|
457
457
|
A paragraph.
|
|
458
458
|
|
|
459
|
-
|
|
459
|
+
Source. Twitter Post.
|
|
460
460
|
|
|
461
461
|
<blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>— User (@twitter) <a href="https://twitter.com/UserID/status/XXXXX">August 4, 2022</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
|
|
462
462
|
|
|
463
463
|
A paragraph.
|
|
464
464
|
[HTML]
|
|
465
465
|
<p>A paragraph.</p>
|
|
466
|
-
<figure class="f-
|
|
467
|
-
<figcaption><span class="f-blockquote-label">
|
|
466
|
+
<figure class="f-iframe">
|
|
467
|
+
<figcaption><span class="f-blockquote-label">Source<span class="f-blockquote-label-joint">.</span></span> Twitter Post.</figcaption>
|
|
468
468
|
<blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>— User (@twitter) <a href="https://twitter.com/UserID/status/XXXXX">August 4, 2022</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
|
|
469
469
|
</figure>
|
|
470
470
|
<p>A paragraph.</p>
|
|
@@ -511,7 +511,7 @@ Quote. Twitter Post.
|
|
|
511
511
|
A paragraph.
|
|
512
512
|
[HTML]
|
|
513
513
|
<p>A paragraph.</p>
|
|
514
|
-
<figure class="f-
|
|
514
|
+
<figure class="f-iframe">
|
|
515
515
|
<blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>— User (@twitter) <a href="https://twitter.com/UserID/status/XXXXX">August 4, 2022</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
|
|
516
516
|
<figcaption><span class="f-blockquote-label">Quote<span class="f-blockquote-label-joint">.</span></span> Twitter Post.</figcaption>
|
|
517
517
|
</figure>
|
|
@@ -519,13 +519,13 @@ A paragraph.
|
|
|
519
519
|
|
|
520
520
|
|
|
521
521
|
[Markdown]
|
|
522
|
-
A paragraph.
|
|
522
|
+
A paragraph. 28.
|
|
523
523
|
|
|
524
524
|
<blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>— User (@twitter) <a href="https://twitter.com/UserID/status/XXXXX">August 4, 2022</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
|
|
525
525
|
|
|
526
526
|
A paragraph.
|
|
527
527
|
[HTML]
|
|
528
|
-
<p>A paragraph.</p>
|
|
528
|
+
<p>A paragraph. 28.</p>
|
|
529
529
|
<blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>— User (@twitter) <a href="https://twitter.com/UserID/status/XXXXX">August 4, 2022</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
|
|
530
530
|
<p>A paragraph.</p>
|
|
531
531
|
|
|
@@ -683,3 +683,68 @@ Figure. A Caption.
|
|
|
683
683
|
[HTML]
|
|
684
684
|
<p class="f-img"><span class="f-img-label">Figure<span class="f-img-label-joint">.</span></span> A Caption.</p>
|
|
685
685
|
<p class="style"><img src="cat.jpg" alt="Figure"> Text</p>
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
[Markdown]
|
|
689
|
+
A paragraph.
|
|
690
|
+
|
|
691
|
+
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/XXXXXXXXXXX" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
|
692
|
+
|
|
693
|
+
A paragraph.
|
|
694
|
+
[HTML]
|
|
695
|
+
<p>A paragraph.</p>
|
|
696
|
+
<figure class="f-video">
|
|
697
|
+
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/XXXXXXXXXXX" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
|
698
|
+
</figure>
|
|
699
|
+
<p>A paragraph.</p>
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
[Markdown]
|
|
703
|
+
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/XXXXXXXXXXX" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
|
704
|
+
[HTML]
|
|
705
|
+
<figure class="f-video">
|
|
706
|
+
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/XXXXXXXXXXX" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
|
707
|
+
</figure>
|
|
708
|
+
|
|
709
|
+
[Markdown]
|
|
710
|
+
<iframe src="https://example.com/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="400" allowfullscreen="allowfullscreen"></iframe><script src="https://exapmle.com/embed.js" async="async"></script>
|
|
711
|
+
[HTML]
|
|
712
|
+
<figure class="f-iframe">
|
|
713
|
+
<iframe src="https://example.com/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="400" allowfullscreen="allowfullscreen"></iframe><script src="https://exapmle.com/embed.js" async="async"></script>
|
|
714
|
+
</figure>
|
|
715
|
+
|
|
716
|
+
[Markdown]
|
|
717
|
+
<iframe class="speakerdeck-iframe" style="border: 0px none; background: rgba(0, 0, 0, 0.1) padding-box; margin: 0px; padding: 0px; border-radius: 6px; box-shadow: rgba(0, 0, 0, 0.2) 0px 5px 40px; width: 100%; height: auto; aspect-ratio: 560 / 314;" src="https://speakerdeck.com/player/xxxxxxxxxxxxxx" title="xxxxxxxxxxx" allowfullscreen="true" data-ratio="1.78343949044586" frameborder="0"></iframe>
|
|
718
|
+
[HTML]
|
|
719
|
+
<figure class="f-iframe">
|
|
720
|
+
<iframe class="speakerdeck-iframe" style="border: 0px none; background: rgba(0, 0, 0, 0.1) padding-box; margin: 0px; padding: 0px; border-radius: 6px; box-shadow: rgba(0, 0, 0, 0.2) 0px 5px 40px; width: 100%; height: auto; aspect-ratio: 560 / 314;" src="https://speakerdeck.com/player/xxxxxxxxxxxxxx" title="xxxxxxxxxxx" allowfullscreen="true" data-ratio="1.78343949044586" frameborder="0"></iframe>
|
|
721
|
+
</figure>
|
|
722
|
+
|
|
723
|
+
[Markdown]
|
|
724
|
+
<iframe src="https://player.vimeo.com/video/xxxxxxxxxxxxxxx" width="640" height="360" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>
|
|
725
|
+
<p><a href="https://vimeo.com/xxxx">Title</a> from <a href="https://vimeo.com/yyy">User</a> on <a href="https://vimeo.com">Vimeo</a>.</p>
|
|
726
|
+
[HTML]
|
|
727
|
+
<figure class="f-video">
|
|
728
|
+
<iframe src="https://player.vimeo.com/video/xxxxxxxxxxxxxxx" width="640" height="360" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>
|
|
729
|
+
<p><a href="https://vimeo.com/xxxx">Title</a> from <a href="https://vimeo.com/yyy">User</a> on <a href="https://vimeo.com">Vimeo</a>.</p></figure>
|
|
730
|
+
|
|
731
|
+
[Markdown]
|
|
732
|
+
<iframe src="https://player.vimeo.com/video/xxxxxxxxxxxxxxx" width="640" height="360" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>
|
|
733
|
+
[HTML]
|
|
734
|
+
<figure class="f-video">
|
|
735
|
+
<iframe src="https://player.vimeo.com/video/xxxxxxxxxxxxxxx" width="640" height="360" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>
|
|
736
|
+
</figure>
|
|
737
|
+
|
|
738
|
+
[Markdown]
|
|
739
|
+
A paragraph. iframeWithoutCaption: true.
|
|
740
|
+
|
|
741
|
+
<blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>— User (@twitter) <a href="https://twitter.com/UserID/status/XXXXX">August 4, 2022</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
|
|
742
|
+
|
|
743
|
+
A paragraph.
|
|
744
|
+
[HTML]
|
|
745
|
+
<p>A paragraph. iframeWithoutCaption: true.</p>
|
|
746
|
+
<figure class="f-iframe">
|
|
747
|
+
<blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>— User (@twitter) <a href="https://twitter.com/UserID/status/XXXXX">August 4, 2022</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
|
|
748
|
+
</figure>
|
|
749
|
+
<p>A paragraph.</p>
|
|
750
|
+
|
package/test/test.js
CHANGED
|
@@ -2,6 +2,8 @@ const assert = require('assert');
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const md = require('markdown-it')({ html: true });
|
|
4
4
|
const mdOneImage = require('markdown-it')({ html: true });
|
|
5
|
+
const mdWithoutCaption = require('markdown-it')({ html: true });
|
|
6
|
+
|
|
5
7
|
const mdFigureWithPCaption = require('../index.js');
|
|
6
8
|
|
|
7
9
|
const attrs = require('../node_modules/markdown-it-attrs');
|
|
@@ -20,6 +22,14 @@ mdOneImage.use(mdFigureWithPCaption, {
|
|
|
20
22
|
hasNumClass: true,
|
|
21
23
|
}).use(attrs);
|
|
22
24
|
|
|
25
|
+
mdWithoutCaption.use(mdFigureWithPCaption, {
|
|
26
|
+
dquoteFilename: true,
|
|
27
|
+
strongFilename: true,
|
|
28
|
+
oneImageWithoutCaption: true,
|
|
29
|
+
iframeWithoutCaption: true,
|
|
30
|
+
hasNumClass: true,
|
|
31
|
+
}).use(attrs);
|
|
32
|
+
|
|
23
33
|
const example = __dirname + '/examples.txt';
|
|
24
34
|
const mdPath = __dirname + '/examples.md';
|
|
25
35
|
const exampleCont = fs.readFileSync(example, 'utf-8').trim();
|
|
@@ -52,7 +62,9 @@ while(n < ms.length) {
|
|
|
52
62
|
|
|
53
63
|
const m = ms[n].markdown;
|
|
54
64
|
let h = ''
|
|
55
|
-
if (n >
|
|
65
|
+
if (n > 37) {
|
|
66
|
+
h = mdWithoutCaption.render(m);
|
|
67
|
+
} else if (n > 20) {
|
|
56
68
|
h = mdOneImage.render(m);
|
|
57
69
|
} else {
|
|
58
70
|
h = md.render(m);
|