Skip to content

Bug in incorrect full references with whitespace between them #497

@sambauers

Description

@sambauers

Subject of the issue

Remark appears to be mishandling text inside square braces, possibly attempting to create a link reference, even though the text in braces is over two lines.

This is hard to describe. I think the reduction below will explain it better.

Your environment

Steps to reproduce

Run this reduction:

const remark = require('remark');
const html = require('remark-html');

const md = new remark().use(html);

const markdown = `
[one]
[two]
[three]
[four]
[five]
`;

md.process(markdown, (error, result) => {
  if (!error) {
    console.log(String(result));
  }
});

Expected behaviour

Same as what happens on Commonmark Dingus:

https://spec.commonmark.org/dingus/?text=%5Bone%5D%0A%5Btwo%5D%0A%5Bthree%5D%0A%5Bfour%5D%0A%5Bfive%5D

<p>[one]
[two]
[three]
[four]
[five]</p>

Actual behaviour

Only every second newline is retained:

<p>[one][two]
[three][four]
[five]</p>

Inside a paragraph this is not a huge deal (although white space is lost there), but inside pre or textarea tags (where this also occurs) this is not desirable.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions