scdoc: require document preamble before guessing by jnohclee-rgb · Pull Request #3409 · pygments/pygments · GitHub
Skip to content

scdoc: require document preamble before guessing - #3409

Open
jnohclee-rgb wants to merge 1 commit into
pygments:masterfrom
jnohclee-rgb:dharma/scdoc2855-no-header
Open

jnohclee-rgb wants to merge 1 commit into
pygments:masterfrom
jnohclee-rgb:dharma/scdoc2855-no-header

Conversation

@jnohclee-rgb

Copy link
Copy Markdown

Scdoc guessing currently gains confidence from any underscore or asterisk, even without its mandatory document header. Require the existing preamble match before applying those weak markup signals, preserving valid-header scores and tokenization.

Refs #2855. This removes false scdoc confidence for the reported Python snippet; it does not promise that short snippet will be recognized as Python.

Validation: 24 new regression cases cover missing/malformed headers, valid headers with optional fields and markup, and the reported underscore case. The new/guess suites passed (712 passed, 7 skipped); existing lexer API, regex lexer, and scdoc golden tests passed (2,455 passed, 8 skipped). Source checks and git diff --check passed. Full tox was not run.

AI assistance: Codex prepared this patch and tests, with a separate source review. No maintainer acceptance is implied.

Dharma — leave the code kinder than we found it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant