Preserve inline code delimiters and significant whitespace - #152
Merged
Merged
Conversation
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.
Inline code currently applies
trim()to the entire code-span body and allows its backtick regex to split a delimiter run. As a result, whitespace examples lose their contents, two unmatched backticks become an empty code element, and a longer run inside a code example can prematurely close it. This changes literal snippets in job descriptions and resumes.Match whole backtick runs of equal length, retaining unmatched runs as ordinary text. Precompute the next run of each length so unmatched openers do not repeatedly scan the remaining text. Normalize code-span whitespace using CommonMark's rule: convert line endings to spaces, then remove one leading and one trailing ASCII space only when both exist and the content is not entirely spaces. Preserve tabs, non-breaking spaces, one-sided padding, and additional spaces.
Validation: reproduced lost padding and all-space contents before the initial fix. Added 11 delimiter tests; 7 fail on the earlier whitespace-only patch and all 11 pass with the delimiter correction. Both existing code-span tests also pass, including ASCII padding, all-space contents, one-sided padding, tabs, NBSP, literal markup, and CRLF/CR/LF normalization. TypeScript build, no-emit typecheck and formatting checks pass. The surrounding block parser is unchanged; full repository tests were not run, and this does not claim full CommonMark conformance.
Reference: CommonMark 0.31.2 code spans.
Submitted under the published $0.25 USD-equivalent reward per valid bug-fix PR, using the existing application and settlement conversation. Requested settlement remains native SOL on Solana mainnet; acceptance and the exact net token amount still require the payer's confirmation.