vitepress-allyouneed 0.5.5 → 0.5.6

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/CHANGELOG.md CHANGED
@@ -5,9 +5,10 @@
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
- ## [0.5.5] - 2026-06-20
8
+ ### Fixed
9
+ - **`==highlight==` 在 CJK、粗体、链接或公式旁跨段错配**:高亮规则不再套用为 `*`/`_` 设计的 delimiter flanking 语义,改为原子解析成对 `==` 并递归解析内部 Markdown。`指==**重点**运行==的`、连续多个粗体高亮及高亮内公式/链接现在稳定输出 `<mark>`,不再残留原始 `==`。
9
10
 
10
- ## [Unreleased]
11
+ ## [0.5.5] - 2026-06-20
11
12
 
12
13
  ### Added
13
14
  - **目录可由 dirIndex 排序**:`index.md`、`README.md` 或同名目录页现在是该文件夹 group 的排序锚点。默认 `sortBy: 'order-then-title'` 下,给目录页写 `order: 1` 即可控制目录位置;嵌套目录、`per-folder` 根侧栏和 `autoNav` 均一致生效,无需给文件夹名添加数字前缀。顶级 `groupOrder` 仍具有最高优先级。
package/dist/index.cjs CHANGED
@@ -1785,79 +1785,49 @@ function registerCallouts(md) {
1785
1785
 
1786
1786
  // src/modules/highlight/rule.ts
1787
1787
  var EQ = 61;
1788
- function tokenize(state, silent) {
1789
- if (silent) return false;
1790
- const start = state.pos;
1791
- const marker = state.src.charCodeAt(start);
1792
- if (marker !== EQ) return false;
1793
- const scanned = state.scanDelims(state.pos, true);
1794
- let len = scanned.length;
1795
- const ch = String.fromCharCode(marker);
1796
- if (len < 2) return false;
1797
- let token;
1798
- if (len % 2) {
1799
- token = state.push("text", "", 0);
1800
- token.content = ch;
1801
- len -= 1;
1802
- }
1803
- for (let i = 0; i < len; i += 2) {
1804
- token = state.push("text", "", 0);
1805
- token.content = ch + ch;
1806
- const delims = state.delimiters;
1807
- delims.push({
1808
- marker,
1809
- length: 0,
1810
- // 关掉 emphasis 用的 "rule of 3"
1811
- jump: i / 2,
1812
- // 1 delimiter = 2 chars
1813
- token: state.tokens.length - 1,
1814
- end: -1,
1815
- open: scanned.can_open,
1816
- close: scanned.can_close
1817
- });
1788
+ var BACKSLASH = 92;
1789
+ function findClosingMarker(src, from) {
1790
+ for (let pos = from; pos < src.length - 1; pos += 1) {
1791
+ if (src.charCodeAt(pos) === BACKSLASH) {
1792
+ pos += 1;
1793
+ continue;
1794
+ }
1795
+ if (src.charCodeAt(pos) === EQ && src.charCodeAt(pos + 1) === EQ) {
1796
+ return pos;
1797
+ }
1818
1798
  }
1819
- state.pos += scanned.length;
1820
- return true;
1799
+ return -1;
1821
1800
  }
1822
- function postProcess(state) {
1823
- const delimiters = state.delimiters;
1824
- const loneMarkers = [];
1825
- const max = delimiters.length;
1826
- for (let i = 0; i < max; i++) {
1827
- const startDelim = delimiters[i];
1828
- if (startDelim.marker !== EQ) continue;
1829
- if (startDelim.end === -1) continue;
1830
- const endDelim = delimiters[startDelim.end];
1831
- let token = state.tokens[startDelim.token];
1832
- token.type = "mark_open";
1833
- token.tag = "mark";
1834
- token.nesting = 1;
1835
- token.markup = "==";
1836
- token.content = "";
1837
- token = state.tokens[endDelim.token];
1838
- token.type = "mark_close";
1839
- token.tag = "mark";
1840
- token.nesting = -1;
1841
- token.markup = "==";
1842
- token.content = "";
1843
- const prev = state.tokens[endDelim.token - 1];
1844
- if (prev && prev.type === "text" && prev.content === "=") {
1845
- loneMarkers.push(endDelim.token - 1);
1846
- }
1801
+ function tokenize(state, silent) {
1802
+ const start = state.pos;
1803
+ if (state.src.charCodeAt(start) !== EQ || state.src.charCodeAt(start + 1) !== EQ) {
1804
+ return false;
1847
1805
  }
1848
- while (loneMarkers.length > 0) {
1849
- const i = loneMarkers.pop();
1850
- let j = i + 1;
1851
- while (j < state.tokens.length && state.tokens[j].type === "mark_close") {
1852
- j += 1;
1853
- }
1854
- j -= 1;
1855
- if (i !== j) {
1856
- const tmp = state.tokens[j];
1857
- state.tokens[j] = state.tokens[i];
1858
- state.tokens[i] = tmp;
1859
- }
1806
+ const close = findClosingMarker(state.src, start + 2);
1807
+ if (close < 0 || close === start + 2) return false;
1808
+ const end = close + 2;
1809
+ if (silent) {
1810
+ state.pos = end;
1811
+ return true;
1860
1812
  }
1813
+ const open = state.push("mark_open", "mark", 1);
1814
+ open.markup = "==";
1815
+ const inner = [];
1816
+ state.md.inline.parse(
1817
+ state.src.slice(start + 2, close),
1818
+ state.md,
1819
+ state.env,
1820
+ inner
1821
+ );
1822
+ const levelOffset = state.level;
1823
+ for (const token of inner) {
1824
+ token.level += levelOffset;
1825
+ state.tokens.push(token);
1826
+ }
1827
+ const closeToken = state.push("mark_close", "mark", -1);
1828
+ closeToken.markup = "==";
1829
+ state.pos = end;
1830
+ return true;
1861
1831
  }
1862
1832
  function registerHighlightInline(md) {
1863
1833
  try {
@@ -1865,27 +1835,6 @@ function registerHighlightInline(md) {
1865
1835
  } catch {
1866
1836
  md.inline.ruler.before("emphasis", "allyouneed_highlight", tokenize);
1867
1837
  }
1868
- md.inline.ruler2.before(
1869
- "emphasis",
1870
- "allyouneed_highlight",
1871
- function highlightPostProcess(state) {
1872
- const tokens_meta = state.tokens_meta;
1873
- const curr = state.delimiters;
1874
- if (curr) postProcess(state);
1875
- if (tokens_meta) {
1876
- for (const m of tokens_meta) {
1877
- if (m && m.delimiters) {
1878
- const proxy = {
1879
- ...state,
1880
- delimiters: m.delimiters
1881
- };
1882
- postProcess(proxy);
1883
- }
1884
- }
1885
- }
1886
- return false;
1887
- }
1888
- );
1889
1838
  }
1890
1839
 
1891
1840
  // src/modules/highlight/index.ts
@@ -2402,7 +2351,7 @@ function renderTemplate(v) {
2402
2351
  // src/core/views/generate-data.ts
2403
2352
  var import_node_fs6 = __toESM(require("fs"), 1);
2404
2353
  var import_node_path6 = __toESM(require("path"), 1);
2405
- var PLUGIN_VERSION = true ? "0.5.5" : "0.0.0-dev";
2354
+ var PLUGIN_VERSION = true ? "0.5.6" : "0.0.0-dev";
2406
2355
  var WIKILINK_RE = /(!?)\[\[([^\]\n]+)\]\]/g;
2407
2356
  var DEFAULT_BODY_TAG_RE = /(?:^|[\s([{,;。,;])#([\p{L}_][\p{L}\p{N}_/-]*)/gu;
2408
2357
  function buildBodyTagRe(userPattern) {