Repository navigation
Conversation
A Markdown file that starts with front matter (`---` … `---`, as in Jekyll pages, skills and DESIGN.md files) showed in the preview as a horizontal rule followed by every YAML line run together as one heading: TextView reads the opening `---` as a rule and the closing one as a setext underline. The front matter now comes first as a `yaml` code block, the way GitHub shows it apart from the text. It counts as front matter when `---` is the first line (after a byte-order mark too), it is closed by `---` or `...`, and it is empty or opens with a `key:` or a `#` comment. A file that only starts with a rule and some prose is left as it was. Tests: front matter with a heading after it, a BOM with CRLF closed by `...`, empty front matter, and four cases that stay text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
The problem
A Markdown file that starts with front matter (Jekyll pages,
SKILL.mdfiles,DESIGN.mddesign systems) shows in Better Files' preview as a horizontal rule followed by every YAML line run together as one long heading. TextView reads the opening---as a rule and the closing---as a setext underline for the paragraph above it.The fix
markdownBlockstakes the front matter off first and puts it at the top as ayamlcode block, the way GitHub shows front matter apart from the text. It is drawn like any other code block: coloured, with a copy button.It counts as front matter only when:
---is the first line (after a byte-order mark too);---or...;key:or a#comment.A file that only starts with a rule and some prose is left as it was. A lone
---still renders as a rule, as the existing test checks.Independent of #39 and #40: this branch is cut from
main. I leftmod.json's version alone, since those two are open as well.Testing
node --test better-files/tests/*.test.cjs: 111 pass. The new cases cover front matter followed by a heading, a BOM with CRLF closed by..., empty front matter, and four inputs that must stay text (prose between rules,---not on the first line, unclosed, indented).node --test site/tests/*.test.cjspasses, andherdr-app checkpasses.DESIGN.mdwith 165 lines of tokens in its front matter now opens with oneyamlblock (165 lines), followed by its title, instead of a single 170-line heading.🤖 Generated with Claude Code