@peaceroad/markdown-it-figure-with-p-caption 0.6.1 → 0.8.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 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 block, samp block, blockquote, and video, iframe.
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. If code block language setting is "samp", change it to use samp element instead of code element.
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. It assumes simultaneous use of `markdown-it-attrs`. However, if there is `{.style}` at the end of the image-only paragraph, and the next paragraph is a caption, processing is not handled well with `markdown-it-attrs` alone, so in order to normalize it, {} The processing is written in this plugin. (This process can be turned off by specifying `{styleProcess: false}`.) [0.5.0]
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)
@@ -112,7 +114,7 @@ A paragraph.
112
114
 
113
115
  [HTML]
114
116
  <p>A paragraph.</p>
115
- <figure class="f-pre-code" role="doc-example">
117
+ <figure class="f-pre-code">
116
118
  <figcaption><span class="f-pre-code-label">Code<span class="f-pre-code-label-joint">.</span></span> A Caption.</figcaption>
117
119
  <pre><code class="language-js">console.log('Hello World!');
118
120
  </code></pre>
@@ -154,7 +156,7 @@ A paragraph.
154
156
 
155
157
  [HTML]
156
158
  <p>A paragraph.</p>
157
- <figure class="f-pre-samp" role="doc-example">
159
+ <figure class="f-pre-samp">
158
160
  <figcaption><span class="f-pre-samp-label">Terminal<span class="f-pre-samp-label-joint">.</span></span> A Caption.</figcaption>
159
161
  <pre><samp>$ pwd
160
162
  /home/user
@@ -327,7 +329,7 @@ A paragraph.
327
329
 
328
330
  [HTML]
329
331
  <p>A paragraph.</p>
330
- <figure class="f-pre-code" role="doc-example">
332
+ <figure class="f-pre-code">
331
333
  <figcaption><span class="f-pre-code-label">Code<span class="f-pre-code-label-joint">.</span></span> <strong class="f-pre-code-filename">filename.js</strong> Call a cat.</figcaption>
332
334
  <pre><code class="language-js">console.log('Nyaan!');
333
335
  </code></pre>
@@ -356,7 +358,7 @@ A paragraph.
356
358
 
357
359
  [HTML]
358
360
  <p>A paragraph.</p>
359
- <figure class="f-pre-code" role="doc-example">
361
+ <figure class="f-pre-code">
360
362
  <figcaption><span class="f-pre-code-label">Code<span class="f-pre-code-label-joint">.</span></span> <strong class="f-pre-code-filename">filename.js</strong> Call a cat.</figcaption>
361
363
  <pre><code class="language-js">console.log('Nyaan!');
362
364
  </code></pre>
@@ -462,12 +464,12 @@ A paragraph.
462
464
  </figure>
463
465
  ~~~
464
466
 
465
- ## Option: imgAltCaption
467
+ ### Option: imgAltCaption
466
468
 
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
- Also (for now), this is translated into an actual HTML alt attribute with the caption label as its value.
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="Figure">
485
+ <img src="cat.jpg" alt="">
484
486
  </figure>
