fix(shared): keep footnotes in GFM tables after unmatched backticks #48263
Opensaphid(GitHub profile, opens in a new tab)wants to merge 3 commits into
main fromrefs/pull/48263/headopened View on GitHubtanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- @@ -1043,4 +1051,10 @@10431051 refs.push(...extractFootnoteRefs(block.join("\n"), capturedFootnoteKeys));10441052 block = [];10451053 };1054+ let tableColumns = 0;10461055 for (let i = start; i < end; i++) {1056+ if (isBodyLine[i] === 4) {1057+ flushBlock();1058+ const cells = splitTableCells(sourceLines[i]!);1059+ if (i === start || isBodyLine[i - 1] !== 4) tableColumns = cells.length;1060+ for (const cell of cells.slice(0, tableColumns))
Pushed17d84f7
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- @@ -364,0 +379,21 @@379+ let closed = -1;380+ for (let j = i + 2; j < trimmed.length; j++) {381+ if (trimmed[j] === "\\") {382+ if (trimmed[j + 1] === closeChar) {383+ closed = j + 1;384+ break;385+ }386+ j++;387+ }388+ }389+ if (closed !== -1) {390+ i = closed;391+ continue;392+ }393+ if (next === "(") parenMathUnclosed = true;394+ else bracketMathUnclosed = true;395+ }396+ i++;397+ continue;398+ }399+ if (ch === "$") {
- @@ -364,0 +379,21 @@379+ let closed = -1;380+ for (let j = i + 2; j < trimmed.length; j++) {381+ if (trimmed[j] === "\\") {382+ if (trimmed[j + 1] === closeChar) {383+ closed = j + 1;384+ break;385+ }386+ j++;387+ }388+ }389+ if (closed !== -1) {390+ i = closed;391+ continue;392+ }393+ if (next === "(") parenMathUnclosed = true;394+ else bracketMathUnclosed = true;395+ }396+ i++;397+ continue;398+ }399+ if (ch === "$") {@@ -364,0 +394,21 @@394+ else bracketMathUnclosed = true;395+ }396+ i++;397+ continue;398+ }399+ if (ch === "$") {400+ let run = 1;401+ while (trimmed[i + run] === "$") run++;402+ if (run === 1 && !singleMathUnclosed) {403+ const next = trimmed[i + 1];404+ if (next !== undefined && next !== " " && next !== "\t") {405+ let closed = -1;406+ for (let j = i + 1; j < trimmed.length; j++) {407+ if (trimmed[j] === "\\") {408+ j++;409+ continue;410+ }411+ if (trimmed[j] === "$") {412+ let endRun = 1;413+ while (trimmed[j + endRun] === "$") endRun++;414+ if (endRun === 1 && trimmed[j - 1] !== " " && trimmed[j - 1] !== "\t") {
Pushed9199b4c
- @@ -364,0 +569,21 @@569+ else bracketMathFailedUntil = j;570+ }571+ i++;572+ continue;573+ }574+ if (ch === "$") {575+ let run = 1;576+ while (trimmed[i + run] === "$") run++;577+ if (!isInLiteralRange(i)) {578+ if (run === 1 && !singleMathUnclosed) {579+ const next = trimmed[i + 1];580+ if (next !== undefined && next !== " " && next !== "\t" && next !== ",") {581+ let closed = -1;582+ let j = i + 1;583+ for (; j < trimmed.length; j++) {584+ if (trimmed[j] === "`") break;585+ if (trimmed[j] === "\\" && (trimmed[j + 1] === "\\" || trimmed[j + 1] === "$")) {586+ j++;587+ continue;588+ }589+ if (trimmed[j] === "$") {@@ -364,0 +482,21 @@482+ if (close !== -1) end = close + 3;483+ else unclosedComment = true;484+ }485+ } else if (text.startsWith("<?", i)) {486+ if (!unclosedPi) {487+ const close = text.indexOf("?>", i + 2);488+ if (close !== -1) end = close + 2;489+ else unclosedPi = true;490+ }491+ } else if (text.startsWith("<![CDATA[", i)) {492+ if (!unclosedCdata) {493+ const close = text.indexOf("]]>", i + 9);494+ if (close !== -1) end = close + 3;495+ else unclosedCdata = true;496+ }497+ } else {498+ end = matchStickyAt(TABLE_URI_AUTOLINK, text, i);499+ if (end === -1) end = matchStickyAt(TABLE_EMAIL_AUTOLINK, text, i);500+ if (end === -1) end = matchStickyAt(TABLE_HTML_OPEN_TAG, text, i);501+ if (end === -1) end = matchStickyAt(TABLE_HTML_CLOSE_TAG, text, i);502+ if (end === -1) end = matchStickyAt(TABLE_HTML_DECLARATION, text, i);
- @@ -364,0 +564,21 @@564+ if (closed !== -1) {565+ i = closed;566+ continue;567+ }568+ if (next === "(") parenMathFailedUntil = j;569+ else bracketMathFailedUntil = j;570+ }571+ i++;572+ continue;573+ }574+ if (ch === "$") {575+ let run = 1;576+ while (trimmed[i + run] === "$") run++;577+ if (!isInLiteralRange(i)) {578+ if (run === 1 && !singleMathUnclosed) {579+ const next = trimmed[i + 1];580+ if (next !== undefined && next !== " " && next !== "\t" && next !== ",") {581+ let closed = -1;582+ let j = i + 1;583+ for (; j < trimmed.length; j++) {584+ if (trimmed[j] === "`") break;@@ -364,0 +576,21 @@576+ while (trimmed[i + run] === "$") run++;577+ if (!isInLiteralRange(i)) {578+ if (run === 1 && !singleMathUnclosed) {579+ const next = trimmed[i + 1];580+ if (next !== undefined && next !== " " && next !== "\t" && next !== ",") {581+ let closed = -1;582+ let j = i + 1;583+ for (; j < trimmed.length; j++) {584+ if (trimmed[j] === "`") break;585+ if (trimmed[j] === "\\" && (trimmed[j + 1] === "\\" || trimmed[j + 1] === "$")) {586+ j++;587+ continue;588+ }589+ if (trimmed[j] === "$") {590+ let endRun = 1;591+ while (trimmed[j + endRun] === "$") endRun++;592+ if (endRun === 1) {593+ if (594+ trimmed[j - 1] !== " " &&595+ trimmed[j - 1] !== "\t" &&596+ !isAsciiDigit(trimmed[j + 1])
Pushedfb4ba24
- @@ -364,0 +471,21 @@471+ while (text[j + run] === "`") run++;472+ if (run === ticks) {473+ closed = j + run;474+ break;475+ }476+ j += run;477+ continue;478+ }479+ j++;480+ }481+ if (closed !== -1) {482+ ranges.push([i, closed]);483+ i = closed - 1;484+ continue;485+ }486+ unclosedBackticks.add(ticks);487+ }488+ i += ticks - 1;489+ continue;490+ }491+ if (ch === "<") {@@ -364,0 +603,21 @@603+ continue;604+ }605+ if (trimmed[j] === "$") {606+ let endRun = 1;607+ while (trimmed[j + endRun] === "$") endRun++;608+ if (endRun === 1) {609+ if (isDollarMathCloser(trimmed[j - 1], trimmed[j + 1], false)) {610+ closed = j;611+ }612+ break;613+ }614+ j += endRun - 1;615+ }616+ }617+ if (closed !== -1) {618+ i = closed;619+ continue;620+ }621+ if (j >= trimmed.length) singleMathUnclosed = true;622+ }623+ } else if (run === 2 && !doubleMathUnclosed) {
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed