@peaceroad/markdown-it-strong-ja 0.3.3 → 0.3.4
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/index.js +16 -14
- package/package.json +1 -1
- package/test/example-complex.txt +79 -1
- package/test/test.js +1 -1
package/index.js
CHANGED
|
@@ -235,9 +235,9 @@ const setStrong = (inlines, marks, n, memo) => {
|
|
|
235
235
|
if (i > inlines.length - 1) return n, nest, memo
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
+
//console.log('memo.html: ' + memo.html + 'insideTagsIsClose: ' + insideTagsIsClose + 'inlines[i].len: ' + inlines[i].len)
|
|
238
239
|
if (memo.html && !insideTagsIsClose && inlines[i].len !== 1) {
|
|
239
|
-
|
|
240
|
-
return n, nest, memo
|
|
240
|
+
i++; continue
|
|
241
241
|
}
|
|
242
242
|
let strongNum = Math.trunc(Math.min(inlines[n].len, inlines[i].len) / 2)
|
|
243
243
|
|
|
@@ -258,7 +258,8 @@ const setStrong = (inlines, marks, n, memo) => {
|
|
|
258
258
|
if (inlines[n].len === 0) return n, nest, memo
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
|
|
261
|
+
//console.log('len: ', inlines[n].len, inlines[i].len)
|
|
262
|
+
if ((inlines[n].len > 0 && inlines[i] === 1) || (inlines[n].len === 1 && inlines[i].len > 0)) {
|
|
262
263
|
//console.log('check em that warp strong.')
|
|
263
264
|
nest++
|
|
264
265
|
n, nest, memo = setEm(inlines, marks, n, memo, nest)
|
|
@@ -345,8 +346,7 @@ const setEm = (inlines, marks, n, memo, sNest) => {
|
|
|
345
346
|
if (emNum === 1) {
|
|
346
347
|
//console.log(n, i, 'insideTagsIsClose: ' + insideTagsIsClose)
|
|
347
348
|
if (memo.html && !insideTagsIsClose && inlines[i].len !== 2) {
|
|
348
|
-
|
|
349
|
-
return n, nest, memo
|
|
349
|
+
i++; continue;
|
|
350
350
|
}
|
|
351
351
|
//console.log('n: ' + n + ' [em]: normal push, nest: ' + nest)
|
|
352
352
|
//console.log('strongPNum: ' + strongPNum)
|
|
@@ -391,6 +391,7 @@ const checkNest = (inlines, marks, n, i) => {
|
|
|
391
391
|
let strongNest = 0
|
|
392
392
|
let emNest = 0
|
|
393
393
|
let j = 0
|
|
394
|
+
//console.log(inlines)
|
|
394
395
|
//console.log(marks)
|
|
395
396
|
//console.log('n: ' + n + ', i: ' + i + ', inlines[n].s: ' + inlines[n].s + ', inlines[i].s: ' + inlines[i].s)
|
|
396
397
|
while (j < marks.length) {
|
|
@@ -408,10 +409,16 @@ const checkNest = (inlines, marks, n, i) => {
|
|
|
408
409
|
if (parentCloseN < marks.length) {
|
|
409
410
|
while (parentCloseN < marks.length) {
|
|
410
411
|
if (marks[parentCloseN].nest === parentNest) break
|
|
412
|
+
//if (marks.length - 1 == parentCloseN) break
|
|
411
413
|
parentCloseN++
|
|
412
414
|
}
|
|
413
|
-
//console.log(parentCloseN
|
|
414
|
-
if (marks
|
|
415
|
+
//console.log('parentCloseN: ' + parentCloseN)
|
|
416
|
+
if (parentCloseN > marks.length - 1) {
|
|
417
|
+
isRange = true
|
|
418
|
+
} else {
|
|
419
|
+
//console.log(marks[parentCloseN].s, i, inlines[i].s)
|
|
420
|
+
if (marks[parentCloseN].s < inlines[i].s) isRange = false
|
|
421
|
+
}
|
|
415
422
|
}
|
|
416
423
|
//console.log('isRange: ' + isRange)
|
|
417
424
|
|
|
@@ -431,13 +438,13 @@ const createMarks = (inlines, start, end, memo) => {
|
|
|
431
438
|
memo.isEm = inlines[n].len === 1 ? true : false
|
|
432
439
|
memo.wrapEm = 0
|
|
433
440
|
let nest = 0
|
|
434
|
-
|
|
441
|
+
//console.log('n: ' + n + ' ----- inlines.length: ' + inlines.length + ', memo.isEm: ' + memo.isEm)
|
|
435
442
|
if (!memo.isEm) {
|
|
436
443
|
n, nest, memo = setStrong(inlines, marks, n, memo)
|
|
437
444
|
}
|
|
438
445
|
n, nest, memo = setEm(inlines, marks, n, memo)
|
|
439
|
-
|
|
440
446
|
if (inlines[n].len !== 0) setText(inlines, marks, n, nest)
|
|
447
|
+
//console.log(marks)
|
|
441
448
|
n++
|
|
442
449
|
}
|
|
443
450
|
return marks
|
|
@@ -503,11 +510,6 @@ const strongJa = (state, silent, opt) => {
|
|
|
503
510
|
inlineMarkStart: state.src.charCodeAt(0) === 0x2A ? true : false,
|
|
504
511
|
inlineMarkEnd: state.src.charCodeAt(max - 1) === 0x2A ? true : false,
|
|
505
512
|
}
|
|
506
|
-
/*
|
|
507
|
-
if (memo.html) {
|
|
508
|
-
let beforeInlines = createInlines(state, 0, start - 1, opt)
|
|
509
|
-
isJumpTag(beforeInlines, beforeInlines.length - 1, memo)
|
|
510
|
-
}*/
|
|
511
513
|
let marks = createMarks(inlines, 0, inlines.length, memo)
|
|
512
514
|
//console.log('marks: ')
|
|
513
515
|
//console.log(marks)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peaceroad/markdown-it-strong-ja",
|
|
3
3
|
"description": "This is a plugin for markdown-it. It is an alternative to the standard `**` (strong) and `*` (em) processing. It also processes strings that cannot be converted by the standard.",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.4",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
package/test/example-complex.txt
CHANGED
|
@@ -191,7 +191,7 @@ z*a<span>b*c</span>d*e
|
|
|
191
191
|
[HTML]
|
|
192
192
|
<p>z<em>a<span>b</em>c</span>d*e</p>
|
|
193
193
|
[HTML:true]
|
|
194
|
-
<p>z
|
|
194
|
+
<p>z<em>a<span>b*c</span>d</em>e</p>
|
|
195
195
|
|
|
196
196
|
[Markdown]
|
|
197
197
|
a<span>b*c</span>d*e*f
|
|
@@ -258,3 +258,81 @@ aa<span>b*e<s>f</s>*</span>cc
|
|
|
258
258
|
<p><em>aa<span>b<strong>e<s>f</s></strong></span>cc</em></p>
|
|
259
259
|
[HTML:true]
|
|
260
260
|
<p><em>aa<span>b<strong>e<s>f</s></strong></span>cc</em></p>
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
[Markdown]
|
|
264
|
+
*ab
|
|
265
|
+
[HTML]
|
|
266
|
+
<p>*ab</p>
|
|
267
|
+
[HTML:true]
|
|
268
|
+
<p>*ab</p>
|
|
269
|
+
|
|
270
|
+
[Markdown]
|
|
271
|
+
*a<span>b</span>
|
|
272
|
+
[HTML]
|
|
273
|
+
<p>*a<span>b</span></p>
|
|
274
|
+
[HTML:true]
|
|
275
|
+
<p>*a<span>b</span></p>
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
[Markdown]
|
|
279
|
+
bc*
|
|
280
|
+
[HTML]
|
|
281
|
+
<p>bc*</p>
|
|
282
|
+
[HTML:true]
|
|
283
|
+
<p>bc*</p>
|
|
284
|
+
|
|
285
|
+
[Markdown]
|
|
286
|
+
b<span>c</span>*
|
|
287
|
+
[HTML]
|
|
288
|
+
<p>b<span>c</span>*</p>
|
|
289
|
+
[HTML:true]
|
|
290
|
+
<p>b<span>c</span>*</p>
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
[Markdown]
|
|
294
|
+
***a***
|
|
295
|
+
[HTML]
|
|
296
|
+
<p><em><strong>a</strong></em></p>
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
[Markdown]
|
|
300
|
+
****a***
|
|
301
|
+
[HTML]
|
|
302
|
+
<p>*<em><strong>a</strong></em></p>
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
[Markdown]
|
|
306
|
+
***a****
|
|
307
|
+
[HTML]
|
|
308
|
+
<p><em><strong>a</strong></em>*</p>
|
|
309
|
+
|
|
310
|
+
[Markdown]
|
|
311
|
+
*****a***
|
|
312
|
+
[HTML]
|
|
313
|
+
<p>**<em><strong>a</strong></em></p>
|
|
314
|
+
|
|
315
|
+
[Markdown]
|
|
316
|
+
*****a*****
|
|
317
|
+
[HTML]
|
|
318
|
+
<p><em><strong><strong>a</strong></strong></em></p>
|
|
319
|
+
|
|
320
|
+
[Markdown]
|
|
321
|
+
******a******
|
|
322
|
+
[HTML]
|
|
323
|
+
<p><strong><strong><strong>a</strong></strong></strong></p>
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
[Markdown]
|
|
327
|
+
***a*b*
|
|
328
|
+
[HTML]
|
|
329
|
+
<p>*<em><em>a</em>b</em></p>
|
|
330
|
+
|
|
331
|
+
[Markdown]
|
|
332
|
+
***<span>a</span>*b*
|
|
333
|
+
[HTML]
|
|
334
|
+
<p>*<em><em><span>a</span></em>b</em></p>
|
|
335
|
+
[HTML: true]
|
|
336
|
+
<p>*<em><em><span>a</span></em>b</em></p>
|
|
337
|
+
|
|
338
|
+
|
package/test/test.js
CHANGED
|
@@ -14,7 +14,7 @@ const check = (ms, example) => {
|
|
|
14
14
|
const mdWithHtml = mdit({html: true}).use(mditStrongJa).use(mditAttrs)
|
|
15
15
|
let n = 1
|
|
16
16
|
while (n < ms.length) {
|
|
17
|
-
//if (n !==
|
|
17
|
+
//if (n !== 23 ) { n++; continue }
|
|
18
18
|
//if (n !== 36 ) { n++; continue }
|
|
19
19
|
const m = ms[n].markdown
|
|
20
20
|
console.log('Test [' + n + ', HTML: false] >>>')
|