HTML headers from readme.md are incorrectly parsed on npmjs.com

website

(Devrafalko) #1

What I Wanted to Do

When I’ve published my npm module with readme.md that looks great on github, the headers were parsed strange on npmjs. After some code redundancy I figured out that the line breaks are the real culprit.
The readme.md code without line breaks:

<h1>Header A</h1>
<p>some paragraph</p>
<h2 id="a">header a</h2>
<p>some paragraph</p>
<h2 id="b">header b</h2>
<p>some paragraph</p>
<h2 id="c">header c</h2>
<p>some paragraph</p>
<h2 id="d">header d</h2>
<p>some paragraph</p>
<h1>Header B</h1>
<p>some paragraph</p>

The readme.md code with line breaks:

<h1>Header A</h1>
<p>some paragraph</p>

<h2 id="a">header a</h2>
<p>some paragraph</p>

<h2 id="b">header b</h2>
<p>some paragraph</p>

<h2 id="c">header c</h2>
<p>some paragraph</p>

<h2 id="d">header d</h2>
<p>some paragraph</p>

<h1>Header B</h1>
<p>some paragraph</p>

What Happened Instead

This is how the readme.md looks like without line breaks on the left and with line breaks on the right. This is the screen of how two readme.md versions look like on npmjs. On the right screen you can see that the npmjs duplicates the last header:

Reproduction Steps

Details

I’ve also figured out that:

  • when I remove ids from headers, they are parsed correctly regardless the line breaks
  • whether I use h1, h2, h3, etc. it is meaningless

Platform Info

$ npm --versions
{ 'test-cde': '0.0.28',
  npm: '5.3.0',
  ares: '1.10.1-DEV',
  cldr: '32.0',
  http_parser: '2.8.0',
  icu: '60.1',
  modules: '57',
  napi: '3',
  nghttp2: '1.29.0',
  node: '8.11.2',
  openssl: '1.0.2o',
  tz: '2017c',
  unicode: '10.0',
  uv: '1.19.1',
  v8: '6.2.414.54',
  zlib: '1.2.11' }
$ node -p process.platform
  win32

(Kat Marchán) #2

This happens in marky-markdown. If you can find what the parsing issue is and push a patch to that, we’ll be able to pull it into the website.


(system) #3

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.