question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: Incorrect addition of H1 when the note only contains front-matter

See original GitHub issue

Describe 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:

  1. Create a new note with an arbitrary title.
  2. Add a frontmatter block to it.
  3. Make sure there is no new-line at the end of the file.
  4. Go to the linter options and activate “Inserts the file name as an H1 if no H1 exists.” in the heading options.
  5. 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

Screenshot 2022-11-25 at 14 50 59 Screenshot 2022-11-25 at 14 51 12

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:closed
  • Created 10 months ago
  • Comments:16

github_iconTop GitHub Comments

1reaction
pjkaufmancommented, Nov 25, 2022

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.

1reaction
pjkaufmancommented, Nov 25, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found