Thomas Kerbrat
Thomas Kerbrat

Reputation: 126

Markdown sub-headers are interpreted as plain text

I have a Markdown document where my headings are strangely interpreted. I could not find any solutions online because I'm confused about which key-words would help me.

Here is my problem:

I have level 2 headings (atx style), and nested level 3 headings inside the last level 2 heading. Which is something like this :

## First title

... lorem ...

## Second title

... lorem ...

### Sub-title 1

... lorem ...

... and so on.

For some reasons the sub-titles would not be interpreted as such. I tried to modify the levels (h2 & h3 -> h1 & h2), and I tried to move the sub-title somewhere else in the document. When I tried to reproduce the issue from scratch to post a question here, I could not find a way to successfully reproduce this behavior.

I used Pandoc to convert Markdown to HTML5, so I began to search with "pandoc" as a search key-word but nothing came out. Then I noticed that in Visual Studio Code, the headings would not be correctly parsed in the "Outline" panel either. I concluded that is was probably an issue with my document and not a Markdown rule I had not respected.

vs code not showing sub-header outline pandoc's html output

Upvotes: 1

Views: 525

Answers (1)

Thomas Kerbrat
Thomas Kerbrat

Reputation: 126

Okay, so I found the solution while writing this post. I have decided to post it anyway so other folks may profit from my time debugging this issue.

I openned my file with a hexadecimal editor, and here is the content near my ### heading :

the file under bless hex editor

The three 23 correspond to the three # and the 53 corresponds to the upper case S. But in between, I have C2 and A0. C2 is "Â" and A0 is a non-breaking space. The trick is that a regular space is 0A so it was not obvious at a first glance.

This was why Markdown parsers could not interpret my line as a heading. Indeed, I only had to replace the non-breaking space by a regular space and it worked fine.

vs code showing sub-header outline properly

Upvotes: 2

Related Questions