Files
skills/.github/skills/blume-migrate/assets/oxfmt@0.67.0.patch
T

50 lines
3.2 KiB
Diff

diff --git a/dist/markdown-BMigo7Hm.js b/dist/markdown-BMigo7Hm.js
index bc9037f6c0de5516b139d8cdb195b1e25cd33bc0..a02c284e28bb535f9964a8a086ebb6549657e416 100644
--- a/dist/markdown-BMigo7Hm.js
+++ b/dist/markdown-BMigo7Hm.js
@@ -4872,7 +4872,43 @@ function lu(e, t, r) {
case "sentence": return Oh(e, r);
case "word": return t.parser !== "mdx" ? zh(e, t) : Uh(e);
case "whitespace": {
- let { next: a } = e, u = a && /^>|^(?:[*+-]|#{1,6}|\d+[).])$/.test(a.value) && !NE(e) && !(t.proseWrap === "preserve" && RE(e)) ? "never" : t.proseWrap;
+ let { next: a, previous: oxfmtFencePrev } = e;
+ // Preserve line breaks that sit directly against a `:::` container
+ // directive fence, so `proseWrap: "never"` keeps the opening/closing
+ // fence on their own lines instead of joining them into the prose (which
+ // breaks the directive). Ordinary prose still wraps per proseWrap.
+ // See prettier/prettier#19040.
+ let oxfmtIsFence = (w) => w != null && typeof w.value === "string" && w.value.startsWith(":::");
+ // A titled directive (`:::warning[Heads up]`) parses its `[title]` as a
+ // linkReference between two sentence nodes at the paragraph level: the
+ // fence word ends the sentence before the reference, and the body's
+ // leading newline opens the sentence after it. So when this whitespace
+ // starts its sentence, climb to the paragraph and check whether the two
+ // preceding siblings are a (link) reference and a sentence ending in a
+ // `:::` fence word.
+ let oxfmtPrevIsTitledFence = !1;
+ if (oxfmtFencePrev == null && e.index === 0 && e.grandparent != null && Array.isArray(e.grandparent.children)) {
+ let oxfmtSibs = e.grandparent.children, oxfmtSentIdx = oxfmtSibs.indexOf(e.parent);
+ if (oxfmtSentIdx >= 2) {
+ let oxfmtLink = oxfmtSibs[oxfmtSentIdx - 1], oxfmtBefore = oxfmtSibs[oxfmtSentIdx - 2];
+ let oxfmtLastWord = oxfmtBefore && oxfmtBefore.type === "sentence" && Array.isArray(oxfmtBefore.children) ? oxfmtBefore.children[oxfmtBefore.children.length - 1] : null;
+ oxfmtPrevIsTitledFence = oxfmtLink != null && (oxfmtLink.type === "linkReference" || oxfmtLink.type === "link") && oxfmtIsFence(oxfmtLastWord);
+ }
+ }
+ // The plain-markdown parser keeps a titled fence's `[title]` as literal
+ // words, so the whole directive is one sentence. For a newline
+ // whitespace, walk back to the start of its visual line within the
+ // sentence; a line led by a `:::` word is a fence whose break must stay.
+ if (!oxfmtPrevIsTitledFence && e.node.value.includes("\n") && e.parent != null && Array.isArray(e.parent.children)) {
+ let oxfmtLineFirst = null;
+ for (let oxfmtJ = e.index - 1; oxfmtJ >= 0; oxfmtJ--) {
+ let oxfmtSib = e.parent.children[oxfmtJ];
+ if (oxfmtSib.type === "whitespace" && typeof oxfmtSib.value === "string" && oxfmtSib.value.includes("\n")) break;
+ oxfmtLineFirst = oxfmtSib;
+ }
+ oxfmtPrevIsTitledFence = oxfmtIsFence(oxfmtLineFirst);
+ }
+ let u = oxfmtIsFence(oxfmtFencePrev) || oxfmtPrevIsTitledFence || oxfmtIsFence(a) ? "preserve" : a && /^>|^(?:[*+-]|#{1,6}|\d+[).])$/.test(a.value) && !NE(e) && !(t.proseWrap === "preserve" && RE(e)) ? "never" : t.proseWrap;
return ou(e, n.value, u, !1, t);
}
case "emphasis": {