HangarMC / Hangar

A plugin repository used for paper plugins
https://hangar.papermc.io/
MIT License
249 stars 65 forks source link

Markdown URLs generated from Headings are different, as on GitHub #1351

Closed NonSwag closed 4 months ago

NonSwag commented 4 months ago

Observed/problematic behavior

Hangar replaces some symbols used in URLs generated for headings different than GitHub.

I only noticed two characters so far: / and . on Hangar are replaced with - but completely stripped on GitHub

The problem with this is that for example TOCs (table of contents) do not work in some cases

Expected behavior

Would be nice if the Markdown format was consistent across GitHub and Hangar

Steps to reproduce

Create headings inside a markdown file containing / and or . on Hangar and GitHub Create a TOC and try to use it.

Other

No response

MiniDigger commented 4 months ago

Would be nice if the Markdown format was consistent

hahahhahaha

markdown sadly is extremely underspec'd and everybody implements it differently. there is no standard. github doesnt document their impl, the original markdown spec (that nobody follows and was already underspec'd) doesn't even include section links, neither does the good (but different from gfm) commonmark spec.

I found a lib that does attempt to emulate githubs slug parsing and used that to generate headings instead: https://github.com/Flet/github-slugger

while at it, also added a toc section.

NonSwag commented 4 months ago

thanks for the hard work :+1: