Skip to content

Fix i18n section links - #52

Merged
bwplotka merged 2 commits into
bwplotka:mainfrom
saswatamcode:i18n-links
Jun 28, 2021
Merged

bwplotka merged 2 commits into
bwplotka:mainfrom
saswatamcode:i18n-links

Conversation

@saswatamcode

Copy link
Copy Markdown
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 <saswataminsta@yahoo.com>
@saswatamcode
saswatamcode requested a review from bwplotka June 24, 2021 06:53
@saswatamcode saswatamcode self-assigned this Jun 24, 2021

@bwplotka bwplotka left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks! LGTM

Comment thread pkg/mdformatter/linktransformer/link.go Outdated
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
Copy Markdown
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 <saswataminsta@yahoo.com>
@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

⌂ 换网址