@vscode/markdown-editor 0.0.2-55 → 0.0.2-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.d.ts CHANGED
@@ -262,13 +262,20 @@ export declare interface BlockViewOptions {
262
262
  }
263
263
 
264
264
  export declare class CodeBlockAstNode extends BlockAstNodeBase {
265
+ /** First token of the fenced code block info string, used for syntax highlighting. */
265
266
  readonly language: string;
267
+ /** Complete fenced code block info string, including metadata after the language token. */
268
+ readonly infoString: string;
266
269
  readonly content: readonly (MarkerAstNode | GlueAstNode)[];
267
270
  readonly leadingTrivia?: GlueAstNode | undefined;
268
271
  readonly kind = "codeBlock";
269
272
  private _previous?;
270
273
  private _contentEdit?;
271
- constructor(language: string, content: readonly (MarkerAstNode | GlueAstNode)[], leadingTrivia?: GlueAstNode | undefined);
274
+ constructor(
275
+ /** First token of the fenced code block info string, used for syntax highlighting. */
276
+ language: string,
277
+ /** Complete fenced code block info string, including metadata after the language token. */
278
+ infoString: string, content: readonly (MarkerAstNode | GlueAstNode)[], leadingTrivia?: GlueAstNode | undefined);
272
279
  get children(): readonly AstNode[];
273
280
  get openFence(): MarkerAstNode | undefined;
274
281
  get closeFence(): MarkerAstNode | undefined;
@@ -1910,10 +1917,10 @@ declare interface IEmbeddedCodeEditor {
1910
1917
  /** Creates an {@link IEmbeddedCodeEditor} for a fenced block, or opts out. */
1911
1918
  declare interface IEmbeddedCodeEditorFactory {
1912
1919
  /**
1913
- * Return an editor for a fenced block of `language`, or `undefined` to fall
1920
+ * Return an editor for a fenced block, or `undefined` to fall
1914
1921
  * back to the default (highlighting / {@link BlockViewOptions.renderCustomCodeBlock}).
1915
1922
  */
1916
- create(language: string, initialContent: string): IEmbeddedCodeEditor | undefined;
1923
+ create(language: string, infoString: string, initialContent: string): IEmbeddedCodeEditor | undefined;
1917
1924
  }
1918
1925
 
1919
1926
  /**
package/dist/index.js CHANGED
@@ -487,8 +487,8 @@ class Ee extends j {
487
487
  }
488
488
  }
489
489
  class Y extends j {
490
- constructor(e, t, n) {
491
- super(), this.language = e, this.content = t, this.leadingTrivia = n;
490
+ constructor(e, t, n, i) {
491
+ super(), this.language = e, this.infoString = t, this.content = n, this.leadingTrivia = i;
492
492
  }
493
493
  kind = "codeBlock";
494
494
  _previous;
@@ -516,13 +516,13 @@ class Y extends j {
516
516
  return e;
517
517
  }
518
518
  mapChildren(e) {
519
- return new Y(this.language, P(e, this.content), ne(e, this.leadingTrivia));
519
+ return new Y(this.language, this.infoString, P(e, this.content), ne(e, this.leadingTrivia));
520
520
  }
521
521
  withLeadingTrivia(e) {
522
- return new Y(this.language, this.content, e);
522
+ return new Y(this.language, this.infoString, this.content, e);
523
523
  }
524
524
  _localEquals(e) {
525
- return this.language === e.language;
525
+ return this.language === e.language && this.infoString === e.infoString;
526
526
  }
527
527
  /**
528
528
  * A copy of this block carrying an incremental link to `previous`:
@@ -801,7 +801,7 @@ function ms(s, e) {
801
801
  }
802
802
  case "codeBlock": {
803
803
  const t = s;
804
- return new Y(t.language, [...t.content, e], t.leadingTrivia);
804
+ return new Y(t.language, t.infoString, [...t.content, e], t.leadingTrivia);
805
805
  }
806
806
  case "frontMatter": {
807
807
  const t = s;
@@ -1013,33 +1013,36 @@ class Oi {
1013
1013
  }
1014
1014
  _parseCodeFenced() {
1015
1015
  const e = this._consume("enter", "codeFenced");
1016
- let t = "";
1017
- const n = new I(e.startOffset, this._source);
1018
- let i = !1, o, r;
1016
+ let t = "", n, i;
1017
+ const o = new I(e.startOffset, this._source);
1018
+ let r = !1, c, a;
1019
1019
  for (; this._notExit("codeFenced"); ) {
1020
- const a = this._events[this._idx];
1021
- if (a.type === "enter" && a.tokenType === "codeFencedFence") {
1022
- const l = this._consume("enter", "codeFencedFence");
1020
+ const u = this._events[this._idx];
1021
+ if (u.type === "enter" && u.tokenType === "codeFencedFence") {
1022
+ const h = this._consume("enter", "codeFencedFence");
1023
1023
  for (; this._notExit("codeFencedFence"); ) {
1024
- const u = this._events[this._idx];
1025
- if (u.type === "enter" && u.tokenType === "codeFencedFenceInfo") {
1026
- for (this._consume("enter", "codeFencedFenceInfo"); this._notExit("codeFencedFenceInfo"); ) {
1027
- const h = this._events[this._idx];
1028
- h.tokenType === "data" && (t = this._source.substring(h.startOffset, h.endOffset)), this._idx++;
1024
+ const m = this._events[this._idx];
1025
+ if (m.type === "enter" && (m.tokenType === "codeFencedFenceInfo" || m.tokenType === "codeFencedFenceMeta")) {
1026
+ const g = m.tokenType, _ = this._consume("enter", g);
1027
+ for (n ??= _.startOffset; this._notExit(g); ) {
1028
+ const p = this._events[this._idx];
1029
+ g === "codeFencedFenceInfo" && p.type === "enter" && p.tokenType === "data" && (t += this._source.substring(p.startOffset, p.endOffset)), this._idx++;
1029
1030
  }
1030
- this._consume("exit", "codeFencedFenceInfo");
1031
+ i = this._consume("exit", g).endOffset;
1031
1032
  } else
1032
1033
  this._idx++;
1033
1034
  }
1034
- const d = this._consume("exit", "codeFencedFence");
1035
- n.add(new E(
1036
- i ? "closeFence" : "openFence",
1037
- this._source.substring(l.startOffset, d.endOffset)
1038
- ), l.startOffset), i = !0;
1039
- } else a.tokenType === "codeFlowValue" || a.tokenType === "lineEnding" ? (o === void 0 && (o = a.startOffset), r = a.endOffset, this._idx++) : this._idx++;
1040
- }
1041
- const c = this._consume("exit", "codeFenced");
1042
- return o !== void 0 && n.add(new E("content", this._source.substring(o, r)), o), new Y(t, n.build(c.endOffset - e.startOffset));
1035
+ const f = this._consume("exit", "codeFencedFence");
1036
+ o.add(new E(
1037
+ r ? "closeFence" : "openFence",
1038
+ this._source.substring(h.startOffset, f.endOffset)
1039
+ ), h.startOffset), r = !0;
1040
+ } else u.tokenType === "codeFlowValue" || u.tokenType === "lineEnding" ? (c === void 0 && (c = u.startOffset), a = u.endOffset, this._idx++) : this._idx++;
1041
+ }
1042
+ const l = this._consume("exit", "codeFenced");
1043
+ c !== void 0 && o.add(new E("content", this._source.substring(c, a)), c);
1044
+ const d = n === void 0 ? "" : this._source.substring(n, i);
1045
+ return new Y(t, d, o.build(l.endOffset - e.startOffset));
1043
1046
  }
1044
1047
  /**
1045
1048
  * An indented code block has no fences and no info string: micromark strips a
@@ -1065,7 +1068,7 @@ class Oi {
1065
1068
  }
1066
1069
  o();
1067
1070
  const r = this._consume("exit", "codeIndented");
1068
- return new Y("", t.build(r.endOffset - e.startOffset));
1071
+ return new Y("", "", t.build(r.endOffset - e.startOffset));
1069
1072
  }
1070
1073
  _parseMathFlow() {
1071
1074
  const e = this._consume("enter", "mathFlow"), t = new I(e.startOffset, this._source);
@@ -1486,7 +1489,7 @@ function ps(s, e, t, n, i) {
1486
1489
  }
1487
1490
  function Ni(s, e, t, n) {
1488
1491
  const i = e.code, o = s.code;
1489
- if (!i || !o || s.language !== e.language || s.openFence?.content !== e.openFence?.content || s.closeFence?.content !== e.closeFence?.content)
1492
+ if (!i || !o || s.infoString !== e.infoString || s.openFence?.content !== e.openFence?.content || s.closeFence?.content !== e.closeFence?.content)
1490
1493
  return;
1491
1494
  const r = t + e.codeOffset, c = r + i.length;
1492
1495
  if (!Ii(n, r, c))
@@ -3752,7 +3755,7 @@ class qt extends R {
3752
3755
  constructor(e, t, n) {
3753
3756
  const i = e.ast, o = i.code?.content ?? "", r = n instanceof qt ? n : void 0, c = t?.embeddedCodeEditorReadOnly ?? !1, a = sr(o);
3754
3757
  let l;
3755
- !e.showMarkup && i.language && i.code && a.sourceOffset > 0 && t?.embeddedCodeEditorFactory && (r?._embeddedEditor && Object.is(t.embeddedCodeEditorFactoryVersion, r._embeddedEditorFactoryVersion) && (i === r.ast || i.getDiff(r.ast)) ? (l = r._embeddedEditor, r._embeddedEditor = void 0) : l = t.embeddedCodeEditorFactory.create(i.language, a.text) ?? void 0), r?._embeddedEditor && (r._embeddedEditor.dispose(), r._embeddedEditor = void 0);
3758
+ !e.showMarkup && i.language && i.code && a.sourceOffset > 0 && t?.embeddedCodeEditorFactory && (r?._embeddedEditor && Object.is(t.embeddedCodeEditorFactoryVersion, r._embeddedEditorFactoryVersion) && (i === r.ast || i.getDiff(r.ast)) ? (l = r._embeddedEditor, r._embeddedEditor = void 0) : l = t.embeddedCodeEditorFactory.create(i.language, i.infoString, a.text) ?? void 0), r?._embeddedEditor && (r._embeddedEditor.dispose(), r._embeddedEditor = void 0);
3756
3759
  const d = !l && !e.showMarkup && i.language && t?.renderCustomCodeBlock ? t.renderCustomCodeBlock(i.language, o) ?? void 0 : void 0, u = t?.syntaxHighlighter;
3757
3760
  let h;
3758
3761
  if (!l && !d && u && i.language) {