Cap ordered list mark at 999,999,999 (#19351)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: fisker <lionkay@gmail.com>
This commit is contained in:
authored and GitHub committed 2026-06-29 20:34:47 +08:00
1 parent 04857eeb00
commit e6e57764f4
5 files changed
+111 -2

No files matched your search

+8 -2
View File
@@ -10,6 +10,10 @@ import { printChildren } from "./children.js";
* @import {Doc} from "../../document/index.js"
*/
// 999,999,999 is the maximum number that can be parsed as a list item number as intended in CommonMark
// https://spec.commonmark.org/0.31.2/#ordered-list-marker
const MAXIMUM_ORDERED_LIST_MARKER = 999_999_999;
/**
* @param {AstPath} path
* @param {*} options
@@ -55,8 +59,10 @@ function printList(path, options, print) {
? node.start
: isGitDiffFriendlyOrderedList
? 1
: node.start + path.index) +
(nthSiblingIndex % 2 === 0 ? ". " : ") ")
: Math.min(
node.start + path.index,
MAXIMUM_ORDERED_LIST_MARKER,
)) + (nthSiblingIndex % 2 === 0 ? ". " : ") ")
: nthSiblingIndex % 2 === 0
? "- "
: "* ";