stream-markdown-parser 0.0.54 → 0.0.56

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
@@ -6756,21 +6756,27 @@ function applyContainers(md) {
6756
6756
  if (!nameMatch) return false;
6757
6757
  const name = nameMatch[1];
6758
6758
  if (!name.trim()) return false;
6759
- const rest = line.slice(nameMatch[0].length);
6759
+ const trimmedRest = line.slice(nameMatch[0].length).trim();
6760
+ let argsStr;
6760
6761
  let jsonStr;
6761
- const trimmedRest = rest.trim();
6762
- if (trimmedRest.startsWith("{")) {
6763
- let depth = 0;
6764
- let jsonEnd = -1;
6765
- for (let i = 0; i < trimmedRest.length; i++) {
6766
- if (trimmedRest[i] === "{") depth++;
6767
- else if (trimmedRest[i] === "}") depth--;
6768
- if (depth === 0) {
6769
- jsonEnd = i + 1;
6770
- break;
6762
+ const jsonStart = trimmedRest.indexOf("{");
6763
+ const jsonCandidate = jsonStart >= 0 ? trimmedRest.slice(jsonStart).trimStart() : void 0;
6764
+ if (jsonStart === -1) argsStr = trimmedRest || void 0;
6765
+ else {
6766
+ argsStr = trimmedRest.slice(0, jsonStart).trim() || void 0;
6767
+ if (jsonCandidate?.startsWith("{")) {
6768
+ let depth = 0;
6769
+ let jsonEnd = -1;
6770
+ for (let i = 0; i < jsonCandidate.length; i++) {
6771
+ if (jsonCandidate[i] === "{") depth++;
6772
+ else if (jsonCandidate[i] === "}") depth--;
6773
+ if (depth === 0) {
6774
+ jsonEnd = i + 1;
6775
+ break;
6776
+ }
6771
6777
  }
6778
+ if (jsonEnd > 0) jsonStr = jsonCandidate.slice(0, jsonEnd);
6772
6779
  }
6773
- if (jsonEnd > 0) jsonStr = trimmedRest.slice(0, jsonEnd);
6774
6780
  }
6775
6781
  if (silent) return true;
6776
6782
  let nextLine = startLine + 1;
@@ -6787,6 +6793,7 @@ function applyContainers(md) {
6787
6793
  if (!found) return false;
6788
6794
  const tokenOpen = s.push("vmr_container_open", "div", 1);
6789
6795
  tokenOpen.attrSet("class", `vmr-container vmr-container-${name}`);
6796
+ if (argsStr) tokenOpen.attrSet("data-args", argsStr);
6790
6797
  if (jsonStr) try {
6791
6798
  const attrs = JSON.parse(jsonStr);
6792
6799
  for (const [key, value] of Object.entries(attrs)) {
@@ -11462,6 +11469,10 @@ function getMarkdown(msgId = `editor-${Date.now()}`, options = {}) {
11462
11469
  if (s.src[s.pos] !== "[") return false;
11463
11470
  const match = RE_REFERENCE.exec(s.src.slice(s.pos));
11464
11471
  if (!match) return false;
11472
+ const lookbehind = s.src.slice(Math.max(0, s.pos - 120), s.pos);
11473
+ if (/"[^"\n]{1,80}"\s*:\s*$/.test(lookbehind)) return false;
11474
+ const afterMatch = s.src.slice(s.pos + match[0].length);
11475
+ if (afterMatch.startsWith("](") || afterMatch.startsWith("(") || afterMatch.startsWith("[")) return false;
11465
11476
  if (!silent) {
11466
11477
  const id = match[1];
11467
11478
  const token = s.push("reference", "span", 0);