@peaceroad/markdown-it-strong-ja 0.6.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,27 +18,32 @@ md.render('HTMLは*「HyperText Markup Language」*の略です。')
18
18
  // <p>HTMLは<em>「HyperText Markup Language」</em>の略です。</p>
19
19
  ```
20
20
 
21
- Notice. Basically, it is assumed that you will use markdown-it-attrs in conjunction with this. If you do not use it, please use `use(mditStrongJa, {mditAttrs: false})`.
21
+ Note: this plugin assumes `markdown-it-attrs` is used. If you do not use it, pass `use(mditStrongJa, { mditAttrs: false })`.
22
22
 
23
23
  ### How this differs from vanilla markdown-it
24
24
 
25
- Default output pairs `*` / `**` as it scans left-to-right: when a line contains Japanese (hiragana / katakana / kanji / fullwidth punctuation), japanese-only mode treats the leading `**` aggressively; English-only lines follow markdown-it style pairing. Pick one mode for the examples below:
25
+ Default output pairs `*` / `**` as it scans left-to-right: when a line contains Japanese (hiragana / katakana / kanji (Han) / fullwidth punctuation), japanese mode treats the leading `**` aggressively; English-only lines follow markdown-it style pairing. Pick one mode for the examples below:
26
26
 
27
- - `mode: 'japanese-only'` (default) … Japanese ⇒ aggressive, English-only ⇒ markdown-it compatible
27
+ - `mode: 'japanese'` (default, alias: `'japanese-only'`) … Japanese ⇒ aggressive, English-only ⇒ markdown-it compatible
28
28
  - `mode: 'aggressive'` … always aggressive (lead `**` pairs greedily)
29
29
  - `mode: 'compatible'` … markdown-it compatible (lead `**` stays literal)
30
30
 
31
31
  ```js
32
- const mdDefault = mdit().use(mditStrongJa) // mode: 'japanese-only'
32
+ const mdDefault = mdit().use(mditStrongJa) // mode: 'japanese'
33
33
  const mdCompat = mdit().use(mditStrongJa, { mode: 'compatible' }) // markdown-it pairing
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 in the paragraph (the full inline content); detection is not line-by-line. Aggressive always pairs the leading `**`, and compatible matches markdown-it.
37
+ Default (japanese) 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. Detection keys off hiragana/katakana/kanji (Han) and fullwidth punctuation; it does not treat Hangul as Japanese, so it is not full CJK detection.
38
+
39
+ Quick mode guide:
40
+ - Pick `compatible` for markdown-it behavior everywhere.
41
+ - Pick `japanese` to be aggressive only when Japanese text is present.
42
+ - Pick `aggressive` if you want leading `**` to always pair.
38
43
 
39
44
  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
45
 
41
- - Punctuation (CJK quotes):
46
+ - Punctuation (Japanese quotes / fullwidth punctuation):
42
47
  - Input: `**「test」**`
43
48
  - Output (default/aggressive/compatible/markdown-it): `<p><strong>「test」</strong></p>`
44
49
  - Input: `これは**「test」**です`
@@ -79,7 +84,7 @@ Notice. The plugin keeps inline HTML / angle-bracket regions intact so rendered
79
84
 
80
85
  ## Example
81
86
 
82
- The following examples is for strong. The process for em is roughly the same.
87
+ The following examples are for strong. The process for em is roughly the same.
83
88
 
84
89
  ````markdown
85
90
  [Markdown]
@@ -222,13 +227,9 @@ a****
222
227
  ````
223
228
 
224
229
 
225
- ### disallowMixed (legacy)
226
-
227
- `disallowMixed: true` is kept for back-compat: it forces compatible pairing for English/mixed contexts that contain markdown links, HTML tags, inline code, or math expressions while staying aggressive for Japanese-only text. Prefer `mode` for new setups; enable this only if you need the legacy compat-first behavior in mixed English.
228
-
229
230
  ### coreRulesBeforePostprocess
230
231
 
231
- `strong_ja_postprocess` runs inside the markdown-it core pipeline. When other plugins register core rules, you can keep their rules ahead of `strong_ja_postprocess` by listing them in `coreRulesBeforePostprocess`. Each name is normalized, deduplicated, and re-ordered once during plugin setup.
232
+ `strong_ja_token_postprocess` runs inside the markdown-it core pipeline. When other plugins register core rules, you can keep their rules ahead of `strong_ja_token_postprocess` by listing them in `coreRulesBeforePostprocess`. Each name is normalized, deduplicated, and re-ordered once during plugin setup.
232
233
 
233
234
  ```js
234
235
  const md = mdit()
@@ -242,4 +243,32 @@ const md = mdit()
242
243
  - Specify `['cjk_breaks']` (or other rule names) when you rely on plugins such as `@peaceroad/markdown-it-cjk-breaks-mod` and need them to run first.
243
244
  - Pass an empty array if you do not want `mditStrongJa` to reorder any core rules.
244
245
 
245
- Most setups can leave this option untouched; use it only when you must keep another plugin's core rule ahead of `strong_ja_postprocess`.
246
+ Most setups can leave this option untouched; use it only when you must keep another plugin's core rule ahead of `strong_ja_token_postprocess`.
247
+
248
+ ### postprocess
249
+
250
+ Toggle the link/reference reconstruction pass and the link-adjacent mark cleanup that runs after inline parsing.
251
+
252
+ ```js
253
+ const md = mdit().use(mditStrongJa, {
254
+ postprocess: false
255
+ })
256
+ ```
257
+
258
+ - Default: `true`
259
+ - Set `false` when you want to minimize core-rule interference and accept that some link/reference + emphasis combinations remain literal (for example, `**[text](url)**`, `[**Text**][]`).
260
+
261
+ ### patchCorePush
262
+
263
+ Controls whether `mditStrongJa` patches `md.core.ruler.push` to keep `strong_ja_restore_softbreaks` ordered after `cjk_breaks` when other plugins register their core rules after `mditStrongJa` (used only when `mditAttrs: false`).
264
+
265
+ ```js
266
+ const md = mdit().use(mditStrongJa, {
267
+ mditAttrs: false,
268
+ patchCorePush: false
269
+ })
270
+ ```
271
+
272
+ - Default: `true`
273
+ - Disable if you want to avoid monkey-patching core rule registration and can guarantee rule ordering (or you do not use `cjk_breaks`).
274
+ - If disabled and `cjk_breaks` is registered later, softbreak normalization can run too early and spacing around CJK punctuation can differ in no-attrs mode.