Bug: Incorrect addition of H1 when the note only contains front-matter
See original GitHub issueDescribe the Bug
I had a note that only consisted of YAML front-matter. I activated the linter option “Inserts the file name as an H1 if no H1 exists.”. When you lint the file, the heading gets added after the closing ---
of the front-matter and a blank line gets inserted after the opening ---
.
How to Reproduce
Steps to reproduce the behavior:
- Create a new note with an arbitrary title.
- Add a frontmatter block to it.
- Make sure there is no new-line at the end of the file.
- Go to the linter options and activate “Inserts the file name as an H1 if no H1 exists.” in the heading options.
- Lint the note.
Example to reproduce issue with
Say we have a note with title Test note
which has the following contents:
---
hello: test
---
Note: there is no ending new-line after the closing ---
.
After a lint, the note gets converted to:
---
hello: test
---# Test note
Expected Behavior
The note gets properly linted, and the title of the note gets added below the YAML front-matter.
---
hello: test
---
# Test note
Screenshots
Device
- Desktop
- Mobile
Additional Context
I’m happy to work on a fix if you give me pointers on where to look at. Awesome job, btw ❤️
Issue Analytics
- State:
- Created 10 months ago
- Comments:16
Top Results From Across the Web
If there's an empty line between YAML frontmatter and the first title, it ...
Creating a note containing YAML frontmatter. What feature did you use: Writing in plain text. I added YAML, left an empty line, and...
Read more >MD025 Error when using front_matter_title and h1 #377 - GitHub
Hi, when using title in a YAML frontmatter (aka metadata block) the first heading h1 throws a linting error for rules MD025 and...
Read more >YAML front matter - Assemble.io
YFM is an optional section of valid YAML that is placed at the top of a page and is used for maintaining metadata...
Read more >Adding Metadata Using Markdown Frontmatter in NextJS
I embedded some metadata in my markdown files using the markdown frontmatter format. After parsing this data, I included it in my NextJS...
Read more >Markdownlint Rules
Aliases: first-heading-h1, first-header-h1. Parameters: level (number; default 1). Note: MD002 has been deprecated and is disabled by default.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s odd. It should be ignoring the YAML. But maybe it is not. Some of the rules definitely do not play well together. I will see if I can reproduce with the
data.json
you provided.This issue should now be fixed on the master branch of the plugin and will go out with the next release. Please let us know if that is not the case.