Skip to content

Link labels cannot be empty #450

@tomByrer

Description

@tomByrer

empty Link Labels should not be parsed

via CommonMark, but should be logical regardless:

A link label begins with a left bracket ([) and ends with the first right
bracket (]) that is not backslash-escaped. Between these brackets there must
be at least one non-whitespace character.

Steps to reproduce

const fs = require('fs')
const remark = require("remark")
const inspect = require('unist-util-inspect')

const tree = remark().parse(`[ ] brackets with white space inside`)
console.log(inspect(tree))
$ node view-ast.js
root[1] (1:1-1:37, 0-36)
└─ paragraph[2] (1:1-1:37, 0-36)
   ├─ linkReference[1] (1:1-1:4, 0-3) [identifier=" "][label=" "][referenceType="shortcut"]
   │  └─ text: " " (1:2-1:3, 1-2)
   └─ text: " brackets with white space inside" (1:4-1:37, 3-36)

More through test; seems GFM Task List is OK with ignoring the Linked List:
https://astexplorer.net/#/gist/51df6d1a522d5a08c3017d92549345f9/ac9ddaca577f5115e7e220c74acbe786ab3a4a11

Expected behaviour

$ node view-ast.js
root[1] (1:1-1:37, 0-36)
└─ paragraph[2] (1:1-1:37, 0-36)
   └─ text: "[ ] brackets with white space inside" (1:1-1:37, 3-36)

cheers, & thanks for all your hard work!

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