Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Headings with inline comments are slugged incorrectly #73

Closed
4 tasks done
djmcgreal-cc opened this issue Mar 30, 2023 · 5 comments
Closed
4 tasks done

Headings with inline comments are slugged incorrectly #73

djmcgreal-cc opened this issue Mar 30, 2023 · 5 comments
Labels
💪 phase/solved Post is done 🐛 type/bug This is a problem

Comments

@djmcgreal-cc
Copy link

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)

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Mar 30, 2023
wooorm added a commit to syntax-tree/mdast-util-to-string that referenced this issue Apr 3, 2023
Previously, HTML was always included.
Sometimes you don’t want that.
Set `includeHtml: false` to ignore it.

Related-to: remarkjs/remark-validate-links#73.
@wooorm wooorm closed this as completed in 415557c Apr 3, 2023
@wooorm wooorm added 🐛 type/bug This is a problem 💪 phase/solved Post is done labels Apr 3, 2023
@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Apr 3, 2023
@wooorm
Copy link
Member

wooorm commented Apr 3, 2023

Thanks for your report.
I’ve fixed handling of HTML in headings to match GitHub.

Please note that the href you use in the link as your desired output, does not match how GitHub works. ## a <!-- b --> turns into a-, not a.

As the prose you show includes the word Gitlab, you might be using Gitlab. Perhaps the link you use is specific to Gitlab. We match GitHub. If you use Gitlab, please remove the comment from your heading.

@djmcgreal-cc
Copy link
Author

Thanks a lot! And indeed, I'd spotted that too :)

@djmcgreal-cc
Copy link
Author

Ay chance of a new release, @wooorm ? I tried to install with npm install https://github.com/remarkjs/remark-validate-links but somehow that method won't let me use it, whereas from the npm package release, it does.

@wooorm
Copy link
Member

wooorm commented May 1, 2023

Done in 12.1.1!

@djmcgreal-cc
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 phase/solved Post is done 🐛 type/bug This is a problem
Development

No branches or pull requests

2 participants