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

Add gitea slugification #763

Merged
merged 2 commits into from
Jul 25, 2020
Merged

Add gitea slugification #763

merged 2 commits into from
Jul 25, 2020

Conversation

rodolpheh
Copy link
Contributor

When generating TOC, the links are not properly slugified for Gitea. One of the issues I had was that Gitea expect all underscores to be hyphen.

This is a quick hack, I'm still missing the source for the slugification function of Gitea so I'm not sure all the proper changes are made when slugifying. Also the tests probably doesn't cover every cases.

@rodolpheh rodolpheh changed the title ✨ Adding gitea slugification Adding gitea slugification Jul 25, 2020
@rodolpheh rodolpheh changed the title Adding gitea slugification Add gitea slugification Jul 25, 2020
The previous commit messed up with the gitlab and gitea tests
@yzhang-gh
Copy link
Owner

Thanks for the PR.

I'm okay with this as you already implemented it. As for the failed test, you can make a document
containing heading # foo & < >  "foo" and see what anchor Gitea will generate.

@rodolpheh
Copy link
Contributor Author

Sorry for the forced push, I was trying to hide my mistakes... Anyway, the tests are shown as not okay, but I tried triggering them on my repository and everything is okay. I don't know if you can run them again.

@rodolpheh
Copy link
Contributor Author

Mmh the tests keep failing on this repository. See the pull request on my fork : https://github.com/rodolpheh/vscode-markdown/pull/4

@yzhang-gh
Copy link
Owner

Well, that's strange. Let me just merge it in.

@yzhang-gh yzhang-gh merged commit baa5dfe into yzhang-gh:master Jul 25, 2020
@yzhang-gh
Copy link
Owner

All set. 🍻

@rodolpheh
Copy link
Contributor Author

For future references, I think that gitea uses blackfriday for parsing and sanitizing the markdown, here is an explanation of the algorithm used for anchor sanitation in blackfriday.

@rodolpheh rodolpheh deleted the feature/gitea-slugify branch July 25, 2020 13:02
@Lemmingh
Copy link
Collaborator

Gitea has migrated to goldmark with their own slugify method since version 1.11 released on 2020-02-10.


I hope the info above is useful to you.

@yzhang-gh
Copy link
Owner

Gitea has migrated to goldmark with their own slugify method since version 1.11 released on 2020-02-10.

👍. Just to leave a reminder for myself here, Hugo also uses goldmark (#689 (comment)).

@rodolpheh
Copy link
Contributor Author

Woah this is great information, thank you very much. For now, I have improved the gitea slugification to follow more closely the blackfriday algorithm (see #764). It seems to work with a few exotic values and hopefully will work for most of the cases.

@rodolpheh
Copy link
Contributor Author

For reference and if I'm not mistaken, this is the default goldmark function called for generating the IDs :
https://github.com/yuin/goldmark/blob/master/util/util.go#L517

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants