@peaceroad/markdown-it-strong-ja 0.6.0 → 0.6.2
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 +20 -35
- package/index.js +6 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,64 +34,44 @@ const mdCompat = mdit().use(mditStrongJa, { mode: 'compatible' }) // markdown-it
|
|
|
34
34
|
const mdAggressive = mdit().use(mditStrongJa, { mode: 'aggressive' }) // always pair leading **
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
Default (japanese-only) pairs aggressively only when Japanese is present. Aggressive always pairs the leading `**`, and compatible matches markdown-it.
|
|
37
|
+
Default (japanese-only) pairs aggressively only when Japanese is present in the paragraph (the full inline content); detection is not line-by-line. Aggressive always pairs the leading `**`, and compatible matches markdown-it.
|
|
38
38
|
|
|
39
|
-
Japanese-first pairing around punctuation and mixed sentences: leading/trailing Japanese quotes or brackets (`「`, `」`, `(`, `、` etc.) are wrapped
|
|
39
|
+
Japanese-first pairing around punctuation and mixed sentences: leading/trailing Japanese quotes or brackets (`「`, `」`, `(`, `、` etc.) are wrapped in Japanese paragraphs. Mixed sentences here mean one paragraph that contains multiple `*` runs; Japanese text keeps the leading `**` aggressive, while English-only stays compatible unless you pick aggressive mode.
|
|
40
40
|
|
|
41
|
-
- Punctuation:
|
|
41
|
+
- Punctuation (CJK quotes):
|
|
42
42
|
- Input: `**「test」**`
|
|
43
|
-
- Output (default): `<p><strong>「test」</strong></p>`
|
|
44
|
-
-
|
|
45
|
-
- Output (
|
|
43
|
+
- Output (default/aggressive/compatible/markdown-it): `<p><strong>「test」</strong></p>`
|
|
44
|
+
- Input: `これは**「test」**です`
|
|
45
|
+
- Output (default/aggressive): `<p>これは<strong>「test」</strong>です</p>`
|
|
46
|
+
- Output (compatible/markdown-it): `<p>これは**「test」**です</p>`
|
|
46
47
|
|
|
47
48
|
- Mixed sentence (multiple `*` runs): English-only stays markdown-it compatible unless you pick aggressive mode; earlier `**` runs can remain literal while later ones pair.
|
|
48
49
|
- Input (Japanese mixed): `**あああ。**iii**`
|
|
49
|
-
- Output (default): `<p><strong>あああ。</strong>iii**</p>`
|
|
50
|
-
- Output (
|
|
51
|
-
- Output (compatible): `<p>**あああ。<strong>iii</strong></p>`
|
|
50
|
+
- Output (default/aggressive): `<p><strong>あああ。</strong>iii**</p>`
|
|
51
|
+
- Output (compatible/markdown-it): `<p>**あああ。<strong>iii</strong></p>`
|
|
52
52
|
- Input (English-only): `**aaa.**iii**`
|
|
53
|
-
- Output (default): `<p>**aaa.<strong>iii</strong></p>`
|
|
54
53
|
- Output (aggressive): `<p><strong>aaa.</strong>iii**</p>`
|
|
55
|
-
- Output (compatible): `<p>**aaa.<strong>iii</strong></p>`
|
|
54
|
+
- Output (default/compatible/markdown-it): `<p>**aaa.<strong>iii</strong></p>`
|
|
56
55
|
- Input (English-only, two `**` runs): `**aaa.**eee.**eeee**`
|
|
57
|
-
- Output (default): `<p>**aaa.**eee.<strong>eeee</strong></p>`
|
|
58
56
|
- Output (aggressive): `<p><strong>aaa.</strong>eee.<strong>eeee</strong></p>`
|
|
59
|
-
- Output (compatible): `<p>**aaa.**eee.<strong>eeee</strong></p>`
|
|
57
|
+
- Output (default/compatible/markdown-it): `<p>**aaa.**eee.<strong>eeee</strong></p>`
|
|
60
58
|
|
|
61
59
|
Inline link/HTML/code blocks stay intact (see Link / Inline code examples above): the plugin re-wraps `[label](url)` / `[label][]` after pairing to avoid broken emphasis tokens around anchors, inline HTML, or inline code. This also covers clusters of `*` with no spaces around the link or code span.
|
|
62
60
|
|
|
63
61
|
- Link (cluster of `*` without spaces):
|
|
64
62
|
- Input (English-only): `string**[text](url)**`
|
|
65
|
-
- Output (default): `<p>string**<a href="url">text</a>**</p>`
|
|
66
63
|
- Output (aggressive): `<p>string<strong><a href="url">text</a></strong></p>`
|
|
67
|
-
- Output (compatible): `<p>string**<a href="url">text</a>**</p>`
|
|
64
|
+
- Output (default/compatible/markdown-it): `<p>string**<a href="url">text</a>**</p>`
|
|
68
65
|
- Input (Japanese mixed): `これは**[text](url)**です`
|
|
69
66
|
- Output (default/aggressive): `<p>これは<strong><a href="url">text</a></strong>です</p>`
|
|
70
|
-
- Output (compatible): `<p>これは**<a href="url">text</a>**です</p>`
|
|
67
|
+
- Output (compatible/markdown-it): `<p>これは**<a href="url">text</a>**です</p>`
|
|
71
68
|
- Inline code (cluster of `*` without spaces):
|
|
72
69
|
- Input (English-only): `` **aa`code`**aa ``
|
|
73
|
-
- Output (default): `<p>**aa<code>code</code>**aa</p>`
|
|
74
70
|
- Output (aggressive): `<p><strong>aa<code>code</code></strong>aa</p>`
|
|
75
|
-
- Output (compatible): `<p>**aa<code>code</code>**aa</p>`
|
|
71
|
+
- Output (default/compatible/markdown-it): `<p>**aa<code>code</code>**aa</p>`
|
|
76
72
|
- Input (Japanese mixed): `` これは**`code`**です ``
|
|
77
73
|
- Output (default/aggressive): `<p>これは<strong><code>code</code></strong>です</p>`
|
|
78
|
-
- Output (compatible): `<p>これは**<code>code</code>**です</p>`
|
|
79
|
-
|
|
80
|
-
### Known differences from vanilla markdown-it
|
|
81
|
-
|
|
82
|
-
This section collects other cases that diverge from vanilla markdown-it.
|
|
83
|
-
|
|
84
|
-
The plugin keeps pairing aggressively in Japanese contexts, which can diverge from markdown-it when markup spans newlines or mixes nested markers.
|
|
85
|
-
|
|
86
|
-
- Multiline + nested emphasis (markdown-it leaves trailing `**`):
|
|
87
|
-
|
|
88
|
-
```markdown
|
|
89
|
-
***強調と*入れ子*の検証***を行う。
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
- markdown-it: `<p><em><em><em>強調と</em>入れ子</em>の検証</em>**を行う。</p>`
|
|
93
|
-
- markdown-it-strong-ja (default/aggressive): `<p><em><strong>強調と<em>入れ子</em>の検証</strong></em>を行う。</p>`
|
|
94
|
-
- If you want markdown-it behavior here, use `mode: 'compatible'`.
|
|
74
|
+
- Output (compatible/markdown-it): `<p>これは**<code>code</code>**です</p>`
|
|
95
75
|
|
|
96
76
|
Notice. The plugin keeps inline HTML / angle-bracket regions intact so rendered HTML keeps correct nesting (for example, it avoids mis-nesting in inputs like `**aaa<code>**bbb</code>` when HTML output is enabled).
|
|
97
77
|
|
|
@@ -220,6 +200,11 @@ HTMLは**「HyperText Markup Language」**。
|
|
|
220
200
|
[HTML]
|
|
221
201
|
<p>HTMLは<strong>「HyperText Markup Language」</strong>。</p>
|
|
222
202
|
|
|
203
|
+
[Markdown]
|
|
204
|
+
***強調と*入れ子*の検証***を行う。
|
|
205
|
+
[HTML]
|
|
206
|
+
<p><em><em><em>強調と</em>入れ子</em>の検証</em>**を行う。</p>
|
|
207
|
+
|
|
223
208
|
[Markdown]
|
|
224
209
|
****
|
|
225
210
|
[HTML]
|
package/index.js
CHANGED
|
@@ -2277,15 +2277,15 @@ const mditStrongJa = (md, option) => {
|
|
|
2277
2277
|
const token = state.tokens[i]
|
|
2278
2278
|
if (!token || token.type !== 'inline' || !token.children || token.children.length === 0) continue
|
|
2279
2279
|
let idx = token.children.length - 1
|
|
2280
|
-
while (idx >= 0 && token.children[idx]
|
|
2280
|
+
while (idx >= 0 && (!token.children[idx] || (token.children[idx].type === 'text' && token.children[idx].content === ''))) {
|
|
2281
2281
|
idx--
|
|
2282
2282
|
}
|
|
2283
2283
|
if (idx < 0) continue
|
|
2284
|
-
const
|
|
2285
|
-
if (!
|
|
2286
|
-
const trimmed =
|
|
2287
|
-
if (trimmed !==
|
|
2288
|
-
|
|
2284
|
+
const tail = token.children[idx]
|
|
2285
|
+
if (!tail || tail.type !== 'text' || !tail.content) continue
|
|
2286
|
+
const trimmed = tail.content.replace(/[ \t]+$/, '')
|
|
2287
|
+
if (trimmed !== tail.content) {
|
|
2288
|
+
tail.content = trimmed
|
|
2289
2289
|
}
|
|
2290
2290
|
}
|
|
2291
2291
|
}
|
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.6.
|
|
4
|
+
"version": "0.6.2",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|