Skip to content

Headings with inline comments are slugged incorrectly #73

@djmcgreal-cc

Description

@djmcgreal-cc

Initial checklist

Affected packages and versions

12.1.0

Link to runnable example

No response

Steps to reproduce

Run this markdown:

# Run a container whose image is pulled from internal GitLab <!-- comment -->

[Link](#run-a-container-whose-image-is-pulled-from-internal-gitlab)

Through remark-validate-links:
remark --use remark-validate-links

Here's the same markdown to show the GitHub heading link doesn't include ----comment---- at the end:

Run a container whose image is pulled from internal GitLab

Link

Expected behavior

Shouldn't include inline comments as heading identifier. I looked at the code and it's the node toString that gets passed to the slugger, so it should probably be removed beforehand, as it's not printable, which is what the slugger docs ask to be passed.

Actual behavior

## Run a container whose image is pulled from internal GitLab <!-- comment -->

[Link](#run-a-container-whose-image-is-pulled-from-internal-gitlab)
validate-links-bug.md
  3:1-3:68  warning  Link to unknown heading: `run-a-container-whose-image-is-pulled-from-internal-gitlab`. Did you mean `run-a-container-whose-image-is-pulled-from-internal-gitlab----comment---`  missing-heading  remark-validate-links

⚠ 1 warning

Runtime

Node v16

Package manager

npm 8

OS

macOS

Build and bundle tools

Other (please specify in steps to reproduce)

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