@peaceroad/markdown-it-figure-with-p-caption 0.6.1 → 0.7.0
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 +9 -7
- package/index.js +78 -83
- package/package.json +3 -1
- package/test/examples-console.txt +94 -0
- package/test/examples-iframe-type-blockquote-without-caption.txt +64 -0
- package/test/examples-iframe-without-caption.txt +4 -25
- package/test/examples-no-option.txt +10 -1
- package/test/test.js +35 -11
package/README.md
CHANGED
|
@@ -4,21 +4,23 @@ This is a markdown-it plugin.
|
|
|
4
4
|
|
|
5
5
|
For a paragraph with one image/images only, a table or code block or a blockquote or a iframe, and by writing a caption paragraph immediately before or after, they are converted into the figure element with the figcaption element.
|
|
6
6
|
|
|
7
|
-
1. Check that the element: one image only paragraph, table, code
|
|
7
|
+
1. Check that the element: one image only paragraph, table, code(samp) block, blockquote, and video, iframe.
|
|
8
8
|
2. Check if this element has a caption paragraph immediately before or after it
|
|
9
9
|
3. If there is the caption paragraph, convert them to figure and figcaption element.
|
|
10
10
|
|
|
11
11
|
The figcaption behavior of this plugin depends on [p7d-markdown-it-p-captions](https://www.npmjs.com/package/p7d-markdown-it-p-captions).
|
|
12
12
|
|
|
13
|
-
Notice.
|
|
13
|
+
**Notice.** Starting with version 0.7, the process changing from code to samp tag has been migrated to [@peaceroad/markdown-it-renderer-fence](https://www.npmjs.com/package/@peaceroad/markdown-it-renderer-fence). If you want to continue processing as before, please use this plugin at the same time.
|
|
14
|
+
(The tests for this plugin and this Readme output used the plugins together.)
|
|
14
15
|
|
|
15
|
-
Notice
|
|
16
|
+
**Notice.** You can also use `markdown-it-attrs` at the same time. However, if there is `{.style}` at the end of a paragraph with only an image, and the next paragraph is a caption, `markdown-it-attrs` alone does not handle it well, so this plugin takes care of that. (This processing is optional `{styleProcess: true}` and can be turned off.) [0.5.0]
|
|
16
17
|
|
|
17
18
|
Use it as follows.
|
|
18
19
|
|
|
19
20
|
```js
|
|
20
21
|
import mdit from 'markdown-it'
|
|
21
22
|
import mditFigureWithPCaption from '@peaceroad/markdown-it-figure-with-p-caption'
|
|
23
|
+
import mditRendererFence from '@peaceroad/markdown-it-renderer-fence' /* to processing code -> smap tag etc. process.*/
|
|
22
24
|
|
|
23
25
|
const md = mdit()
|
|
24
26
|
md.use(mditFigureWithPCaption)
|
|
@@ -467,7 +469,7 @@ A paragraph.
|
|
|
467
469
|
In Markdown documents, captions are often written in the alt attribute of images. If you follow the syntax of this plugin, the commit log will be cluttered. Therefore, as an option, the alt attribute is treated as a caption.
|
|
468
470
|
Note that you cannot use this plugin's syntax and this option's syntax at the same time.
|
|
469
471
|
|
|
470
|
-
|
|
472
|
+
The img alt attribute have an empty value.
|
|
471
473
|
|
|
472
474
|
```js
|
|
473
475
|
const mdImgAltCaption = mdit({html: true}).use(mditFigureWithPCaption, {imgAltCaption: 'Figure'})
|
|
@@ -480,16 +482,16 @@ const mdImgAltCaption = mdit({html: true}).use(mditFigureWithPCaption, {imgAltCa
|
|
|
480
482
|
[HTML]
|
|
481
483
|
<figure class="f-img">
|
|
482
484
|
<figcaption><span class="f-img-label">Figure<span class="f-img-label-joint">.</span></span> A caption.</figcaption>
|
|
483
|
-
<img src="cat.jpg" alt="
|
|
485
|
+
<img src="cat.jpg" alt="">
|
|
484
486
|
</figure>
|
|
485
487
|
```
|
|
486
488
|
|
|
487
489
|
## Option: imgTitleCaption
|
|
488
490
|
|
|
489
491
|
The title attribute of the Markdown img element is used as the caption.
|
|
490
|
-
Note that you cannot use this plugin's syntax and this option's syntax at the same time.
|
|
492
|
+
Note that you cannot use this plugin's standard syntax and this option's syntax at the same time.
|
|
491
493
|
|
|
492
|
-
|
|
494
|
+
The img alt attribute is not specially modified during conversion; the Markdown alt attribute is used as is.
|
|
493
495
|
|
|
494
496
|
```js
|
|
495
497
|
const mdImgAltCaption = mdit({html: true}).use(mditFigureWithPCaption, {imgTitleCaption: 'Figure'})
|
package/index.js
CHANGED
|
@@ -4,6 +4,7 @@ const mditFigureWithPCaption = (md, option) => {
|
|
|
4
4
|
|
|
5
5
|
let opt = {
|
|
6
6
|
classPrefix: 'f',
|
|
7
|
+
styleProcess : true,
|
|
7
8
|
hasNumClass: false,
|
|
8
9
|
scaleSuffix: false,
|
|
9
10
|
dquoteFilename: false,
|
|
@@ -14,10 +15,10 @@ const mditFigureWithPCaption = (md, option) => {
|
|
|
14
15
|
oneImageWithoutCaption: false,
|
|
15
16
|
iframeWithoutCaption: false,
|
|
16
17
|
videoWithoutCaption: false,
|
|
18
|
+
iframeTypeBlockquoteWithoutCaption: false,
|
|
17
19
|
removeUnnumberedLabel: false,
|
|
18
20
|
removeUnnumberedLabelExceptMarks: [],
|
|
19
21
|
multipleImages: true,
|
|
20
|
-
styleProcess: true,
|
|
21
22
|
imgAltCaption: false,
|
|
22
23
|
imgTitleCaption: false,
|
|
23
24
|
};
|
|
@@ -137,21 +138,19 @@ const mditFigureWithPCaption = (md, option) => {
|
|
|
137
138
|
return true;
|
|
138
139
|
}
|
|
139
140
|
|
|
140
|
-
|
|
141
|
+
const wrapWithFigure = (state, range, tagName, caption, replaceInsteadOfWrap, sp) => {
|
|
141
142
|
let n = range.start;
|
|
142
143
|
let en = range.end;
|
|
143
144
|
const figureStartToken = new state.Token('figure_open', 'figure', 1);
|
|
144
145
|
figureStartToken.attrSet('class', 'f-' + tagName);
|
|
145
|
-
if (sp) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (sp.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
} else {
|
|
146
|
+
if (sp.isVideoIframe) {
|
|
147
|
+
figureStartToken.attrSet('class', 'f-video');
|
|
148
|
+
}
|
|
149
|
+
if (sp.isIframeTypeBlockQuote) {
|
|
150
|
+
if (sp.hasImgCaption) {
|
|
151
|
+
figureStartToken.attrSet('class', 'f-img');
|
|
152
|
+
} else {
|
|
153
153
|
figureStartToken.attrSet('class', 'f-iframe');
|
|
154
|
-
}
|
|
155
154
|
}
|
|
156
155
|
}
|
|
157
156
|
if(/pre-(?:code|samp)/.test(tagName)) {
|
|
@@ -160,14 +159,12 @@ const mditFigureWithPCaption = (md, option) => {
|
|
|
160
159
|
const figureEndToken = new state.Token('figure_close', 'figure', -1);
|
|
161
160
|
const breakToken = new state.Token('text', '', 0);
|
|
162
161
|
breakToken.content = '\n';
|
|
163
|
-
if (sp) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
figureStartToken.attrJoin(attr[0], attr[1]);
|
|
167
|
-
}
|
|
162
|
+
if (opt.styleProcess && caption.hasNext && sp.attrs.length > 0) {
|
|
163
|
+
for (let attr of sp.attrs) {
|
|
164
|
+
figureStartToken.attrJoin(attr[0], attr[1]);
|
|
168
165
|
}
|
|
169
166
|
}
|
|
170
|
-
|
|
167
|
+
// For vsce
|
|
171
168
|
if(state.tokens[n].attrs) {
|
|
172
169
|
for (let attr of state.tokens[n].attrs) {
|
|
173
170
|
figureStartToken.attrJoin(attr[0], attr[1]);
|
|
@@ -217,7 +214,12 @@ const mditFigureWithPCaption = (md, option) => {
|
|
|
217
214
|
hasPrev: false,
|
|
218
215
|
hasNext: false,
|
|
219
216
|
};
|
|
220
|
-
|
|
217
|
+
const sp = {
|
|
218
|
+
attrs: [],
|
|
219
|
+
isVideoIframe: false,
|
|
220
|
+
isIframeTypeBlockQuote: false,
|
|
221
|
+
hasImgCaption: false,
|
|
222
|
+
}
|
|
221
223
|
|
|
222
224
|
const checkTags = ['table', 'pre', 'blockquote'];
|
|
223
225
|
let cti = 0;
|
|
@@ -240,7 +242,7 @@ const mditFigureWithPCaption = (md, option) => {
|
|
|
240
242
|
range.end = en;
|
|
241
243
|
caption = checkCaption(state, n, en, tagName, caption);
|
|
242
244
|
if (caption.hasPrev || caption.hasNext) {
|
|
243
|
-
range = wrapWithFigure(state, range, tagName, false);
|
|
245
|
+
range = wrapWithFigure(state, range, tagName, caption, false, sp);
|
|
244
246
|
break;
|
|
245
247
|
}
|
|
246
248
|
break;
|
|
@@ -249,14 +251,19 @@ const mditFigureWithPCaption = (md, option) => {
|
|
|
249
251
|
if(token.type === 'fence') {
|
|
250
252
|
if (token.tag === 'code' && token.block) {
|
|
251
253
|
checkToken = true;
|
|
252
|
-
|
|
253
|
-
|
|
254
|
+
let isSampInfo = false
|
|
255
|
+
if (token.info === 'samp' || token.info === 'shell' || token.info === 'console') {
|
|
254
256
|
token.tag = 'samp';
|
|
257
|
+
isSampInfo = true
|
|
258
|
+
}
|
|
259
|
+
if (isSampInfo) {
|
|
260
|
+
tagName = 'pre-samp';
|
|
261
|
+
} else {
|
|
262
|
+
tagName = 'pre-code';
|
|
255
263
|
}
|
|
256
|
-
tagName = 'pre-' + token.tag;
|
|
257
264
|
caption = checkCaption(state, n, en, tagName, caption);
|
|
258
265
|
if (caption.hasPrev || caption.hasNext) {
|
|
259
|
-
range = wrapWithFigure(state, range, tagName, false);
|
|
266
|
+
range = wrapWithFigure(state, range, tagName, caption, false, sp);
|
|
260
267
|
break;
|
|
261
268
|
}
|
|
262
269
|
}
|
|
@@ -269,64 +276,68 @@ const mditFigureWithPCaption = (md, option) => {
|
|
|
269
276
|
const tags = ['video', 'audio', 'iframe', 'blockquote'];
|
|
270
277
|
let ctj = 0;
|
|
271
278
|
while (ctj < tags.length) {
|
|
272
|
-
const hasTag = token.content.match(new RegExp('^<'+ tags[ctj] + ' ?[^>]*?>[\\s\\S]*?<\\/' + tags[ctj] + '> *?(
|
|
279
|
+
const hasTag = token.content.match(new RegExp('^<'+ tags[ctj] + ' ?[^>]*?>[\\s\\S]*?<\\/' + tags[ctj] + '>(\\n| *?)(<script [^>]*?>(?:<\\/script>)?)?(\\n|$)'));
|
|
273
280
|
if (!hasTag) {
|
|
274
281
|
ctj++;
|
|
275
282
|
continue;
|
|
276
283
|
}
|
|
277
|
-
|
|
284
|
+
//console.log(hasTag)
|
|
285
|
+
if ((hasTag[2] && hasTag[3] !== '\n') ||
|
|
286
|
+
(hasTag[1] !== '\n' && hasTag[2] === undefined)) {
|
|
278
287
|
token.content += '\n'
|
|
279
288
|
}
|
|
280
289
|
tagName = tags[ctj];
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
290
|
+
checkToken = true;
|
|
291
|
+
if (tagName === 'blockquote') {
|
|
292
|
+
//text-post-media: threads
|
|
293
|
+
if(/^<[^>]*? class="(?:twitter-tweet|instagram-media|text-post-media|bluesky-embed)"/.test(token.content)) {
|
|
294
|
+
sp.isIframeTypeBlockQuote = true
|
|
295
|
+
} else {
|
|
296
|
+
ctj++;
|
|
297
|
+
continue;
|
|
284
298
|
}
|
|
285
299
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
if (n + 2 < state.tokens.length) {
|
|
307
|
-
if (state.tokens[n+2].children.length > 1) {
|
|
308
|
-
if (state.tokens[n+2].children[1].attrs.length > 0) {
|
|
309
|
-
if (state.tokens[n+2].children[1].attrs[0][0] === 'class' &&
|
|
310
|
-
state.tokens[n+2].children[1].attrs[0][1] === 'f-img-label') {
|
|
311
|
-
sp.hasImgCaption = true;
|
|
312
|
-
}
|
|
300
|
+
break;
|
|
301
|
+
}
|
|
302
|
+
if (!checkToken) {n++; continue;}
|
|
303
|
+
if (tagName === 'iframe') {
|
|
304
|
+
if(/^<[^>]*? src="https:\/\/(?:www.youtube-nocookie.com|player.vimeo.com)\//i.test(token.content)) {
|
|
305
|
+
sp.isVideoIframe = true
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
if(sp.isIframeTypeBlockQuote) {
|
|
309
|
+
if(n > 2) {
|
|
310
|
+
if (state.tokens[n-2].children.length > 1) {
|
|
311
|
+
if (state.tokens[n-2].children[1].attrs.length > 0) {
|
|
312
|
+
if (state.tokens[n-2].children[1].attrs[0][0] === 'class') {
|
|
313
|
+
if (state.tokens[n-2].children[1].attrs[0][1] === 'f-img-label') {
|
|
314
|
+
sp.hasImgCaption = true;
|
|
315
|
+
/* For now, I think I should use figure instead of blockquoe for caption. */
|
|
313
316
|
}
|
|
314
317
|
}
|
|
315
318
|
}
|
|
316
319
|
}
|
|
317
320
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
321
|
+
if (n + 2 < state.tokens.length) {
|
|
322
|
+
if (state.tokens[n+2].children.length > 1) {
|
|
323
|
+
if (state.tokens[n+2].children[1].attrs.length > 0) {
|
|
324
|
+
if (state.tokens[n+2].children[1].attrs[0][0] === 'class' &&
|
|
325
|
+
state.tokens[n+2].children[1].attrs[0][1] === 'f-img-label') {
|
|
326
|
+
sp.hasImgCaption = true;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
326
329
|
}
|
|
327
|
-
break;
|
|
328
330
|
}
|
|
329
|
-
|
|
331
|
+
}
|
|
332
|
+
caption = checkCaption(state, n, en, tagName, caption);
|
|
333
|
+
if (caption.hasPrev || caption.hasNext) {
|
|
334
|
+
range = wrapWithFigure(state, range, tagName, caption, false, sp);
|
|
335
|
+
n = en + 2;
|
|
336
|
+
} else if ((opt.iframeWithoutCaption && (tagName === 'iframe')) ||
|
|
337
|
+
(opt.videoWithoutCaption && (tagName === 'video')) ||
|
|
338
|
+
(opt.iframeTypeBlockquoteWithoutCaption && (tagName === 'blockquote'))) {
|
|
339
|
+
range = wrapWithFigure(state, range, tagName, caption, false, sp);
|
|
340
|
+
n = en + 2;
|
|
330
341
|
}
|
|
331
342
|
}
|
|
332
343
|
|
|
@@ -417,11 +428,7 @@ const mditFigureWithPCaption = (md, option) => {
|
|
|
417
428
|
}
|
|
418
429
|
if (checkToken && (opt.oneImageWithoutCaption || caption.hasPrev || caption.hasNext)) {
|
|
419
430
|
if (caption.nameSuffix) tagName += caption.nameSuffix
|
|
420
|
-
|
|
421
|
-
range = wrapWithFigure(state, range, tagName, true, sp);
|
|
422
|
-
} else {
|
|
423
|
-
range = wrapWithFigure(state, range, tagName, true);
|
|
424
|
-
}
|
|
431
|
+
range = wrapWithFigure(state, range, tagName, caption, true, sp)
|
|
425
432
|
}
|
|
426
433
|
}
|
|
427
434
|
|
|
@@ -563,18 +570,6 @@ const mditFigureWithPCaption = (md, option) => {
|
|
|
563
570
|
removeUnnumberedLabelExceptMarks: opt.removeUnnumberedLabelExceptMarks,
|
|
564
571
|
})
|
|
565
572
|
md.core.ruler.before('linkify', 'figure_with_caption', figureWithCaption);
|
|
566
|
-
|
|
567
|
-
const token = tokens[idx];
|
|
568
|
-
let sampStartTag = '<samp>';
|
|
569
|
-
if (token.attrs) {
|
|
570
|
-
sampStartTag = sampStartTag.replace('>', '');
|
|
571
|
-
for(let attr of token.attrs) {
|
|
572
|
-
sampStartTag += ' ' + attr[0] + '="' + attr[1] + '"';
|
|
573
|
-
}
|
|
574
|
-
sampStartTag += '>';
|
|
575
|
-
}
|
|
576
|
-
return '<pre>' + sampStartTag + md.utils.escapeHtml(token.content) + '</samp></pre>\n';
|
|
577
|
-
};
|
|
578
|
-
};
|
|
573
|
+
}
|
|
579
574
|
|
|
580
575
|
export default mditFigureWithPCaption
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peaceroad/markdown-it-figure-with-p-caption",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
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
|
"type": "module",
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
"url": "https://github.com/peaceroad/p7d-markdown-it-figure-with-p-caption/issues"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
+
"@peaceroad/markdown-it-renderer-fence": "^0.1.0",
|
|
18
|
+
"highlight.js": "^11.9.0",
|
|
17
19
|
"markdown-it": "^14.1.0",
|
|
18
20
|
"markdown-it-attrs": "^4.1.6"
|
|
19
21
|
},
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
[Markdown]
|
|
2
|
+
```js
|
|
3
|
+
import mdit from 'markdonw-it'
|
|
4
|
+
```
|
|
5
|
+
[HTML]
|
|
6
|
+
<pre><code class="language-js"><span class="hljs-keyword">import</span> mdit <span class="hljs-keyword">from</span> <span class="hljs-string">'markdonw-it'</span>
|
|
7
|
+
</code></pre>
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
[Markdown]
|
|
11
|
+
```html
|
|
12
|
+
<p>I draw <span class="style">cats</span>.</p>
|
|
13
|
+
```
|
|
14
|
+
[HTML]
|
|
15
|
+
<pre><code class="language-html"><span class="hljs-tag"><<span class="hljs-name">p</span>></span>I draw <span class="hljs-tag"><<span class="hljs-name">span</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"style"</span>></span>cats<span class="hljs-tag"></<span class="hljs-name">span</span>></span>.<span class="hljs-tag"></<span class="hljs-name">p</span>></span>
|
|
16
|
+
</code></pre>
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
[Markdown]
|
|
20
|
+
```js
|
|
21
|
+
import mdit from 'markdonw-it'
|
|
22
|
+
const md = mdit()
|
|
23
|
+
md.render('Nyaan')
|
|
24
|
+
```
|
|
25
|
+
[HTML]
|
|
26
|
+
<pre><code class="language-js"><span class="hljs-keyword">import</span> mdit <span class="hljs-keyword">from</span> <span class="hljs-string">'markdonw-it'</span>
|
|
27
|
+
<span class="hljs-keyword">const</span> md = <span class="hljs-title function_">mdit</span>()
|
|
28
|
+
md.<span class="hljs-title function_">render</span>(<span class="hljs-string">'Nyaan'</span>)
|
|
29
|
+
</code></pre>
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
[Markdown]
|
|
33
|
+
```js {.style}
|
|
34
|
+
import mdit from 'markdonw-it'
|
|
35
|
+
const md = mdit()
|
|
36
|
+
md.render('Nyaan')
|
|
37
|
+
```
|
|
38
|
+
[HTML]
|
|
39
|
+
<pre><code class="language-js style"><span class="hljs-keyword">import</span> mdit <span class="hljs-keyword">from</span> <span class="hljs-string">'markdonw-it'</span>
|
|
40
|
+
<span class="hljs-keyword">const</span> md = <span class="hljs-title function_">mdit</span>()
|
|
41
|
+
md.<span class="hljs-title function_">render</span>(<span class="hljs-string">'Nyaan'</span>)
|
|
42
|
+
</code></pre>
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
[Markdown]
|
|
46
|
+
```html {start="2"}
|
|
47
|
+
<p>I draw <span class="style">cats</span>.</p>
|
|
48
|
+
```
|
|
49
|
+
[HTML]
|
|
50
|
+
<pre><code class="language-html" data-pre-start="2" style="counter-set:pre-line-number 2;"><span class="pre-line"><span class="hljs-tag"><<span class="hljs-name">p</span>></span>I draw <span class="hljs-tag"><<span class="hljs-name">span</span> <span class="hljs-attr">class</span>=<span class="hljs-string">"style"</span>></span>cats<span class="hljs-tag"></<span class="hljs-name">span</span>></span>.<span class="hljs-tag"></<span class="hljs-name">p</span>></span></span>
|
|
51
|
+
</code></pre>
|
|
52
|
+
|
|
53
|
+
[Markdown]
|
|
54
|
+
```js {start="1"}
|
|
55
|
+
import mdit from 'markdonw-it'
|
|
56
|
+
```
|
|
57
|
+
[HTML]
|
|
58
|
+
<pre><code class="language-js" data-pre-start="1" style="counter-set:pre-line-number 1;"><span class="pre-line"><span class="hljs-keyword">import</span> mdit <span class="hljs-keyword">from</span> <span class="hljs-string">'markdonw-it'</span></span>
|
|
59
|
+
</code></pre>
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
[Markdown]
|
|
63
|
+
```js {.style start="1"}
|
|
64
|
+
import mdit from 'markdonw-it'
|
|
65
|
+
const md = mdit()
|
|
66
|
+
md.render('Nyaan')
|
|
67
|
+
```
|
|
68
|
+
[HTML]
|
|
69
|
+
<pre><code class="language-js style" data-pre-start="1" style="counter-set:pre-line-number 1;"><span class="pre-line"><span class="hljs-keyword">import</span> mdit <span class="hljs-keyword">from</span> <span class="hljs-string">'markdonw-it'</span></span>
|
|
70
|
+
<span class="pre-line"><span class="hljs-keyword">const</span> md = <span class="hljs-title function_">mdit</span>()</span>
|
|
71
|
+
<span class="pre-line">md.<span class="hljs-title function_">render</span>(<span class="hljs-string">'Nyaan'</span>)</span>
|
|
72
|
+
</code></pre>
|
|
73
|
+
|
|
74
|
+
[Markdown]
|
|
75
|
+
```shell
|
|
76
|
+
$ pwd
|
|
77
|
+
/home/User
|
|
78
|
+
```
|
|
79
|
+
[HTML]
|
|
80
|
+
<pre><samp class="language-shell"><span class="hljs-meta prompt_">$ </span><span class="language-bash"><span class="hljs-built_in">pwd</span></span>
|
|
81
|
+
/home/User
|
|
82
|
+
</samp></pre>
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
[Markdown]
|
|
86
|
+
```samp
|
|
87
|
+
$ pwd
|
|
88
|
+
/home/User
|
|
89
|
+
```
|
|
90
|
+
[HTML]
|
|
91
|
+
<pre><samp>$ pwd
|
|
92
|
+
/home/User
|
|
93
|
+
</samp></pre>
|
|
94
|
+
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
[Markdown]
|
|
2
|
+
A paragraph. iframeTypeBlockquoteWithoutCaption: true.
|
|
3
|
+
|
|
4
|
+
<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>
|
|
5
|
+
|
|
6
|
+
A paragraph.
|
|
7
|
+
[HTML]
|
|
8
|
+
<p>A paragraph. iframeTypeBlockquoteWithoutCaption: true.</p>
|
|
9
|
+
<figure class="f-iframe">
|
|
10
|
+
<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>
|
|
11
|
+
</figure>
|
|
12
|
+
<p>A paragraph.</p>
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
[Markdown]
|
|
16
|
+
<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>
|
|
17
|
+
[HTML]
|
|
18
|
+
<figure class="f-iframe">
|
|
19
|
+
<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>
|
|
20
|
+
</figure>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
[Markdown]
|
|
25
|
+
<iframe src="https://mstdn.social/User/xxxxxxxx/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="400" allowfullscreen="allowfullscreen"></iframe><script src="https://mstdn.social/embed.js" async="async"></script>
|
|
26
|
+
[HTML]
|
|
27
|
+
<figure class="f-iframe">
|
|
28
|
+
<iframe src="https://mstdn.social/User/xxxxxxxx/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="400" allowfullscreen="allowfullscreen"></iframe><script src="https://mstdn.social/embed.js" async="async"></script>
|
|
29
|
+
</figure>
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
[Markdown]
|
|
33
|
+
<blockquote class="text-post-media" data-text-post-permalink="https://www.threads.net/User/post/xxxxxxxxxx" data-text-post-version="0" id="xxxxxx" style=" background:#FFF; border-width: 1px; border-style: solid; border-color: #00000026; border-radius: 16px; max-width:540px; margin: 1px; min-width:270px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);"> <a href="https://www.threads.net/User/post/xxxxxxxxxxxxx" style=" background:#FFFFFF; line-height:0; padding:0 0; text-align:center; text-decoration:none; width:100%; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" target="_blank"> <div style=" padding: 40px; display: flex; flex-direction: column; align-items: center;"><div style=" display:block; height:32px; width:32px; padding-bottom:20px;"> <svg aria-label="Threads" height="32px" role="img" viewBox="0 0 192 192" width="32px" xmlns="http://www.w3.org/2000/svg"> <path /></svg></div> <div style=" font-size: 15px; line-height: 21px; color: #999999; font-weight: 400; padding-bottom: 4px; "> 投稿者: xxxxx</div> <div style=" font-size: 15px; line-height: 21px; color: #000000; font-weight: 600; "> Threadsで見る</div></div></a></blockquote>
|
|
34
|
+
<script async src="https://www.threads.net/embed.js"></script>
|
|
35
|
+
|
|
36
|
+
[HTML]
|
|
37
|
+
<figure class="f-iframe">
|
|
38
|
+
<blockquote class="text-post-media" data-text-post-permalink="https://www.threads.net/User/post/xxxxxxxxxx" data-text-post-version="0" id="xxxxxx" style=" background:#FFF; border-width: 1px; border-style: solid; border-color: #00000026; border-radius: 16px; max-width:540px; margin: 1px; min-width:270px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);"> <a href="https://www.threads.net/User/post/xxxxxxxxxxxxx" style=" background:#FFFFFF; line-height:0; padding:0 0; text-align:center; text-decoration:none; width:100%; font-family: -apple-system, BlinkMacSystemFont, sans-serif;" target="_blank"> <div style=" padding: 40px; display: flex; flex-direction: column; align-items: center;"><div style=" display:block; height:32px; width:32px; padding-bottom:20px;"> <svg aria-label="Threads" height="32px" role="img" viewBox="0 0 192 192" width="32px" xmlns="http://www.w3.org/2000/svg"> <path /></svg></div> <div style=" font-size: 15px; line-height: 21px; color: #999999; font-weight: 400; padding-bottom: 4px; "> 投稿者: xxxxx</div> <div style=" font-size: 15px; line-height: 21px; color: #000000; font-weight: 600; "> Threadsで見る</div></div></a></blockquote>
|
|
39
|
+
<script async src="https://www.threads.net/embed.js"></script>
|
|
40
|
+
</figure>
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
[Markdown]
|
|
44
|
+
<blockquote class="instagram-media" data-instgrm-captioned data-instgrm-permalink="https://www.instagram.com/p/xxxxxxxxxxxxxxxxxxx" data-instgrm-version="14" style=" background:#FFF; border:0; border-radius:3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width:540px; min-width:326px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);"><div style="padding:16px;"> <a href="https://www.instagram.com/p/xxxxxxxxxxxxxxxxxxxxxxx" style=" background:#FFFFFF; line-height:0; padding:0 0; text-align:center; text-decoration:none; width:100%;" target="_blank"> <div style=" display: flex; flex-direction: row; align-items: center;"> <div style="background-color: #F4F4F4; border-radius: 50%; flex-grow: 0; height: 40px; margin-right: 14px; width: 40px;"></div> <div style="display: flex; flex-direction: column; flex-grow: 1; justify-content: center;"> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; margin-bottom: 6px; width: 100px;"></div> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; width: 60px;"></div></div></div><div style="padding: 19% 0;"></div> <div style="display:block; height:50px; margin:0 auto 12px; width:50px;"><svg width="50px" height="50px" viewBox="0 0 60 60" version="1.1" xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink"><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g><g><path></path></g></g></g></svg></div><div style="padding-top: 8px;"> <div style=" color:#3897f0; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:550; line-height:18px;">この投稿をInstagramで見る</div></div><div style="padding: 12.5% 0;"></div> <div style="display: flex; flex-direction: row; margin-bottom: 14px; align-items: center;"><div> <div style="background-color: #F4F4F4; border-radius: 50%; height: 12.5px; width: 12.5px; transform: translateX(0px) translateY(7px);"></div> <div style="background-color: #F4F4F4; height: 12.5px; transform: rotate(-45deg) translateX(3px) translateY(1px); width: 12.5px; flex-grow: 0; margin-right: 14px; margin-left: 2px;"></div> <div style="background-color: #F4F4F4; border-radius: 50%; height: 12.5px; width: 12.5px; transform: translateX(9px) translateY(-18px);"></div></div><div style="margin-left: 8px;"> <div style=" background-color: #F4F4F4; border-radius: 50%; flex-grow: 0; height: 20px; width: 20px;"></div> <div style=" width: 0; height: 0; border-top: 2px solid transparent; border-left: 6px solid #f4f4f4; border-bottom: 2px solid transparent; transform: translateX(16px) translateY(-4px) rotate(30deg)"></div></div><div style="margin-left: auto;"> <div style=" width: 0px; border-top: 8px solid #F4F4F4; border-right: 8px solid transparent; transform: translateY(16px);"></div> <div style=" background-color: #F4F4F4; flex-grow: 0; height: 12px; width: 16px; transform: translateY(-4px);"></div> <div style=" width: 0; height: 0; border-top: 8px solid #F4F4F4; border-left: 8px solid transparent; transform: translateY(-4px) translateX(8px);"></div></div></div> <div style="display: flex; flex-direction: column; flex-grow: 1; justify-content: center; margin-bottom: 24px;"> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; margin-bottom: 6px; width: 224px;"></div> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; width: 144px;"></div></div></a><p style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; line-height:17px; margin-bottom:0; margin-top:8px; overflow:hidden; padding:8px 0 7px; text-align:center; text-overflow:ellipsis; white-space:nowrap;"><a href="https://www.instagram.com/p/xxxxxxxxxxxxxx" style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:normal; line-height:17px; text-decoration:none;" target="_blank">Ueserがシェアした投稿</a></p></div></blockquote>
|
|
45
|
+
<script async src="//www.instagram.com/embed.js"></script>
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
[HTML]
|
|
49
|
+
<figure class="f-iframe">
|
|
50
|
+
<blockquote class="instagram-media" data-instgrm-captioned data-instgrm-permalink="https://www.instagram.com/p/xxxxxxxxxxxxxxxxxxx" data-instgrm-version="14" style=" background:#FFF; border:0; border-radius:3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width:540px; min-width:326px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);"><div style="padding:16px;"> <a href="https://www.instagram.com/p/xxxxxxxxxxxxxxxxxxxxxxx" style=" background:#FFFFFF; line-height:0; padding:0 0; text-align:center; text-decoration:none; width:100%;" target="_blank"> <div style=" display: flex; flex-direction: row; align-items: center;"> <div style="background-color: #F4F4F4; border-radius: 50%; flex-grow: 0; height: 40px; margin-right: 14px; width: 40px;"></div> <div style="display: flex; flex-direction: column; flex-grow: 1; justify-content: center;"> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; margin-bottom: 6px; width: 100px;"></div> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; width: 60px;"></div></div></div><div style="padding: 19% 0;"></div> <div style="display:block; height:50px; margin:0 auto 12px; width:50px;"><svg width="50px" height="50px" viewBox="0 0 60 60" version="1.1" xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink"><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g><g><path></path></g></g></g></svg></div><div style="padding-top: 8px;"> <div style=" color:#3897f0; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:550; line-height:18px;">この投稿をInstagramで見る</div></div><div style="padding: 12.5% 0;"></div> <div style="display: flex; flex-direction: row; margin-bottom: 14px; align-items: center;"><div> <div style="background-color: #F4F4F4; border-radius: 50%; height: 12.5px; width: 12.5px; transform: translateX(0px) translateY(7px);"></div> <div style="background-color: #F4F4F4; height: 12.5px; transform: rotate(-45deg) translateX(3px) translateY(1px); width: 12.5px; flex-grow: 0; margin-right: 14px; margin-left: 2px;"></div> <div style="background-color: #F4F4F4; border-radius: 50%; height: 12.5px; width: 12.5px; transform: translateX(9px) translateY(-18px);"></div></div><div style="margin-left: 8px;"> <div style=" background-color: #F4F4F4; border-radius: 50%; flex-grow: 0; height: 20px; width: 20px;"></div> <div style=" width: 0; height: 0; border-top: 2px solid transparent; border-left: 6px solid #f4f4f4; border-bottom: 2px solid transparent; transform: translateX(16px) translateY(-4px) rotate(30deg)"></div></div><div style="margin-left: auto;"> <div style=" width: 0px; border-top: 8px solid #F4F4F4; border-right: 8px solid transparent; transform: translateY(16px);"></div> <div style=" background-color: #F4F4F4; flex-grow: 0; height: 12px; width: 16px; transform: translateY(-4px);"></div> <div style=" width: 0; height: 0; border-top: 8px solid #F4F4F4; border-left: 8px solid transparent; transform: translateY(-4px) translateX(8px);"></div></div></div> <div style="display: flex; flex-direction: column; flex-grow: 1; justify-content: center; margin-bottom: 24px;"> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; margin-bottom: 6px; width: 224px;"></div> <div style=" background-color: #F4F4F4; border-radius: 4px; flex-grow: 0; height: 14px; width: 144px;"></div></div></a><p style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; line-height:17px; margin-bottom:0; margin-top:8px; overflow:hidden; padding:8px 0 7px; text-align:center; text-overflow:ellipsis; white-space:nowrap;"><a href="https://www.instagram.com/p/xxxxxxxxxxxxxx" style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:normal; line-height:17px; text-decoration:none;" target="_blank">Ueserがシェアした投稿</a></p></div></blockquote>
|
|
51
|
+
<script async src="//www.instagram.com/embed.js"></script>
|
|
52
|
+
</figure>
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
[Markdown]
|
|
56
|
+
<blockquote class="bluesky-embed" data-bluesky-uri="at://did:plc:xxxxxxxxxz/app.bsky.feed.post/xxxxxxxxxxxxxxxxxx" data-bluesky-cid="xxxxxxxxxxxxxxxxxxxxxxxxxx"><p lang="ja">.....<br><br><a href="https://bsky.app/profile/did:plc:xxxxxxxxxxx/post/xxxxxxxxxxxxxx?ref_src=embed">[image or embed]</a></p>— user (<a href="https://bsky.app/profile/did:plc:xxxxxxxxxx?ref_src=embed">user</a>) <a href="https://bsky.app/profile/did:plc:xxxxxxxxxxxx/post/xxxxxxxxxxxx?ref_src=embed">Jun 7, 2024 at 9:49</a></blockquote><script async src="https://embed.bsky.app/static/embed.js" charset="utf-8"></script>
|
|
57
|
+
|
|
58
|
+
[HTML]
|
|
59
|
+
<figure class="f-iframe">
|
|
60
|
+
<blockquote class="bluesky-embed" data-bluesky-uri="at://did:plc:xxxxxxxxxz/app.bsky.feed.post/xxxxxxxxxxxxxxxxxx" data-bluesky-cid="xxxxxxxxxxxxxxxxxxxxxxxxxx"><p lang="ja">.....<br><br><a href="https://bsky.app/profile/did:plc:xxxxxxxxxxx/post/xxxxxxxxxxxxxx?ref_src=embed">[image or embed]</a></p>— user (<a href="https://bsky.app/profile/did:plc:xxxxxxxxxx?ref_src=embed">user</a>) <a href="https://bsky.app/profile/did:plc:xxxxxxxxxxxx/post/xxxxxxxxxxxx?ref_src=embed">Jun 7, 2024 at 9:49</a></blockquote><script async src="https://embed.bsky.app/static/embed.js" charset="utf-8"></script>
|
|
61
|
+
</figure>
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
[Markdown]
|
|
2
|
-
A paragraph.
|
|
2
|
+
A YouTube paragraph.
|
|
3
3
|
|
|
4
4
|
<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>
|
|
5
5
|
|
|
6
6
|
A paragraph.
|
|
7
7
|
[HTML]
|
|
8
|
-
<p>A paragraph.</p>
|
|
8
|
+
<p>A YouTube paragraph.</p>
|
|
9
9
|
<figure class="f-video">
|
|
10
10
|
<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>
|
|
11
11
|
</figure>
|
|
@@ -53,7 +53,8 @@ Slide. A caption.
|
|
|
53
53
|
[HTML]
|
|
54
54
|
<figure class="f-video">
|
|
55
55
|
<iframe src="https://player.vimeo.com/video/xxxxxxxxxxxxxxx" width="640" height="360" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>
|
|
56
|
-
<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
|
|
56
|
+
<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>
|
|
57
|
+
</figure>
|
|
57
58
|
|
|
58
59
|
[Markdown]
|
|
59
60
|
<iframe src="https://player.vimeo.com/video/xxxxxxxxxxxxxxx" width="640" height="360" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>
|
|
@@ -62,25 +63,3 @@ Slide. A caption.
|
|
|
62
63
|
<iframe src="https://player.vimeo.com/video/xxxxxxxxxxxxxxx" width="640" height="360" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>
|
|
63
64
|
</figure>
|
|
64
65
|
|
|
65
|
-
[Markdown]
|
|
66
|
-
A paragraph. iframeWithoutCaption: true.
|
|
67
|
-
|
|
68
|
-
<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>
|
|
69
|
-
|
|
70
|
-
A paragraph.
|
|
71
|
-
[HTML]
|
|
72
|
-
<p>A paragraph. iframeWithoutCaption: true.</p>
|
|
73
|
-
<figure class="f-iframe">
|
|
74
|
-
<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>
|
|
75
|
-
</figure>
|
|
76
|
-
<p>A paragraph.</p>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
[Markdown]
|
|
80
|
-
<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>
|
|
81
|
-
[HTML]
|
|
82
|
-
<figure class="f-iframe">
|
|
83
|
-
<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>
|
|
84
|
-
</figure>
|
|
85
|
-
|
|
86
|
-
|
|
@@ -611,6 +611,16 @@ Figure. A Caption.
|
|
|
611
611
|
<img src="cat.jpg" alt="Figure">
|
|
612
612
|
</figure>
|
|
613
613
|
|
|
614
|
+
[Markdown]
|
|
615
|
+
Figure. A Caption.
|
|
616
|
+
|
|
617
|
+
 {.style #id}
|
|
618
|
+
[HTML]
|
|
619
|
+
<figure class="f-img style" id="id">
|
|
620
|
+
<figcaption><span class="f-img-label">Figure<span class="f-img-label-joint">.</span></span> A Caption.</figcaption>
|
|
621
|
+
<img src="cat.jpg" alt="Figure">
|
|
622
|
+
</figure>
|
|
623
|
+
|
|
614
624
|
|
|
615
625
|
[Markdown]
|
|
616
626
|
 {.style}
|
|
@@ -631,7 +641,6 @@ Figure. A Caption.
|
|
|
631
641
|
<p class="style"><img src="cat.jpg" alt="Figure"> Text</p>
|
|
632
642
|
|
|
633
643
|
|
|
634
|
-
|
|
635
644
|
[Markdown]
|
|
636
645
|
Slide. A caption.
|
|
637
646
|
|
package/test/test.js
CHANGED
|
@@ -2,9 +2,11 @@ import assert from 'assert'
|
|
|
2
2
|
import fs from 'fs'
|
|
3
3
|
import path from 'path'
|
|
4
4
|
import mdit from 'markdown-it'
|
|
5
|
+
import mditAttrs from 'markdown-it-attrs'
|
|
6
|
+
import mditRndererFence from '@peaceroad/markdown-it-renderer-fence'
|
|
5
7
|
|
|
6
8
|
import mdFigureWithPCaption from '../index.js'
|
|
7
|
-
import
|
|
9
|
+
import highlightjs from 'highlight.js'
|
|
8
10
|
|
|
9
11
|
let opt = {
|
|
10
12
|
dquoteFilename: true,
|
|
@@ -13,26 +15,44 @@ let opt = {
|
|
|
13
15
|
iframeWithoutCaption: false,
|
|
14
16
|
videoWithoutCaption: false,
|
|
15
17
|
hasNumClass: false,
|
|
18
|
+
iframeTypeBlockquoteWithoutCaption: false,
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
const md = mdit({ html: true }).use(mdFigureWithPCaption, opt).use(
|
|
21
|
+
const md = mdit({ html: true }).use(mdFigureWithPCaption, opt).use(mditAttrs).use(mditRndererFence);
|
|
19
22
|
|
|
20
23
|
opt.hasNumClass = true
|
|
21
|
-
const mdHasNumClass = mdit({ html: true }).use(mdFigureWithPCaption, opt).use(
|
|
24
|
+
const mdHasNumClass = mdit({ html: true }).use(mdFigureWithPCaption, opt).use(mditAttrs).use(mditRndererFence);
|
|
22
25
|
|
|
23
26
|
opt.hasNumClass = false
|
|
24
27
|
opt.oneImageWithoutCaption = true
|
|
25
|
-
const mdOneImage = mdit({ html: true }).use(mdFigureWithPCaption, opt).use(
|
|
28
|
+
const mdOneImage = mdit({ html: true }).use(mdFigureWithPCaption, opt).use(mditAttrs).use(mditRndererFence);
|
|
26
29
|
|
|
27
30
|
opt.iframeWithoutCaption = true
|
|
28
31
|
opt.hasNumClass = false
|
|
29
|
-
const mdIframeWithoutCaption = mdit({ html: true }).use(mdFigureWithPCaption, opt).use(
|
|
32
|
+
const mdIframeWithoutCaption = mdit({ html: true }).use(mdFigureWithPCaption, opt).use(mditAttrs).use(mditRndererFence);
|
|
33
|
+
|
|
34
|
+
opt.iframeTypeBlockquoteWithoutCaption = true
|
|
35
|
+
const mdIframeTypeBlockquoteWithoutCaption = mdit({ html: true }).use(mdFigureWithPCaption, opt).use(mditAttrs).use(mditRndererFence);
|
|
30
36
|
|
|
31
37
|
opt.multipleImages = true
|
|
32
|
-
const mdMultipleImages = mdit({ html: true }).use(mdFigureWithPCaption, opt).use(
|
|
38
|
+
const mdMultipleImages = mdit({ html: true }).use(mdFigureWithPCaption, opt).use(mditAttrs).use(mditRndererFence);
|
|
33
39
|
|
|
34
40
|
opt.videoWithoutCaption = true
|
|
35
|
-
const mdVideoWithoutCaption = mdit({ html: true }).use(mdFigureWithPCaption, opt).use(
|
|
41
|
+
const mdVideoWithoutCaption = mdit({ html: true }).use(mdFigureWithPCaption, opt).use(mditAttrs).use(mditRndererFence);
|
|
42
|
+
|
|
43
|
+
const mdConsole = mdit({
|
|
44
|
+
html: true,
|
|
45
|
+
langPrefix: 'language-',
|
|
46
|
+
typographer: false,
|
|
47
|
+
highlight: (str, lang) => {
|
|
48
|
+
if (lang && highlightjs.getLanguage(lang)) {
|
|
49
|
+
try {
|
|
50
|
+
return highlightjs.highlight(str, { language: lang }).value
|
|
51
|
+
} catch (__) {}
|
|
52
|
+
}
|
|
53
|
+
return ''
|
|
54
|
+
}
|
|
55
|
+
}).use(mdFigureWithPCaption, opt).use(mditAttrs).use(mditRndererFence);
|
|
36
56
|
|
|
37
57
|
|
|
38
58
|
let __dirname = path.dirname(new URL(import.meta.url).pathname)
|
|
@@ -47,11 +67,13 @@ const testData = {
|
|
|
47
67
|
hasNumClass: __dirname + path.sep + 'examples-has-num-class.txt',
|
|
48
68
|
oneImageWithoutCaption: __dirname + path.sep + 'examples-one-image-without-caption.txt',
|
|
49
69
|
iframeWithoutCaption: __dirname + path.sep + 'examples-iframe-without-caption.txt',
|
|
70
|
+
iframeTypeBlockquoteWithoutCaption: __dirname + path.sep + 'examples-iframe-type-blockquote-without-caption.txt',
|
|
50
71
|
multipleImages: __dirname + path.sep + 'examples-multiple-images.txt',
|
|
51
72
|
videoWithoutCaption: __dirname + path.sep + 'examples-video-without-caption.txt',
|
|
52
73
|
mdAllOption: __dirname + path.sep + 'examples-all-option.txt',
|
|
53
74
|
imgAltCaption: __dirname + path.sep + 'examples-img-alt-caption.txt',
|
|
54
75
|
imgTitleCaption: __dirname + path.sep + 'examples-img-title-caption.txt',
|
|
76
|
+
console: __dirname + path.sep + 'examples-console.txt',
|
|
55
77
|
}
|
|
56
78
|
|
|
57
79
|
const getTestData = (pat) => {
|
|
@@ -133,26 +155,28 @@ pass = runTest(md, testData.noOption, pass)
|
|
|
133
155
|
pass = runTest(mdHasNumClass, testData.hasNumClass, pass)
|
|
134
156
|
pass = runTest(mdOneImage, testData.oneImageWithoutCaption, pass)
|
|
135
157
|
pass = runTest(mdIframeWithoutCaption, testData.iframeWithoutCaption, pass)
|
|
158
|
+
pass = runTest(mdIframeTypeBlockquoteWithoutCaption, testData.iframeTypeBlockquoteWithoutCaption, pass)
|
|
136
159
|
pass = runTest(mdMultipleImages, testData.multipleImages, pass)
|
|
137
160
|
pass = runTest(mdVideoWithoutCaption, testData.videoWithoutCaption, pass)
|
|
161
|
+
pass = runTest(mdConsole, testData.console, pass)
|
|
138
162
|
|
|
139
163
|
|
|
140
164
|
opt.oneImageWithoutCaption = false
|
|
141
165
|
|
|
142
166
|
opt.imgAltCaption = 'Figure'
|
|
143
|
-
const mdImgAltCaption = mdit({html: true}).use(mdFigureWithPCaption, opt).use(
|
|
167
|
+
const mdImgAltCaption = mdit({html: true}).use(mdFigureWithPCaption, opt).use(mditAttrs).use(mditRndererFence);
|
|
144
168
|
pass = runTest(mdImgAltCaption, testData.imgAltCaption, pass, [1, 5])
|
|
145
169
|
opt.imgAltCaption = '図'
|
|
146
|
-
const mdImgAltCaptionJa = mdit({html: true}).use(mdFigureWithPCaption, opt).use(
|
|
170
|
+
const mdImgAltCaptionJa = mdit({html: true}).use(mdFigureWithPCaption, opt).use(mditAttrs).use(mditRndererFence);
|
|
147
171
|
pass = runTest(mdImgAltCaptionJa, testData.imgAltCaption, pass, [6 , 99])
|
|
148
172
|
|
|
149
173
|
opt.imgAltCaption = false
|
|
150
174
|
|
|
151
175
|
opt.imgTitleCaption = 'Figure'
|
|
152
|
-
const mdImgTitleCaption = mdit({html: true}).use(mdFigureWithPCaption, opt).use(
|
|
176
|
+
const mdImgTitleCaption = mdit({html: true}).use(mdFigureWithPCaption, opt).use(mditAttrs).use(mditRndererFence);
|
|
153
177
|
pass = runTest(mdImgTitleCaption, testData.imgTitleCaption, pass, [1, 6])
|
|
154
178
|
opt.imgTitleCaption = '図'
|
|
155
|
-
const mdImgTitleCaptionJa = mdit({html: true}).use(mdFigureWithPCaption, opt).use(
|
|
179
|
+
const mdImgTitleCaptionJa = mdit({html: true}).use(mdFigureWithPCaption, opt).use(mditAttrs).use(mditRndererFence);
|
|
156
180
|
pass = runTest(mdImgTitleCaptionJa, testData.imgTitleCaption, pass, [7, 99])
|
|
157
181
|
|
|
158
182
|
if (pass) console.log('Passed all test.')
|