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

Fix i18n section links #52

Merged
merged 2 commits into from
Jun 28, 2021
Merged

Fix i18n section links #52

merged 2 commits into from
Jun 28, 2021

Conversation

saswatamcode
Copy link
Collaborator

This PR converts toHeaderID function to use a unicode regex to generate header ids for any given language instead of using ascii codes which restrict section links to just English. Test case added as well. Fixes #50.

Signed-off-by: Saswata Mukherjee <[email protected]>
@saswatamcode saswatamcode requested a review from bwplotka June 24, 2021 06:53
@saswatamcode saswatamcode self-assigned this Jun 24, 2021
Copy link
Owner

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM

punctuation := regexp.MustCompile(`[^\p{L}\p{N}\p{M}-# ]`)
header = punctuation.ReplaceAll(header, []byte(""))
headerText := bytes.TrimLeft(bytes.ToLower(header), "#")
// If header is just punctuation it comes up empty. So cannot be linked.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// If header is just punctuation it comes up empty. So cannot be linked.
// If header is just punctuation it comes up empty, so it cannot be linked.

Signed-off-by: Saswata Mukherjee <[email protected]>
@saswatamcode saswatamcode requested a review from bwplotka June 25, 2021 02:52
@bwplotka bwplotka merged commit ce7adf8 into bwplotka:main Jun 28, 2021
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.

Section links for md in non-English language break
2 participants