@quartz-community/remark-obsidian 2.0.0 → 2.0.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/dist/index.js CHANGED
@@ -8246,6 +8246,12 @@ function keys(value2) {
8246
8246
  return result;
8247
8247
  }
8248
8248
 
8249
+ // src/lib/tag-char.ts
8250
+ var TAG_STOP = /[\u2000-\u206F\u2E00-\u2E7F'!"#$%&()*+,.:;<=>?@^`{|}~[\]\\\s]/u;
8251
+ function isTagCharacter(char) {
8252
+ return char !== "" && !TAG_STOP.test(char);
8253
+ }
8254
+
8249
8255
  // src/rp8/reader.ts
8250
8256
  function along(point, columns2) {
8251
8257
  return {
@@ -8460,14 +8466,13 @@ function highlights(tables) {
8460
8466
  "highlight"
8461
8467
  );
8462
8468
  }
8463
- var TAG_CHAR = /[\p{L}\p{M}\p{Emoji}\p{N}_\-/]/u;
8464
8469
  function tags(tables) {
8465
8470
  const tag2 = function(eat, value2, silent) {
8466
8471
  if (value2.charAt(0) !== "#") return void 0;
8467
8472
  let end = 1;
8468
8473
  let nonDigit = false;
8469
8474
  for (const ch of value2.slice(1)) {
8470
- if (ch === "#" || ch === "*" || !TAG_CHAR.test(ch)) break;
8475
+ if (!isTagCharacter(ch)) break;
8471
8476
  if (!/[0-9]/u.test(ch)) nonDigit = true;
8472
8477
  end += ch.length;
8473
8478
  }
@@ -10828,10 +10833,6 @@ function tokenizeNonLazyContinuation(effects, ok3, nok) {
10828
10833
  // src/lib/syntax/tag.ts
10829
10834
  var HASH2 = 35;
10830
10835
  var SLASH2 = 47;
10831
- var DASH = 45;
10832
- var UNDERSCORE = 95;
10833
- var ASTERISK = 42;
10834
- var tagCharRegex = /[\p{L}\p{M}\p{Emoji}]/u;
10835
10836
  var LABEL_OPENERS = /* @__PURE__ */ new Set(["labelLink", "labelImage"]);
10836
10837
  function insideDoubledOpener(events) {
10837
10838
  let index = events.length - 1;
@@ -10857,11 +10858,8 @@ function isWhitespace(code2) {
10857
10858
  }
10858
10859
  function isTagChar(code2) {
10859
10860
  if (code2 === null || code2 < 0) return false;
10860
- if (code2 >= 48 && code2 <= 57) return true;
10861
- if (code2 === DASH || code2 === UNDERSCORE) return true;
10862
- if (code2 === HASH2 || code2 === ASTERISK) return false;
10863
10861
  if (code2 >= 55296 && code2 <= 57343) return true;
10864
- return tagCharRegex.test(String.fromCodePoint(code2));
10862
+ return isTagCharacter(String.fromCharCode(code2));
10865
10863
  }
10866
10864
  function isNonDigit(code2) {
10867
10865
  if (code2 === null) return false;
@@ -12032,6 +12030,18 @@ var RESTORE = new Map(
12032
12030
  ])
12033
12031
  );
12034
12032
  var PLACEHOLDER_IN = /[\uE000-\uE005]/u;
12033
+ function restoreHints(nodes) {
12034
+ for (const node2 of nodes) {
12035
+ const hast = node2;
12036
+ if (hast.type === "text" && typeof hast.value === "string") {
12037
+ hast.value = hast.value.replace(
12038
+ PLACEHOLDER_ALL,
12039
+ (c) => RESTORE.get(c) ?? c
12040
+ );
12041
+ }
12042
+ if (Array.isArray(hast.children)) restoreHints(hast.children);
12043
+ }
12044
+ }
12035
12045
  var PLACEHOLDER_ALL = /[\uE000-\uE005]/gu;
12036
12046
  function lineTable(source) {
12037
12047
  const starts = [0];
@@ -12608,6 +12618,8 @@ function mapBack(tree, edited, lines) {
12608
12618
  );
12609
12619
  }
12610
12620
  }
12621
+ const hints = record.data?.hChildren;
12622
+ if (hints) restoreHints(hints);
12611
12623
  for (const child of node2.children ?? []) visit2(child);
12612
12624
  };
12613
12625
  visit2(tree);
@@ -12639,6 +12651,22 @@ function lineOfOffset(text4, offset) {
12639
12651
  return line;
12640
12652
  }
12641
12653
 
12654
+ // src/lib/math-value.ts
12655
+ function setMathValue(node2, value2) {
12656
+ const math3 = node2;
12657
+ math3.value = value2;
12658
+ const leaf = textLeaf(math3.data?.hChildren);
12659
+ if (leaf) leaf.value = value2;
12660
+ }
12661
+ function textLeaf(nodes) {
12662
+ for (const node2 of nodes ?? []) {
12663
+ if (node2.type === "text") return node2;
12664
+ const inner = textLeaf(node2.children);
12665
+ if (inner) return inner;
12666
+ }
12667
+ return void 0;
12668
+ }
12669
+
12642
12670
  // src/lib/math-fence.ts
12643
12671
  var DOLLAR = "$";
12644
12672
  function mathFenceTransform(tree, source) {
@@ -12688,7 +12716,7 @@ function mathFenceTransform(tree, source) {
12688
12716
  if (!closes2 || start !== end) body.push(line.slice(start, end));
12689
12717
  if (closes2) break;
12690
12718
  }
12691
- math3.value = body.join("\n");
12719
+ setMathValue(math3, body.join("\n"));
12692
12720
  math3.meta = null;
12693
12721
  });
12694
12722
  }
@@ -13339,8 +13367,15 @@ function mathMidlineTransform(tree, source) {
13339
13367
  const openerStart = map3.starts[opener2] + lines[opener2].length - "$$".length;
13340
13368
  const kept = phrasingBefore(paragraph3, openerStart, source);
13341
13369
  if (!kept) continue;
13342
- const body = lines.slice(opener2 + 1).join("\n");
13343
- math3.value = body;
13370
+ const content = (paragraph3.position?.start?.column ?? 1) - 1;
13371
+ const body = lines.slice(opener2 + 1).map((text4, at3) => {
13372
+ const from = map3.starts[opener2 + 1 + at3];
13373
+ const prefix2 = from - (source.lastIndexOf("\n", from - 1) + 1);
13374
+ let strip = 0;
13375
+ while (strip < content - prefix2 && text4[strip] === " ") strip++;
13376
+ return text4.slice(strip);
13377
+ }).join("\n");
13378
+ setMathValue(math3, body);
13344
13379
  if (math3.position) {
13345
13380
  math3.position.start = {
13346
13381
  line: map3.lines[opener2],