Skip to content

add linkify custom regex to excluding parenthesis in the end of link - #42

Open
makrusali wants to merge 1 commit into
HandmadeNetwork:masterfrom
makrusali:fix-link-pickup-parenthesis
Open

add linkify custom regex to excluding parenthesis in the end of link#42
makrusali wants to merge 1 commit into
HandmadeNetwork:masterfrom
makrusali:fix-link-pickup-parenthesis

Conversation

@makrusali

Copy link
Copy Markdown

i added some push to the website for following issue #31

this https://handmade.network/), is a valid link as i check in here https://0mg.github.io/tools/uri/
but turns out github doesn't render '),' as part of the link
so i add custom config url regex for linkify,

i remove the ( and ) from [-a-zA-Z0-9@:%_+.~#$!?&/=\(\);,'">\^{}\[\]`] and after that i add a condition or if we find ( or ) it must be followed by [-a-zA-Z0-9@:%_+~#$!?&/=;'">\^{}\[\]`] excepting , and . to make ( or ) as a part of the link, otherwise not

original regex for linkify is (default from goldmark):
from: https://github.com/yuin/goldmark/blob/master/extension/linkify.go

^(?:http|https|ftp)://[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-z]+(?::\d+)?(?:[/#?][-a-zA-Z0-9@:%_+.~#$!?&/=\(\);,'">\^{}\[\]`]*)?

and modified version is like this

^(?:http|https|ftp)://[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-z]+(?::\d+)?(?:[/#?](?:[-a-zA-Z0-9@:%_+.~#$!?&/=;,'">\^{}\[\]`]|\([-a-zA-Z0-9@:%_+~#$!?&/=;'">\^{}\[\]`]|\)[-a-zA-Z0-9@:%_+~#$!?&/=;'">\^{}\[\]`])*)?

the wasm build is error for me in hmn\src\parsing\wasm\parsingmain.go:14 undefined: parsing.ForumPreviewMarkdown so i replace it to PostPreviewMarkdown only just to test and i din't commit them.

sorry if my explanation sound confusing, i try my best to write this

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.

1 participant