@peaceroad/markdown-it-strong-ja 0.3.2 → 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 CHANGED
@@ -12,7 +12,7 @@ const hasBackslash = (state, start) => {
12
12
  const setToken = (state, inlines) => {
13
13
  let i = 0
14
14
  while (i < inlines.length) {
15
- const type = inlines[i].type
15
+ let type = inlines[i].type
16
16
  const tag = type.replace(/(?:_open|_close)$/, '')
17
17
 
18
18
  if (/_open$/.test(type)) {
@@ -20,19 +20,22 @@ const setToken = (state, inlines) => {
20
20
  startToken.markup = tag === 'strong' ? '**' : '*'
21
21
  }
22
22
 
23
+ if (type === 'html_inline') {
24
+ type = 'text'
25
+ }
23
26
  if (type === 'text') {
24
27
  const content = state.src.slice(inlines[i].s, inlines[i].e + 1)
25
28
  if (/^\**$/.test(content)) {
26
29
  //console.log('asterisk process::')
27
30
  const asteriskToken = state.push(type, '', 0)
28
31
  asteriskToken.content = content
29
- //console.log('asteriskToken: ' + asteriskToken.content)
30
32
  i++
31
33
  continue
32
34
  }
33
- const childTokens = state.md.parseInline(content, state.env)
34
35
 
36
+ const childTokens = state.md.parseInline(content, state.env)
35
37
  if (childTokens[0] && childTokens[0].children) {
38
+ //console.log(state.tokens)
36
39
  //console.log(state.tokens[state.tokens.length - 1])
37
40
  state.tokens[state.tokens.length - 1].children = childTokens[0].children
38
41
  childTokens[0].children.forEach(t => {
@@ -50,25 +53,6 @@ const setToken = (state, inlines) => {
50
53
  token.hidden = t.hidden
51
54
  })
52
55
  }
53
- //console.log(childTokens[0].children)
54
- /*
55
- if (childTokens[0] && childTokens[0].children) {
56
- state.tokens[state.tokens.length - 1].children = childTokens[0].children
57
- childTokens[0].children.forEach(t => {
58
- //console.log('t.type: ' + t.type + ', t.tag: ' + t.tag + ', t.nesting: ' + t.nesting)
59
- const token = state.push(t.type, t.tag, t.nesting)
60
- token.attrs = t.attrs
61
- token.map = t.map
62
- token.level = t.level
63
- token.children = t.children
64
- token.content = t.content
65
- token.markup = t.markup
66
- token.info = t.info
67
- token.meta = t.meta
68
- token.block = t.block
69
- token.hidden = t.hidden
70
- })
71
- }*/
72
56
  }
73
57
 
74
58
  if (/_close$/.test(type)) {
@@ -80,62 +64,113 @@ const setToken = (state, inlines) => {
80
64
  }
81
65
  }
82
66
 
83
- const inlinesPush = (inlines, s, e, len, type) => {
84
- inlines.push({
67
+ const inlinesPush = (inlines, s, e, len, type, tag, tagType) => {
68
+ const inline = {
85
69
  s: s,
86
70
  sp: s,
87
71
  e: e,
88
72
  ep: e,
89
73
  len: len,
90
74
  type: type,
91
- })
75
+ }
76
+ if (tag) inline.tag = [tag, tagType]
77
+ inlines.push(inline)
78
+ }
79
+
80
+ const hasNextSymbol = (state, n, max, symbol, noMark) => {
81
+ let nextSymbolPos = -1
82
+ if (state.src.charCodeAt(n) === symbol && !hasBackslash(state, n)) {
83
+ let i = n + 1
84
+ let tempNoMark = noMark
85
+ while (i < max) {
86
+ tempNoMark += state.src[i]
87
+ if (state.src.charCodeAt(i) === symbol && !hasBackslash(state, i)) {
88
+ noMark += state.src[n]
89
+ nextSymbolPos = i
90
+ break
91
+ }
92
+ i++
93
+ }
94
+ }
95
+ return nextSymbolPos
92
96
  }
93
97
 
94
98
  const createInlines = (state, start, max, opt) => {
95
99
  let n = start
96
100
  let inlines = []
97
101
  let noMark = ''
98
- let mark = ''
99
- let isInCode = false
100
- let isInMath = false
101
- let beforeIsMark = true
102
+ let isInStartMark = true
103
+ let textStart = n
104
+
102
105
  while (n < max) {
103
- if (state.src.charCodeAt(n) === 0x60) {
104
- if (!hasBackslash(state, n)) isInCode = isInCode ? false : true
106
+ let nextSymbolPos = hasNextSymbol(state, n, max, 0x60, noMark) // '`'
107
+ if (nextSymbolPos !== -1) {
108
+ n = nextSymbolPos + 1
109
+ continue
105
110
  }
106
111
  if (opt.dollarMath) {
107
- if (state.src.charCodeAt(n) === 0x24) {
108
- if (!hasBackslash(state, n)) isInMath = isInMath ? false : true
112
+ nextSymbolPos = hasNextSymbol(state, n, max, 0x24, noMark) // '$'
113
+ if (nextSymbolPos !== -1) {
114
+ n = nextSymbolPos + 1
115
+ continue
109
116
  }
110
117
  }
111
- if (state.src.charCodeAt(n) === 0x2A && !isInCode && !isInMath) {
112
- if (hasBackslash(state, n)) {
113
- beforeIsMark = false
114
- noMark += state.src[n]
115
- if (n === max - 1) {
116
- inlinesPush(inlines, n - noMark.length + 1, n, noMark.length, 'text')
118
+
119
+ if (state.md.options.html) {
120
+ if (state.src.charCodeAt(n) === 0x3C && !hasBackslash(state, n)) { // '<'
121
+ let i = n + 1
122
+ while (i < max) {
123
+ if (state.src.charCodeAt(i) === 0x3E && !hasBackslash(state, i)) { // '>'
124
+ if (noMark.length !== 0) {
125
+ inlinesPush(inlines, textStart, n - 1, n - textStart, 'text')
126
+ }
127
+ let tag = state.src.slice(n + 1, i)
128
+ let tagType = ''
129
+ if (/^\//.test(tag)) {
130
+ tag = tag.slice(1)
131
+ tagType = 'close'
132
+ } else {
133
+ tagType = 'open'
134
+ }
135
+ inlinesPush(inlines, n, i, i - n + 1, 'html_inline', tag, tagType)
136
+ textStart = i + 1
137
+ break
138
+ }
139
+ i++
117
140
  }
118
- n++
141
+ n = i + 1
119
142
  continue
120
143
  }
121
- beforeIsMark = true
122
- mark += '*'
123
- if (n !== start && noMark !== '') {
124
- inlinesPush(inlines, n - noMark.length, n - 1, noMark.length, 'text')
144
+ }
145
+
146
+ if (state.src.charCodeAt(n) === 0x2A && !hasBackslash(state, n)) { // '*'
147
+ if (!isInStartMark) {
148
+ inlinesPush(inlines, textStart, n - 1, n - textStart, 'text')
125
149
  }
126
- noMark = ''
127
150
  if (n === max - 1) {
128
- inlinesPush(inlines, n - mark.length + 1, n, mark.length, '')
129
- }
130
- } else {
131
- noMark += state.src[n]
132
- if (state.src[n-1] === '*' && beforeIsMark) {
133
- inlinesPush(inlines, n - mark.length, n - 1, mark.length, '')
134
- mark = ''
151
+ inlinesPush(inlines, n, n, 1 , '')
152
+ break
135
153
  }
136
- if (n === max - 1) {
137
- inlinesPush(inlines, n - noMark.length + 1, n, noMark.length, 'text')
154
+ let i = n + 1
155
+ while (i < max) {
156
+ if (state.src.charCodeAt(i) === 0x2A) {
157
+ if (i === max - 1) inlinesPush(inlines, n, i, i - n + 1 , '')
158
+ i++
159
+ continue
160
+ }
161
+ inlinesPush(inlines, n, i - 1, i - n, '')
162
+ textStart = i
163
+ break
138
164
  }
165
+ n = i
166
+ continue
167
+ }
168
+ isInStartMark = false
169
+ noMark += state.src[n]
170
+ //console.log('noMark: ' + noMark)
171
+ if (n === max - 1 || max < 3) {
172
+ inlinesPush(inlines, textStart, n, n - textStart + 1, 'text')
173
+ break
139
174
  }
140
175
  n++
141
176
  }
@@ -153,7 +188,6 @@ const marksPush = (marks, nest, s, e, len, outsideLen, type) => {
153
188
  oLen: outsideLen,
154
189
  type: type,
155
190
  }
156
- //let i = marks.findIndex(o => o.s > s)
157
191
  let i = marks.findIndex(o => o.s > s)
158
192
  if (i === -1) {
159
193
  marks.push(np)
@@ -163,17 +197,27 @@ const marksPush = (marks, nest, s, e, len, outsideLen, type) => {
163
197
  }
164
198
 
165
199
  const setStrong = (inlines, marks, n, memo) => {
166
- let i = n + 2
200
+ let i = n + 1
167
201
  let j = 0
168
202
  let nest = 0
203
+ let insideTagsIsClose = 1
169
204
  while (i < inlines.length) {
170
- if (inlines[i].len === 0) { i += 2; continue }
205
+ if (inlines[i].len === 0) { i++; continue }
206
+ if (memo.html) {
207
+ if (inlines[i].type === 'html_inline') {
208
+ insideTagsIsClose = isJumpTag(inlines, i, memo)
209
+ //console.log('insideTagsIsClose: ' + insideTagsIsClose )
210
+ if (insideTagsIsClose === -1) return n, nest, memo
211
+ if (insideTagsIsClose === 0) { i++; continue }
212
+ }
213
+ }
214
+ if (inlines[i].type !== '') { i++; continue }
215
+
171
216
  //console.log('n: ' + n + ' [strong]: inlines[n].len: ' + inlines[n].len + ', i: ' + i + ', inlines[i].len: ' + inlines[i].len)
172
217
 
173
218
  nest = checkNest(inlines, marks, n, i)
174
219
  //console.log('n: ' + n + ' [strong]: nest: ' + nest)
175
220
  if (nest === -1) return n, nest, memo
176
-
177
221
  if (inlines[i].len === 1 && inlines[n].len > 2) {
178
222
  //console.log('n: ' + n + ' [strong]: check em inside strong: ' + nest)
179
223
  marksPush(marks, nest, inlines[n].ep, inlines[n].ep, 1, inlines[n].len - 1, 'em_open')
@@ -182,17 +226,21 @@ const setStrong = (inlines, marks, n, memo) => {
182
226
  inlines[n].ep -= 1
183
227
  inlines[i].len = 0
184
228
  inlines[i].sp += 1
185
- if (i + 2 < inlines.length) {
186
- i += 2
229
+ if (i++ < inlines.length) {
230
+ i++
187
231
  nest++
188
232
  } else {
189
233
  return n, nest, memo
190
234
  }
191
- //console.log(marks)
192
- //console.log('n: ' + n + ' [strong]: check em inside strong end.')
235
+ if (i > inlines.length - 1) return n, nest, memo
193
236
  }
194
237
 
238
+ //console.log('memo.html: ' + memo.html + 'insideTagsIsClose: ' + insideTagsIsClose + 'inlines[i].len: ' + inlines[i].len)
239
+ if (memo.html && !insideTagsIsClose && inlines[i].len !== 1) {
240
+ i++; continue
241
+ }
195
242
  let strongNum = Math.trunc(Math.min(inlines[n].len, inlines[i].len) / 2)
243
+
196
244
  if (inlines[i].len > 1) {
197
245
  //console.log('n: ' + n + ' [strong]: normal push, nest: ' + nest)
198
246
  j = 0
@@ -207,16 +255,16 @@ const setStrong = (inlines, marks, n, memo) => {
207
255
  //console.log(marks)
208
256
  j++
209
257
  }
210
-
211
258
  if (inlines[n].len === 0) return n, nest, memo
212
259
  }
213
260
 
214
- if (inlines[n].len === 1) {
215
- //console.log('check em that warp strong: ')
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)) {
263
+ //console.log('check em that warp strong.')
216
264
  nest++
217
- n, nest, memo= setEm(inlines, marks, n, memo, nest)
265
+ n, nest, memo = setEm(inlines, marks, n, memo, nest)
218
266
  if (memo.hasEmThatWrapStrong) {
219
- //console.log('fix strong wrapped em:')
267
+ //console.log('set em that wrap strong.')
220
268
  let k = 0
221
269
  while (k < strongNum) {
222
270
  marks[marks.length - 2 - k * 2 - 1].nest += 1
@@ -225,19 +273,57 @@ const setStrong = (inlines, marks, n, memo) => {
225
273
  }
226
274
  }
227
275
  }
228
-
229
276
  if (inlines[n].len === 0) return n, nest, memo
230
- i += 2
277
+ i++
231
278
  }
232
279
  return n, nest, memo
233
280
  }
234
281
 
282
+ const isJumpTag = (inlines, n, memo) => {
283
+ //console.log(n, 'before::memo.htmlTags: ' + JSON.stringify(memo.htmlTags))
284
+ const hasSet = Object.keys(memo.htmlTags).some(tag => {
285
+ if (tag === inlines[n].tag[0]) {
286
+ if (inlines[n].tag[1] === 'open') {
287
+ memo.htmlTags[tag]++ }
288
+ else {
289
+ memo.htmlTags[tag]--
290
+ }
291
+ return true
292
+ }
293
+ return false
294
+ })
295
+ if (!hasSet && !memo.htmlTags[inlines[n].tag[0]]) {
296
+ if (inlines[n].tag[1] === 'close') {
297
+ memo.htmlTags = {}
298
+ return -1
299
+ }
300
+ memo.htmlTags[inlines[n].tag[0]] = 1
301
+ }
302
+ //console.log(n, 'after::memo.htmlTags: ' + JSON.stringify(memo.htmlTags))
303
+ const closeAllTags = Object.values(memo.htmlTags).every(val => val === 0)
304
+ //console.log('closeAllTags: ' + closeAllTags)
305
+ if (closeAllTags) return 1
306
+ //memo.htmlTags = {}
307
+ return 0
308
+ }
309
+
235
310
  const setEm = (inlines, marks, n, memo, sNest) => {
236
- let i = n + 2
311
+ let i = n + 1
237
312
  let nest = 0
238
313
  let strongPNum = 0
314
+ let insideTagsIsClose = 1
239
315
  while (i < inlines.length) {
240
- if (inlines[i].len === 0) { i += 2; continue }
316
+ if (inlines[i].len === 0) { i++; continue }
317
+ if (memo.isEm && memo.html) {
318
+ if (inlines[i].type === 'html_inline') {
319
+ insideTagsIsClose = isJumpTag(inlines, i, memo)
320
+ //console.log('insideTagsIsClose: ' + insideTagsIsClose )
321
+ if (insideTagsIsClose === -1) return n, nest, memo
322
+ if (insideTagsIsClose === 0) { i++; continue }
323
+ }
324
+ }
325
+ if (inlines[i].type !== '') { i++; continue }
326
+
241
327
  const emNum = Math.min(inlines[n].len, inlines[i].len)
242
328
  if (memo.isEm && emNum !== 1) return n, sNest, memo
243
329
  //console.log('n: ' + n + ' [em]: inlines[n].len: ' + inlines[n].len + ', i: ' + i, ', inlines[i].len: ' + inlines[i].len + ', isEm: ' + memo.isEm)
@@ -245,7 +331,7 @@ const setEm = (inlines, marks, n, memo, sNest) => {
245
331
 
246
332
  if (memo.isEm && inlines[i].len === 2) {
247
333
  strongPNum++
248
- i += 2
334
+ i++
249
335
  continue
250
336
  }
251
337
 
@@ -258,6 +344,10 @@ const setEm = (inlines, marks, n, memo, sNest) => {
258
344
  if (nest === -1) return n, nest, memo
259
345
 
260
346
  if (emNum === 1) {
347
+ //console.log(n, i, 'insideTagsIsClose: ' + insideTagsIsClose)
348
+ if (memo.html && !insideTagsIsClose && inlines[i].len !== 2) {
349
+ i++; continue;
350
+ }
261
351
  //console.log('n: ' + n + ' [em]: normal push, nest: ' + nest)
262
352
  //console.log('strongPNum: ' + strongPNum)
263
353
  //console.log(inlines[n].ep, inlines[n].sp, inlines[n].s)
@@ -281,9 +371,8 @@ const setEm = (inlines, marks, n, memo, sNest) => {
281
371
  if (inlines[n].len === 0) return n, nest, memo
282
372
  }
283
373
 
284
- i += 2
374
+ i++
285
375
  }
286
-
287
376
  return n, nest, memo
288
377
  }
289
378
 
@@ -302,6 +391,7 @@ const checkNest = (inlines, marks, n, i) => {
302
391
  let strongNest = 0
303
392
  let emNest = 0
304
393
  let j = 0
394
+ //console.log(inlines)
305
395
  //console.log(marks)
306
396
  //console.log('n: ' + n + ', i: ' + i + ', inlines[n].s: ' + inlines[n].s + ', inlines[i].s: ' + inlines[i].s)
307
397
  while (j < marks.length) {
@@ -319,10 +409,16 @@ const checkNest = (inlines, marks, n, i) => {
319
409
  if (parentCloseN < marks.length) {
320
410
  while (parentCloseN < marks.length) {
321
411
  if (marks[parentCloseN].nest === parentNest) break
412
+ //if (marks.length - 1 == parentCloseN) break
322
413
  parentCloseN++
323
414
  }
324
- //console.log(parentCloseN, marks[parentCloseN].s, i, inlines[i].s)
325
- if (marks[parentCloseN].s < inlines[i].s) isRange = false
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
+ }
326
422
  }
327
423
  //console.log('isRange: ' + isRange)
328
424
 
@@ -334,13 +430,12 @@ const checkNest = (inlines, marks, n, i) => {
334
430
  return nest
335
431
  }
336
432
 
337
- const createMarks = (inlines, inlinesStart, inlinesEnd, memo) => {
433
+ const createMarks = (inlines, start, end, memo) => {
338
434
  let marks = []
339
- let n = inlinesStart
340
- while (n < inlinesEnd) {
341
- if (inlines[n].type !== '') { n += 2; continue }
342
- if (inlines[n].len === 0) { n += 2; continue }
343
- memo.isEm = inlines[n].len === 1 ? true : false
435
+ let n = start
436
+ while (n < end) {
437
+ if (inlines[n].type !== '' || inlines[n].len === 0) { n++; continue }
438
+ memo.isEm = inlines[n].len === 1 ? true : false
344
439
  memo.wrapEm = 0
345
440
  let nest = 0
346
441
  //console.log('n: ' + n + ' ----- inlines.length: ' + inlines.length + ', memo.isEm: ' + memo.isEm)
@@ -348,13 +443,41 @@ const createMarks = (inlines, inlinesStart, inlinesEnd, memo) => {
348
443
  n, nest, memo = setStrong(inlines, marks, n, memo)
349
444
  }
350
445
  n, nest, memo = setEm(inlines, marks, n, memo)
351
-
352
446
  if (inlines[n].len !== 0) setText(inlines, marks, n, nest)
353
- n += 2
447
+ //console.log(marks)
448
+ n++
354
449
  }
355
450
  return marks
356
451
  }
357
452
 
453
+ const fixInlines = (inlines, marks) => {
454
+ let n = 0
455
+ while (n < inlines.length) {
456
+ if (inlines[n].type !== '') { n++; continue }
457
+ let i = 0
458
+ //console.log('n: ' + n + ', inlines[n].s: ' + inlines[n].s + ', inlines[n].e: ' + inlines[n].e)
459
+ while (i < marks.length) {
460
+ //console.log(marks[i].type, marks[i].s, inlines[n].e, marks[i].e, inlines[n].e)
461
+ //console.log(marks[i].s >= inlines[n].s , marks[i].e <= inlines[n].e)
462
+ if (marks[i].s >= inlines[n].s && marks[i].e <= inlines[n].e) {
463
+ //console.log('n: ' + n + ', i: ' + i + ', marks[i].type: ' + marks[i].type)
464
+ inlines.splice(n + i + 1, 0, marks[i])
465
+ i++
466
+ continue
467
+ }
468
+ break
469
+ }
470
+ if (marks.length) {
471
+ marks.splice(0, i)
472
+ inlines.splice(n, 1)
473
+ n += i
474
+ } else {
475
+ //if (inlines[n].type === '') inlines[n].type = 'text'
476
+ n++
477
+ }
478
+ }
479
+ }
480
+
358
481
  const strongJa = (state, silent, opt) => {
359
482
  if (silent) return false
360
483
  const start = state.pos
@@ -371,6 +494,7 @@ const strongJa = (state, silent, opt) => {
371
494
  }
372
495
  if (start > max) return false
373
496
  if (state.src.charCodeAt(start) !== 0x2A) return false
497
+
374
498
  if (hasBackslash(state, start)) return false
375
499
  //console.log('state.src.length: ' + state.src.length + ', start: ' + start + ', state.src: ' + state.src)
376
500
  let inlines = createInlines(state, start, max, opt)
@@ -381,6 +505,8 @@ const strongJa = (state, silent, opt) => {
381
505
  isEm: false,
382
506
  hasEmThatWrapStrong: false,
383
507
  noSetStrongEnd: false,
508
+ html: state.md.options.html,
509
+ htmlTags: {},
384
510
  inlineMarkStart: state.src.charCodeAt(0) === 0x2A ? true : false,
385
511
  inlineMarkEnd: state.src.charCodeAt(max - 1) === 0x2A ? true : false,
386
512
  }
@@ -388,51 +514,28 @@ const strongJa = (state, silent, opt) => {
388
514
  //console.log('marks: ')
389
515
  //console.log(marks)
390
516
 
391
- let n = 0
392
- while (n < inlines.length) {
393
- if (inlines[n].type !== '') { n++; continue }
394
- let i = 0
395
- //console.log('n: ' + n + ', inlines[n].s: ' + inlines[n].s + ', inlines[n].e: ' + inlines[n].e)
396
- let c = 0
397
- while (i < marks.length) {
398
- //console.log(marks[i].s, inlines[n].e, marks[i].e, inlines[n].e)
399
- //console.log(marks[i].s >= inlines[n].s , marks[i].e <= inlines[n].e)
400
- if (marks[i].s >= inlines[n].s && marks[i].e <= inlines[n].e) {
401
- //console.log('n: ' + n + ', i: ' + i + ', marks[i].type: ' + marks[i].type)
402
- inlines.splice(n + i + 1, 0, marks[i])
403
- c++
404
- i++
405
- continue
406
- }
407
- break
408
- }
409
- if (marks.length) {
410
- marks.splice(0, c)
411
- inlines.splice(n, 1)
412
- n += c
413
- } else {
414
- inlines[n].type = 'text'
415
- n++
416
- }
417
- }
418
-
517
+ fixInlines(inlines, marks)
419
518
  //console.log('fix inlines:')
420
519
  //console.log(inlines)
520
+
421
521
  setToken(state, inlines)
422
522
 
423
- //console.log('state.pos: ' + state.pos + ', inlines[inlines.length - 1].e + 1: ' + (inlines[inlines.length - 1].e + 1) + ', max: ' + max)
424
- state.pos = inlines[inlines.length - 1].e + 1
425
523
  if (attributesSrc) {
524
+ //console.log('attributesSrc[1].length: ' + attributesSrc[1].length)
426
525
  if (attributesSrc[1].length > 1) {
427
- state.pos += attributesSrc[1].length
526
+ state.pos = max + attributesSrc[1].length
527
+ } else {
528
+ state.pos = max
428
529
  }
530
+ } else {
531
+ state.pos = max + 1
429
532
  }
430
533
  return true
431
534
  }
432
535
 
433
536
  const mditStrongJa = (md, option) => {
434
537
  const opt = {
435
- dollarMath: true
538
+ dollarMath: true,
436
539
  }
437
540
  if (option !== undefined) {
438
541
  for (let o in option) {
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.2",
4
+ "version": "0.3.4",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
7
  "scripts": {
@@ -146,9 +146,9 @@ a[*](https://example*.com)*b*
146
146
  <p><strong>重要な文・文節や語句</strong>は<code>**</code>を使って囲みます。<em>文脈上強調する語句</em>は<code>*</code>を使って囲みます。</p>
147
147
 
148
148
  [Markdown]
149
- インライン数式は$x * y = z$のように*書きます*。
149
+ インラインコードは`*`と`*`で*囲みます*。
150
150
  [HTML]
151
- <p>インライン数式は$x * y = z$のように<em>書きます</em>。</p>
151
+ <p>インラインコードは<code>*</code>と<code>*</code>で<em>囲みます</em>。</p>
152
152
 
153
153
  [Markdown]
154
154
  [node_modules/*](#)の*はすべてを意味します。
@@ -184,3 +184,155 @@ a**b**{.style}
184
184
  a**b**c {.style}
185
185
  [HTML]
186
186
  <p class="style">a<strong>b</strong>c</p>
187
+
188
+
189
+ [Markdown]
190
+ z*a<span>b*c</span>d*e
191
+ [HTML]
192
+ <p>z<em>a&lt;span&gt;b</em>c&lt;/span&gt;d*e</p>
193
+ [HTML:true]
194
+ <p>z<em>a<span>b*c</span>d</em>e</p>
195
+
196
+ [Markdown]
197
+ a<span>b*c</span>d*e*f
198
+ [HTML]
199
+ <p>a&lt;span&gt;b<em>c&lt;/span&gt;d</em>e*f</p>
200
+ [HTML:true]
201
+ <p>a<span>b*c</span>d<em>e</em>f</p>
202
+
203
+ [Markdown]
204
+ a*a<span>b</span>c*c
205
+ [HTML:false]
206
+ <p>a<em>a&lt;span&gt;b&lt;/span&gt;c</em>c</p>
207
+ [HTML:true]
208
+ <p>a<em>a<span>b</span>c</em>c</p>
209
+
210
+ [Markdown]
211
+ aa<span>b*ef*</span>cc
212
+ [HTML:false]
213
+ <p>aa&lt;span&gt;b<em>ef</em>&lt;/span&gt;cc</p>
214
+ [HTML:true]
215
+ <p>aa<span>b<em>ef</em></span>cc</p>
216
+
217
+ [Markdown]
218
+ a*a<span>b*ef*</span>c*c
219
+ [HTML:false]
220
+ <p>a<em>a&lt;span&gt;b</em>ef<em>&lt;/span&gt;c</em>c</p>
221
+ [HTML:true, commonmark: <p>a<em>a<span>b</em>ef*</span>c*c</p>]
222
+ <p>a<em>a<span>b<em>ef</em></span>c</em>c</p>
223
+
224
+
225
+ [Markdown]
226
+ a***a<span>b</span>c***c
227
+ [HTML:false]
228
+ <p>a<em><strong>a&lt;span&gt;b&lt;/span&gt;c</strong></em>c</p>
229
+ [HTML:true]
230
+ <p>a<em><strong>a<span>b</span>c</strong></em>c</p>
231
+
232
+
233
+ [Markdown]
234
+ a***a<span>b***e</span>cc
235
+ [HTML:false]
236
+ <p>a<em><strong>a&lt;span&gt;b</strong></em>e&lt;/span&gt;cc</p>
237
+ [HTML:true]
238
+ <p>a***a<span>b***e</span>cc</p>
239
+
240
+ [Markdown]
241
+ aa<span>b*e<s>f</s>*</span>cc
242
+ [HTML:false]
243
+ <p>aa&lt;span&gt;b<em>e&lt;s&gt;f&lt;/s&gt;</em>&lt;/span&gt;cc</p>
244
+ [HTML:true]
245
+ <p>aa<span>b<em>e<s>f</s></em></span>cc</p>
246
+
247
+ [Markdown]
248
+ **aa<span>b*e<s>f</s>*</span>cc**
249
+ [HTML:false]
250
+ <p><strong>aa&lt;span&gt;b<em>e&lt;s&gt;f&lt;/s&gt;</em>&lt;/span&gt;cc</strong></p>
251
+ [HTML:true]
252
+ <p><strong>aa<span>b<em>e<s>f</s></em></span>cc</strong></p>
253
+
254
+
255
+ [Markdown]
256
+ *aa<span>b**e<s>f</s>**</span>cc*
257
+ [HTML:false]
258
+ <p><em>aa&lt;span&gt;b<strong>e&lt;s&gt;f&lt;/s&gt;</strong>&lt;/span&gt;cc</em></p>
259
+ [HTML:true]
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&lt;span&gt;b&lt;/span&gt;</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&lt;span&gt;c&lt;/span&gt;*</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>&lt;span&gt;a&lt;/span&gt;</em>b</em></p>
335
+ [HTML: true]
336
+ <p>*<em><em><span>a</span></em>b</em></p>
337
+
338
+
@@ -21,8 +21,7 @@ HTMLは**「HyperText *Markup* `Language`」**の略です。
21
21
  [HTML]
22
22
  <p>HTMLは<strong>「HyperText <em>Markup</em> <code>Language</code>」</strong>の略です。</p>
23
23
 
24
-
25
- [Markdown]
24
+ [Markdown: 5]
26
25
  HTMLは**「HyperText Mark
27
26
 
28
27
  up Language」**の略です。
package/test/test.js CHANGED
@@ -14,7 +14,8 @@ 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 != 29 ) { n++; continue }
17
+ //if (n !== 23 ) { n++; continue }
18
+ //if (n !== 36 ) { n++; continue }
18
19
  const m = ms[n].markdown
19
20
  console.log('Test [' + n + ', HTML: false] >>>')
20
21
  const h = md.render(m)
@@ -23,7 +24,6 @@ const check = (ms, example) => {
23
24
  } catch(e) {
24
25
  console.log('Input: ' + ms[n].markdown + '\nConvert: ' + h + 'Correct: ' + ms[n].html)
25
26
  }
26
-
27
27
  if (ms[n].htmlWithHtmlTrue) {
28
28
  console.log('Test [' + n + ', HTML: true] >>>')
29
29
  const hh = mdWithHtml.render(m)