485
487
  ```
486
488
 
487
- ## Option: imgTitleCaption
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
- Also(for now), the alt attribute is not specially modified during conversion; the Markdown alt attribute is used as is.
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'})
@@ -504,4 +506,12 @@ const mdImgAltCaption = mdit({html: true}).use(mditFigureWithPCaption, {imgTitle
504
506
  <figcaption><span class="f-img-label">Figure<span class="f-img-label-joint">.</span></span> A caption.</figcaption>
505
507
  <img src="cat.jpg" alt="A alt text.">
506
508
  </figure>
507
- ```
509
+ ```
510
+
511
+ ### Option: roleDocExample
512
+
513
+ From version 0.8, role="doc-example" is not included as standard in figure.f-pre-code and figure.f-pre-samp. If necessary, set `roleDocExample: true.`
514
+
515
+ ```js
516
+ const mdImgAltCaption = mdit({html: true}).use(mditFigureWithPCaption, {roleDocExample: true})
517
+ ```
package/index.js CHANGED
@@ -4,6 +4,8 @@ const mditFigureWithPCaption = (md, option) => {
4
4
 
5
5
  let opt = {
6
6
  classPrefix: 'f',
7
+ figureClassThatWrapsIframeTypeBlockquote: 'f-img',
8
+ styleProcess : true,
7
9
  hasNumClass: false,
8
10
  scaleSuffix: false,
9
11
  dquoteFilename: false,
@@ -14,12 +16,13 @@ const mditFigureWithPCaption = (md, option) => {
14
16
  oneImageWithoutCaption: false,
15
17
  iframeWithoutCaption: false,
16
18
  videoWithoutCaption: false,
19
+ iframeTypeBlockquoteWithoutCaption: false,
17
20
  removeUnnumberedLabel: false,
18
21
  removeUnnumberedLabelExceptMarks: [],
19
22
  multipleImages: true,
20
- styleProcess: true,
21
23
  imgAltCaption: false,
22
24
  imgTitleCaption: false,
25
+ roleDocExample: false,
23
26
  };
24
27
  if (option !== undefined) {
25
28
  for (let o in option) {
@@ -137,37 +140,39 @@ const mditFigureWithPCaption = (md, option) => {
137
140
  return true;
138
141
  }
139
142
 
140
- function wrapWithFigure(state, range, tagName, replaceInsteadOfWrap, sp) {
143
+ const wrapWithFigure = (state, range, tagName, caption, replaceInsteadOfWrap, sp) => {
141
144
  let n = range.start;
142
145
  let en = range.end;
143
146
  const figureStartToken = new state.Token('figure_open', 'figure', 1);
144
147
  figureStartToken.attrSet('class', 'f-' + tagName);
145
- if (sp) {
146
- if (sp.isYoutube) {
147
- figureStartToken.attrSet('class', 'f-video');
148
- }
149
- if (sp.isTwitter) {
150
- if (sp.hasImgCaption) {
151
- figureStartToken.attrSet('class', 'f-img');
152
- } else {
153
- figureStartToken.attrSet('class', 'f-iframe');
148
+ if (sp.isVideoIframe) {
149
+ figureStartToken.attrSet('class', 'f-video');
150
+ }
151
+ if (sp.isIframeTypeBlockQuote) {
152
+ let figureClassThatWrapsIframeTypeBlockquote = 'i-frame'
153
+ if (caption.prev || caption.next) {
154
+ if (caption.name === 'img') {
155
+ figureClassThatWrapsIframeTypeBlockquote = 'f-img'
154
156
  }
157
+ figureStartToken.attrSet('class', figureClassThatWrapsIframeTypeBlockquote)
158
+ } else {
159
+ console.log('else::')
160
+ figureClassThatWrapsIframeTypeBlockquote = opt.figureClassThatWrapsIframeTypeBlockquote
161
+ figureStartToken.attrSet('class', figureClassThatWrapsIframeTypeBlockquote)
155
162
  }
156
163
  }
157
- if(/pre-(?:code|samp)/.test(tagName)) {
164
+ if(/pre-(?:code|samp)/.test(tagName) && opt.roleDocExample) {
158
165
  figureStartToken.attrSet('role', 'doc-example');
159
166
  }
160
167
  const figureEndToken = new state.Token('figure_close', 'figure', -1);
161
168
  const breakToken = new state.Token('text', '', 0);
162
169
  breakToken.content = '\n';
163
- if (sp) {
164
- if (sp.attrs) {
165
- for (let attr of sp.attrs) {
166
- figureStartToken.attrJoin(attr[0], attr[1]);
167
- }
170
+ if (opt.styleProcess && caption.hasNext && sp.attrs.length > 0) {
171
+ for (let attr of sp.attrs) {
172
+ figureStartToken.attrJoin(attr[0], attr[1]);
168
173
  }
169
174
  }
170
- ///Add for vsce
175
+ // For vsce
171
176
  if(state.tokens[n].attrs) {
172
177
  for (let attr of state.tokens[n].attrs) {
173
178
  figureStartToken.attrJoin(attr[0], attr[1]);
@@ -217,7 +222,12 @@ const mditFigureWithPCaption = (md, option) => {
217
222
  hasPrev: false,
218
223
  hasNext: false,
219
224
  };
220
- let sp = {attrs: []};
225
+ const sp = {
226
+ attrs: [],
227
+ isVideoIframe: false,
228
+ isIframeTypeBlockQuote: false,
229
+ hasImgCaption: false,
230
+ }
221
231
 
222
232
  const checkTags = ['table', 'pre', 'blockquote'];
223
233
  let cti = 0;
@@ -240,7 +250,7 @@ const mditFigureWithPCaption = (md, option) => {
240
250
  range.end = en;
241
251
  caption = checkCaption(state, n, en, tagName, caption);
242
252
  if (caption.hasPrev || caption.hasNext) {
243
- range = wrapWithFigure(state, range, tagName, false);
253
+ range = wrapWithFigure(state, range, tagName, caption, false, sp);
244
254
  break;
245
255
  }
246
256
  break;
@@ -249,14 +259,19 @@ const mditFigureWithPCaption = (md, option) => {
249
259
  if(token.type === 'fence') {
250
260
  if (token.tag === 'code' && token.block) {
251
261
  checkToken = true;
252
- if (token.info === 'samp') {
253
- token.type = 'fence_samp';
262
+ let isSampInfo = false
263
+ if (/^ *(?:samp|shell|console)(?:(?= )|$)/.test(token.info)) {
254
264
  token.tag = 'samp';
265
+ isSampInfo = true
266
+ }
267
+ if (isSampInfo) {
268
+ tagName = 'pre-samp';
269
+ } else {
270
+ tagName = 'pre-code';
255
271
  }
256
- tagName = 'pre-' + token.tag;
257
272
  caption = checkCaption(state, n, en, tagName, caption);
258
273
  if (caption.hasPrev || caption.hasNext) {
259
- range = wrapWithFigure(state, range, tagName, false);
274
+ range = wrapWithFigure(state, range, tagName, caption, false, sp);
260
275
  break;
261
276
  }
262
277
  }
@@ -269,64 +284,67 @@ const mditFigureWithPCaption = (md, option) => {
269
284
  const tags = ['video', 'audio', 'iframe', 'blockquote'];
270
285
  let ctj = 0;
271
286
  while (ctj < tags.length) {
272
- const hasTag = token.content.match(new RegExp('^<'+ tags[ctj] + ' ?[^>]*?>[\\s\\S]*?<\\/' + tags[ctj] + '> *?(?:<script [^>]*?>(?:</script>)?)?(\\n|$)'));
287
+ const hasTag = token.content.match(new RegExp('^<'+ tags[ctj] + ' ?[^>]*?>[\\s\\S]*?<\\/' + tags[ctj] + '>(\\n| *?)(<script [^>]*?>(?:<\\/script>)?)? *(\\n|$)'));
273
288
  if (!hasTag) {
274
289
  ctj++;
275
290
  continue;
276
291
  }
277
- if (hasTag[hasTag.length - 1] !== '\n') {
292
+ if ((hasTag[2] && hasTag[3] !== '\n') ||
293
+ (hasTag[1] !== '\n' && hasTag[2] === undefined)) {
278
294
  token.content += '\n'
279
295
  }
280
296
  tagName = tags[ctj];
281
- if (tagName === 'iframe') {
282
- if(/^<[^>]*? src="https:\/\/(?:www.youtube-nocookie.com|player.vimeo.com)\//i.test(token.content)) {
283
- sp.isYoutube = true;
297
+ checkToken = true;
298
+ if (tagName === 'blockquote') {
299
+ //text-post-media: threads
300
+ if(/^<[^>]*? class="(?:twitter-tweet|instagram-media|text-post-media|bluesky-embed)"/.test(token.content)) {
301
+ sp.isIframeTypeBlockQuote = true
302
+ } else {
303
+ ctj++;
304
+ continue;
284
305
  }
285
306
  }
286
- if (tagName === 'blockquote') {
287
- if(/^<[^>]*? class="twitter-tweet"/.test(token.content)) {
288
- sp.isTwitter = true;
289
- if (n > 2) {
290
- if (state.tokens[n-2].children.length > 1) {
291
- if (state.tokens[n-2].children[1].attrs.length > 0) {
292
- if (state.tokens[n-2].children[1].attrs[0][0] === 'class') {
293
- if (state.tokens[n-2].children[1].attrs[0][1] === 'f-img-label') {
294
- sp.hasImgCaption = true;
295
- /* under consideration. I think I should use figure instead of blockquoe for caption.
296
- } else {
297
- if (state.tokens[n-2].children[1].attrs[0][1] === 'f-blockquote-label') {
298
- state.tokens[n-2].children[1].attrs[0][1] = 'f-iframe-label'
299
- state.tokens[n-2].children[3].attrs[0][1] = 'f-iframe-label-joint'
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
- }
307
+ break;
308
+ }
309
+ if (!checkToken) {n++; continue;}
310
+ if (tagName === 'iframe') {
311
+ if(/^<[^>]*? src="https:\/\/(?:www.youtube-nocookie.com|player.vimeo.com)\//i.test(token.content)) {
312
+ sp.isVideoIframe = true
313
+ }
314
+ }
315
+ if(sp.isIframeTypeBlockQuote) {
316
+ if(n > 2) {
317
+ if (state.tokens[n-2].children && state.tokens[n-2].children.length > 1) {
318
+ if (state.tokens[n-2].children[1].attrs.length > 0) {
319
+ if (state.tokens[n-2].children[1].attrs[0][0] === 'class') {
320
+ if (state.tokens[n-2].children[1].attrs[0][1] === 'f-img-label') {
321
+ sp.hasImgCaption = true;
322
+ /* For now, I think I should use figure instead of blockquoe for caption. */
313
323
  }
314
324
  }
315
325
  }
316
326
  }
317
327
  }
318
- checkToken = true;
319
- caption = checkCaption(state, n, en, tagName, caption);
320
- if (caption.hasPrev || caption.hasNext ||
321
- (opt.iframeWithoutCaption && (tagName === 'iframe' || sp.isTwitter)) ||
322
- (opt.videoWithoutCaption && tagName === 'video')) {
323
- range = wrapWithFigure(state, range, tagName, false, sp);
324
- if ((opt.videoWithoutCaption || opt.iframeWithoutCaption) && (!caption.hasPrev || !caption.hasNext)) {
325
- n = en + 2;
328
+ if (n + 2 < state.tokens.length) {
329
+ if (state.tokens[n+2].children && state.tokens[n+2].children.length > 1) {
330
+ if (state.tokens[n+2].children[1].attrs.length > 0) {
331
+ if (state.tokens[n+2].children[1].attrs[0][0] === 'class' &&
332
+ state.tokens[n+2].children[1].attrs[0][1] === 'f-img-label') {
333
+ sp.hasImgCaption = true;
334
+ }
335
+ }
326
336
  }
327
- break;
328
337
  }
329
- ctj++
338
+ }
339
+ caption = checkCaption(state, n, en, tagName, caption);
340
+ if (caption.hasPrev || caption.hasNext) {
341
+ range = wrapWithFigure(state, range, tagName, caption, false, sp);
342
+ n = en + 2;
343
+ } else if ((opt.iframeWithoutCaption && (tagName === 'iframe')) ||
344
+ (opt.videoWithoutCaption && (tagName === 'video')) ||
345
+ (opt.iframeTypeBlockquoteWithoutCaption && (tagName === 'blockquote'))) {
346
+ range = wrapWithFigure(state, range, tagName, caption, false, sp);
347
+ n = en + 2;
330
348
  }
331
349
  }
332
350
 
@@ -417,11 +435,7 @@ const mditFigureWithPCaption = (md, option) => {
417
435
  }
418
436
  if (checkToken && (opt.oneImageWithoutCaption || caption.hasPrev || caption.hasNext)) {
419
437
  if (caption.nameSuffix) tagName += caption.nameSuffix
420
- if (caption.hasNext && opt.styleProcess) {
421
- range = wrapWithFigure(state, range, tagName, true, sp);
422
- } else {
423
- range = wrapWithFigure(state, range, tagName, true);
424
- }
438
+ range = wrapWithFigure(state, range, tagName, caption, true, sp)
425
439
  }
426
440
  }
427
441
 
@@ -563,18 +577,6 @@ const mditFigureWithPCaption = (md, option) => {
563
577
  removeUnnumberedLabelExceptMarks: opt.removeUnnumberedLabelExceptMarks,
564
578
  })
565
579
  md.core.ruler.before('linkify', 'figure_with_caption', figureWithCaption);
566
- md.renderer.rules['fence_samp'] = function (tokens, idx, options, env, slf) {
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
- };
580
+ }
579
581
 
580
582
  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.6.1",
3
+ "version": "0.8.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.1",
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,125 @@
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">&#x27;markdonw-it&#x27;</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">&lt;<span class="hljs-name">p</span>&gt;</span>I draw <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;style&quot;</span>&gt;</span>cats<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</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">&#x27;markdonw-it&#x27;</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">&#x27;Nyaan&#x27;</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">&#x27;markdonw-it&#x27;</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">&#x27;Nyaan&#x27;</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">&lt;<span class="hljs-name">p</span>&gt;</span>I draw <span class="hljs-tag">&lt;<span class="hljs-name">span</span> <span class="hljs-attr">class</span>=<span class="hljs-string">&quot;style&quot;</span>&gt;</span>cats<span class="hljs-tag">&lt;/<span class="hljs-name">span</span>&gt;</span>.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</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">&#x27;markdonw-it&#x27;</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">&#x27;markdonw-it&#x27;</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">&#x27;Nyaan&#x27;</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
+
95
+
96
+ [Markdown]
97
+ 端末 現在のディレクトリ
98
+
99
+ ```samp {.style}
100
+ $ pwd
101
+ /home/User
102
+ ```
103
+ [HTML]
104
+ <figure class="f-pre-samp">
105
+ <figcaption><span class="f-pre-samp-label">端末</span> 現在のディレクトリ</figcaption>
106
+ <pre><samp class="style">$ pwd
107
+ /home/User
108
+ </samp></pre>
109
+ </figure>
110
+
111
+
112
+ [Markdown]
113
+ 端末 現在のディレクトリ
114
+
115
+ ```console {.style}
116
+ $ pwd
117
+ /home/User
118
+ ```
119
+ [HTML]
120
+ <figure class="f-pre-samp">
121
+ <figcaption><span class="f-pre-samp-label">端末</span> 現在のディレクトリ</figcaption>
122
+ <pre><samp class="language-console style"><span class="hljs-meta prompt_">$ </span><span class="language-bash"><span class="hljs-built_in">pwd</span></span>
123
+ /home/User
124
+ </samp></pre>
125
+ </figure>
@@ -23,7 +23,7 @@ A paragraph.
23
23
 
24
24
  [HTML]
25
25
  <p>A paragraph.</p>
26
- <figure class="f-pre-code" role="doc-example">
26
+ <figure class="f-pre-code">
27
27
  <figcaption><span class="f-pre-code-label label-has-num">リスト1</span> キャプション</figcaption>
28
28
  <pre><code class="language-js">console.log('Nyaan!');
29
29
  </code></pre>
@@ -0,0 +1,92 @@
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>&mdash; 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-img">
10
+ <blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>&mdash; 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>&mdash; 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-img">
19
+ <blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>&mdash; 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
+ [Markdown]
24
+ <blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>&mdash; 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>
25
+
26
+ <blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>&mdash; 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>
27
+ [HTML]
28
+ <figure class="f-img">
29
+ <blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>&mdash; 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>
30
+ </figure>
31
+ <figure class="f-img">
32
+ <blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>&mdash; 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>
33
+ </figure>
34
+
35
+
36
+
37
+ [Markdown]
38
+ <blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>&mdash; 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>
39
+
40
+ <!-- -->
41
+
42
+ <blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>&mdash; 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>
43
+ [HTML]
44
+ <figure class="f-img">
45
+ <blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>&mdash; 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>
46
+ </figure>
47
+ <!-- -->
48
+ <figure class="f-img">
49
+ <blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>&mdash; 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>
50
+ </figure>
51
+
52
+ [Markdown]
53
+ <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>
54
+ [HTML]
55
+ <figure class="f-iframe">
56
+ <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>
57
+ </figure>
58
+
59
+
60
+ [Markdown]
61
+ <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>
62
+ <script async src="https://www.threads.net/embed.js"></script>
63
+
64
+ [HTML]
65
+ <figure class="f-img">
66
+ <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>
67
+ <script async src="https://www.threads.net/embed.js"></script>
68
+ </figure>
69
+
70
+
71
+ [Markdown]
72
+ <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>
73
+ <script async src="//www.instagram.com/embed.js"></script>
74
+
75
+
76
+ [HTML]
77
+ <figure class="f-img">
78
+ <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>
79
+ <script async src="//www.instagram.com/embed.js"></script>
80
+ </figure>
81
+
82
+
83
+ [Markdown]
84
+ <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>&mdash; 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>
85
+
86
+ [HTML]
87
+ <figure class="f-img">
88
+ <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>&mdash; 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>
89
+ </figure>
90
+
91
+
92
+
@@ -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></figure>
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>
@@ -61,26 +62,3 @@ Slide. A caption.
61
62
  <figure class="f-video">
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
- [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>&mdash; 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>&mdash; 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>&mdash; 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>&mdash; 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
-
@@ -186,7 +186,7 @@ A paragraph.
186
186
 
187
187
  [HTML]
188
188
  <p>A paragraph.</p>
189
- <figure class="f-pre-code" role="doc-example">
189
+ <figure class="f-pre-code">
190
190
  <figcaption><span class="f-pre-code-label">Code<span class="f-pre-code-label-joint">.</span></span> A Caption.</figcaption>
191
191
  <pre><code class="language-js">console.log('Hello World!');
192
192
  </code></pre>
@@ -207,7 +207,7 @@ A paragraph.
207
207
 
208
208
  [HTML]
209
209
  <p>A paragraph.</p>
210
- <figure class="f-pre-code" role="doc-example">
210
+ <figure class="f-pre-code">
211
211
  <pre><code class="language-js">console.log('Hello World!');
212
212
  </code></pre>
213
213
  <figcaption><span class="f-pre-code-label">Code<span class="f-pre-code-label-joint">.</span></span> A Caption.</figcaption>
@@ -228,7 +228,7 @@ A paragraph.
228
228
 
229
229
  [HTML]
230
230
  <p>A paragraph.</p>
231
- <figure class="f-pre-samp" role="doc-example">
231
+ <figure class="f-pre-samp">
232
232
  <figcaption><span class="f-pre-samp-label">Terminal<span class="f-pre-samp-label-joint">.</span></span> A Caption.</figcaption>
233
233
  <pre><samp>$ pwd
234
234
  /home/user
@@ -250,7 +250,7 @@ Terminal. A Caption.
250
250
  A paragraph.
251
251
  [HTML]
252
252
  <p>A paragraph.</p>
253
- <figure class="f-pre-samp" role="doc-example">
253
+ <figure class="f-pre-samp">
254
254
  <pre><samp>$ pwd
255
255
  /home/user
256
256
  </samp></pre>
@@ -452,7 +452,7 @@ Source. Twitter Post.
452
452
  A paragraph.
453
453
  [HTML]
454
454
  <p>A paragraph.</p>
455
- <figure class="f-iframe">
455
+ <figure class="f-img">
456
456
  <figcaption><span class="f-blockquote-label">Source<span class="f-blockquote-label-joint">.</span></span> Twitter Post.</figcaption>
457
457
  <blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>&mdash; 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>
458
458
  </figure>
@@ -500,7 +500,7 @@ Quote. Twitter Post.
500
500
  A paragraph.
501
501
  [HTML]
502
502
  <p>A paragraph.</p>
503
- <figure class="f-iframe">
503
+ <figure class="f-img">
504
504
  <blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>&mdash; 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>
505
505
  <figcaption><span class="f-blockquote-label">Quote<span class="f-blockquote-label-joint">.</span></span> Twitter Post.</figcaption>
506
506
  </figure>
@@ -533,7 +533,7 @@ A paragraph.
533
533
 
534
534
  [HTML]
535
535
  <p>A paragraph.</p>
536
- <figure class="f-pre-code" role="doc-example">
536
+ <figure class="f-pre-code">
537
537
  <figcaption><span class="f-pre-code-label">Code<span class="f-pre-code-label-joint">.</span></span> <strong class="f-pre-code-filename">filename.js</strong> Call a cat.</figcaption>
538
538
  <pre><code class="language-js">console.log('Nyaan!');
539
539
  </code></pre>
@@ -553,7 +553,7 @@ A paragraph.
553
553
 
554
554
  [HTML]
555
555
  <p>A paragraph.</p>
556
- <figure class="f-pre-code" role="doc-example">
556
+ <figure class="f-pre-code">
557
557
  <figcaption><span class="f-pre-code-label">Code<span class="f-pre-code-label-joint">.</span></span> <strong class="f-pre-code-filename">filename.js</strong> Call a cat.</figcaption>
558
558
  <pre><code class="language-js">console.log('Nyaan!');
559
559
  </code></pre>
@@ -573,7 +573,7 @@ A paragraph.
573
573
 
574
574
  [HTML]
575
575
  <p>A paragraph.</p>
576
- <figure class="f-pre-code" role="doc-example">
576
+ <figure class="f-pre-code">
577
577
  <figcaption><span class="f-pre-code-label">Code<span class="f-pre-code-label-joint">.</span></span> <strong class="f-pre-code-filename">filename.js</strong></figcaption>
578
578
  <pre><code class="language-js">console.log('Nyaan!');
579
579
  </code></pre>
@@ -593,7 +593,7 @@ A paragraph.
593
593
 
594
594
  [HTML]
595
595
  <p>A paragraph.</p>
596
- <figure class="f-pre-code" role="doc-example">
596
+ <figure class="f-pre-code">
597
597
  <figcaption><span class="f-pre-code-label">Code<span class="f-pre-code-label-joint">.</span></span> <strong class="f-pre-code-filename">filename.js</strong></figcaption>
598
598
  <pre><code class="language-js">console.log('Nyaan!');
599
599
  </code></pre>
@@ -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
+ ![Figure](cat.jpg) {.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
  ![Figure](cat.jpg) {.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
 
@@ -653,3 +662,13 @@ Slide. A caption.
653
662
  </video>
654
663
 
655
664
 
665
+ [Markdown]
666
+ 図 キャプション
667
+
668
+ <blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>&mdash; 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>
669
+ [HTML]
670
+ <figure class="f-img">
671
+ <figcaption><span class="f-img-label">図</span> キャプション</figcaption>
672
+ <blockquote class="twitter-tweet"><p lang="ja" dir="ltr">XXXXX <a href="https://t.co/XXXXX">https://t.co/XXXXX</a></p>&mdash; 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>
673
+ </figure>
674
+
@@ -9,3 +9,44 @@
9
9
  </video>
10
10
  </figure>
11
11
 
12
+ [Markdown]
13
+ Video. A caption.
14
+
15
+ <video controls width="400" height="300">
16
+ <source src="example.mp4" type="video/mp4">
17
+ </video>
18
+ [HTML]
19
+ <figure class="f-video">
20
+ <figcaption><span class="f-video-label">Video<span class="f-video-label-joint">.</span></span> A caption.</figcaption>
21
+ <video controls width="400" height="300">
22
+ <source src="example.mp4" type="video/mp4">
23
+ </video>
24
+ </figure>
25
+
26
+
27
+ [Markdown]
28
+ A YouTube paragraph.
29
+
30
+ <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>
31
+
32
+ A paragraph.
33
+ [HTML]
34
+ <p>A YouTube paragraph.</p>
35
+ <figure class="f-video">
36
+ <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>
37
+ </figure>
38
+ <p>A paragraph.</p>
39
+
40
+
41
+ [Markdown]
42
+ Video. A YouTube caption.
43
+
44
+ <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>
45
+
46
+ A paragraph.
47
+ [HTML]
48
+ <figure class="f-video">
49
+ <figcaption><span class="f-video-label">Video<span class="f-video-label-joint">.</span></span> A YouTube caption.</figcaption>
50
+ <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>
51
+ </figure>
52
+ <p>A paragraph.</p>
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 attrs from 'markdown-it-attrs'
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(attrs);
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(attrs);
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(attrs);
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(attrs);
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(attrs)
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(attrs)
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(attrs)
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(attrs)
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(attrs)
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(attrs)
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.')