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.

MD041/first-line-h1 complains despite `title` attribute in frontmatter

See original GitHub issue

Start of my .md file:

---
path: "/impressum"
date: "2012-06-21T10:14:00.000+02:00"
title: "Impressum"
---

## Angaben gemäß § 5 TMG

My .markdownlintrc file:

{
  "MD002": { "level": 2 },
  "MD041": { "level": 2 },
  //"MD041/first-line-h1": { "level": 2 }, <-- Tried that one too
  "MD026": { "punctuation": ".,;:" },
}

But still:

markdownlint -c ../../.markdownlintrc src/pages/imprint.md
src/pages/imprint.md: 7: MD041/first-line-h1 First line in file should be a top level header [Context: "## Angaben gemäß § 5 TMG"]

Am I missing sth or is this a bug?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
DavidAnsoncommented, Mar 9, 2019

Okay, I’ve convinced myself the behavior of MD041 should change. If a YAML title property is present, this rule should accept that as the “top level heading” and not warn again no matter what’s in the body of the document. If it behaved that way, your configuration above would do what you want without any changes. If I still feel this way tomorrow, I’ll look at making this change. Thanks for calling this out!

1reaction
DavidAnsoncommented, Mar 24, 2018

The code does respect YAML titles, but there’s a subtlety that’s causing this issue.

First, proof that YAML title is respected - the following does not trigger MD041:

---
path: "/impressum"
date: "2012-06-21T10:14:00.000+02:00"
title: "Impressum"
---

Hallo

## Angaben gemäß § 5 TMG

However, your example reports an issue because the first text of the document is a header. If MD041 sees a header first, it doesn’t care if a front matter title is present and it reports an issue.

I’ll think about whether that might be correct, but it seems wrong to me right now, so I’m calling this a bug and you can assume I will fix it in the next release.

Sorry about that!

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Link Title Attribute: What It Is & How To Use It
Curious about whether there is value in optimizing link title attributes? Here's everything you need to know about using it in SEO.
Read more >
Frontmatter - Dendron
Frontmatter is a collection of custom attributes at the top of each Markdown file. The beginning and end of this is indicated by...
Read more >
Using the HTML title attribute - Updated March 2020 - TPGi
The HTML title attribute is problematic. It is problematic because it is not well supported in some crucial respects, even though it has...
Read more >
Front Matter - Hugo
Hugo allows you to add front matter in yaml, toml, or json to your content files. Front matter allows you to keep metadata...
Read more >
title - HTML: HyperText Markup Language - MDN Web Docs
The title global attribute contains text representing advisory information related to the element it belongs to.
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