Repository navigation
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.
extract_frontmatteronly matched fence lines ending in a bare\n(or at the end of the file), so frontmatter in a file with CRLF line endings was never detected. The opening---rendered as a horizontal rule, and the key/value lines and the closing---became a setext H2 heading. The body was fine; only the fence check missed CRLF.This accepts
---\r\nas the opening fence and trims trailing\r/\nbefore comparing the closing fence. A lone CR is also a line ending in CommonMark/YAML, so"---\r\r\n"still closes the block, and a short comment notes this. LF files behave exactly as before.Reproduce
Before:
After:
Testing
frontmatter_with_crlf_line_endings_is_ignored_in_preview,source_line_map_crlf_frontmatter_lines_point_to_line_one,frontmatter_closing_fence_accepts_lone_crandfrontmatter_closing_fence_variants_are_detected. All four fail onmainand pass with this change.frontmatter_closing_fence_variants_are_detectedalso covers the LF fences that had no test before (..., and a closing fence at the end of the file), since this change rewrites that check.cargo test(1017 passed),cargo clippy --all-targets --all-features -- -D warnings,cargo fmt --all -- --check.*.mdin this repo with the old and new code: output and source line map are identical, so normal documents are unaffected.One visible change for CRLF files: a file whose first line is
---used as a horizontal rule, with another---line later, is now treated as frontmatter, the same as an LF file. Lines in between that are notkey: valuepairs are no longer rendered, and lines that look like one show up in the frontmatter table. This is the existing LF behavior, not something new in this change.A file using bare CR line endings (classic Mac OS) is still not supported. Leaf counts lines by
\nthroughout, so handling that would mean normalizing line endings on load, which felt out of scope here.