@diplodoc/transform 4.73.2 → 4.73.3

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.
@@ -139,10 +139,21 @@ function collectTermsFromRawContent(tokens: Token[], reg: RegExp, out: Set<strin
139
139
  collectRawTermMatches(token.content, reg, out);
140
140
  }
141
141
 
142
- if (token.type === 'inline' && token.children) {
143
- for (const child of token.children) {
144
- if (child.type === 'code_inline' && child.content) {
145
- collectRawTermMatches(child.content, reg, out);
142
+ if (token.type === 'inline') {
143
+ // Scan the raw inline content to catch term references that
144
+ // may have been split across child tokens by emphasis parsing.
145
+ // When term definitions come from includes resolved after inline
146
+ // parsing, term_inline fails and `(*key)` gets fragmented by
147
+ // the `*` emphasis delimiter — making per-child scanning miss them.
148
+ if (token.content) {
149
+ collectRawTermMatches(token.content, reg, out);
150
+ }
151
+
152
+ if (token.children) {
153
+ for (const child of token.children) {
154
+ if (child.type === 'code_inline' && child.content) {
155
+ collectRawTermMatches(child.content, reg, out);
156
+ }
146
157
  }
147
158
  }
148
159
  }
@@ -386,7 +397,15 @@ const term: MarkdownItPluginCb = (md, options) => {
386
397
  alt: ['paragraph', 'reference'],
387
398
  });
388
399
 
389
- md.core.ruler.after('linkify', 'termReplace', termReplace);
400
+ // Register termReplace after text_join so that emphasis-split text
401
+ // tokens (e.g. [text](*key) where * opens a delimiter) are merged
402
+ // before the term regex runs. Without this, terms defined in
403
+ // included files (resolved after inline parsing) would be missed.
404
+ try {
405
+ md.core.ruler.after('text_join', 'termReplace', termReplace);
406
+ } catch {
407
+ md.core.ruler.after('linkify', 'termReplace', termReplace);
408
+ }
390
409
  };
391
410
 
392
411
  export = term;
@@ -57,7 +57,7 @@ export function headingInfo(tokens: Token[], idx: number) {
57
57
  while (inlineToken.children && i < inlineToken.children.length) {
58
58
  const token = inlineToken.children[i];
59
59
 
60
- if (token.type === 'text') {
60
+ if (token.type === 'text' || token.type === 'text_special') {
61
61
  title += token.content;
62
62
  }
63
63