thedevsaddam / docgen

Transform your postman collection to HTML/Markdown documentation
MIT License
966 stars 134 forks source link

Certain markdown links not working in Gitlab #72

Open mnich0ls opened 2 years ago

mnich0ls commented 2 years ago

Gitlab seems to have slightly different rules for how it escapes spaces for it's anchor links: https://docs.gitlab.com/ee/user/markdown.html#header-ids-and-links

This causes the links generated for the index/TOC, to not work when a string has a hyphen surrounded by spaces e.g "/api/example - success"

Docgen will make a link such as: [/api/example - success](#apiexample-success)

However Gitlab will create an anchor ID such as: id=apiexample---success

I tried to look at the function that generates links, but I can't seem to find the source of the function: https://github.com/thedevsaddam/docgen/blob/7c09b007e8835d83fdd8d4aeb5b4dc8a42d8541b/cmd/root.go#L223

I don't know what the right answer to this problem is, since changing the behavior will have a breaking effect for Markdown pages rendered by Github or Chrome where they seem to have slightly different behavior for the anchor tag links (header IDs). Maybe we can have a "gitlab" flag that allows the links to be generated/escaped using the same rules Gitlab follows?