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

Links in markdown are not parsed correctly #221

Open
fsy2001 opened this issue Jul 20, 2024 · 3 comments
Open

Links in markdown are not parsed correctly #221

fsy2001 opened this issue Jul 20, 2024 · 3 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@fsy2001
Copy link
Collaborator

fsy2001 commented Jul 20, 2024

image

@fsy2001 fsy2001 added the bug Something isn't working label Jul 20, 2024
@fsy2001 fsy2001 added this to the 2.1 milestone Jul 20, 2024
@fsy2001
Copy link
Collaborator Author

fsy2001 commented Jul 28, 2024

Here's a possible fix:

func addSpaceAfterLinks(_ content: String) -> String {
    let pattern = /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&\/\/=]*)(?![\n\s])/
    
    let modifiedContent = content.replacing(pattern, maxReplacements: 10) { match in
        content[match.range] + " "
    }
    
    return modifiedContent
}

But the regex still needs fix. It cannot handle contents like

http://www.whxinan.net/dongman/mingzhentankenanwanshengjiedexinniang/2-1.html 这个网站有人在电影院拍的,勉强能看吧

or

https://www.wjx.cn/vm/hxjo6de.aspx# 
关于疫情下志愿服务开展状况的问卷,有50%概率获得红包,roll5个带r的uu请奶茶,请大家帮忙填填😭😭😭

@fsy2001 fsy2001 added the help wanted Extra attention is needed label Jul 28, 2024
@fsy2001 fsy2001 removed this from the 2.1 milestone Aug 4, 2024
@singularity-s0
Copy link
Collaborator

What is the current regex? A simple fix would be to exclude unicode characters.

@fsy2001
Copy link
Collaborator Author

fsy2001 commented Dec 8, 2024

No regex currently exists.

@fsy2001 fsy2001 removed the bug Something isn't working label Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants