fix(lint): close display math on more than a bare $$ line - #1149
Open
ChrisJr404 wants to merge 1 commit into
Open
fix(lint): close display math on more than a bare $$ line#1149ChrisJr404 wants to merge 1 commit into
ChrisJr404 wants to merge 1 commit into
Conversation
goldmark-mathjax's block parser only ever closed `$$…$$` display math on a
line that held nothing but `$$`. Every other Pandoc shape -- an opener that
also closes (`$$x=1$$`), a content line ending in `$$` (`\end{aligned}$$`),
and a `$$ … $$ {#eq-foo}` label -- left the block open, and an unclosed block
consumes the rest of the file, so everything after the equation went unlinted.
Replace it with an in-tree block parser, as was already done for inline math,
that recognizes each of those closes while still keeping the bare-`$$` line as
markup. Closes vale-cli#1148.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Recognize every place Pandoc closes a
$$…$$display-math block, so an equation no longer leaves the block open and hides the rest of the file from linting.Since v3.15.2 (#878) display math is parsed by goldmark-mathjax's block parser, which only closes the block on a line that contains nothing but
$$. That misses the ordinary Pandoc shapes reported in #1148:$$x=1$$— opener and closer on one line$$\begin{aligned} … \end{aligned}$$— the closing$$ends a content line$$ … $$ {#eq-foo}— a Pandoc/Quarto cross-reference label after the closeIn each case the block stays open, and an open block consumes everything to the end of the document, so all the prose past the equation goes unchecked.
Rather than patch around the third-party parser, this replaces it with an in-tree block parser — the same move already made for inline math, and for the reason the file's comment already gives. The new parser produces the same
mathjax.MathBlocknode the renderer knows how to skip, keeps a bare$$line as markup exactly as before, and additionally closes on an opener that also closes, on a content line ending in$$, and after an optional trailing{…}label.Testing
internal/lint/math_test.gogainsTestMathBlock, which runs each shape above (plus the existing bare-$$block, to pin that it still behaves) through the Quarto renderer and asserts both that the equation renders as skippedpreand that the paragraph after it survives as prose.go test ./internal/lint/andgolangci-lint run ./internal/lint/both pass.Closes #1148.