Address issue #306: Make dollar-sign math highlighting conditional#317
Merged
Merged
Conversation
Add pmh_EXT_MATH extension flag to PEG Markdown Highlight so that dollar-sign math rules ($...$ and $$...$$) are only active when the user has enabled both MathJax and inline-dollar preferences. When math is disabled, $ is treated as a normal character instead of a special one, preventing unpaired dollar signs from disrupting syntax highlighting. Also constrain Dollar1Math to single-line matching so that even with math enabled, an unpaired $ only affects the current line rather than corrupting the entire document. Related to #306
Without observing htmlMathJax and htmlMathJaxInlineDollar, toggling these preferences in the UI would not trigger setupEditor: to update the highlighter's extension flags. The math highlighting change would only take effect incidentally when another preference change occurred. Related to #306
Contributor
Code Coverage ReportCurrent Coverage: 54.52% Coverage Details (Summary) |
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.
Summary
pmh_EXT_MATHextension flag to PEG Markdown Highlight so dollar-sign math rules ($...$and$$...$$) are only active when both MathJax and inline-dollar preferences are enabledDollar1Mathto single-line matching so an unpaired$only affects the current line, even with math enabled$a normal character (notSpecialChar) when math is disabled, preventing it from disrupting the highlighting state machinehtmlMathJaxandhtmlMathJaxInlineDollarto the editor KVO observation set so toggling preferences updates highlighting immediatelyRelated Issue
Related to #306
Manual Testing Plan
Prerequisites
Key Scenarios
$with math disabled$treated as normal text$with math enabled$...$inline math$$...$$display math$treated as plain text (math grammar inactive)$inside code blocks/spans