-
Notifications
You must be signed in to change notification settings - Fork 110
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
URL not detected correctly, when it contains a '#' #556
Comments
I believe this could be fixed by changing |
Probably, yes. Feel free to raise a PR :) |
Alright. I discovered that the patterns in data.py match hashtags and those are used for the Tags section. The matching done for the coloring of the text, recognition of urls and such is done in rednotebook/files/t2t.lang. A single source of regexes is necessary to avoid confusion like this one. The second file uses xml format to define how the matches are treated. Is the regex format in this file compliant with the python format? If so, regexes can be defined in a single place and imported in both data.py and in t2t.lang. |
Another thing that I noticed was that data.py hashtags are excluded from being hex colors (as in #AAA000). Also are excluded from being what I presume are cpp directives such as "#include". I have to observations:
|
I wonder if not using a library for the URL-check would make sense. For parsing URLs, urllib (Python Standard-Lib) can be used. But it does not check url-validity. I then looked for URL-validation and found the validators lib. Maybe that lib might be considered here. |
I think fixing the patterns in t2t.lang would be better. The code is already coupled with it, using a new library would be a lot more work. Plus, it seems like GTK Python uses an xml file to identify patterns and then do something with them like displaying them in bold, underline, coloring urls, etc. So i don't think evaluating each piece of text with a python function would work here. |
In other topics: Turns out the use of '#' alone doesn't cause problems in url recognition, the use of '/' after '#' does: These examples are correctly identified as links: These are not: |
I agree. Adding an external library is always a big pain. I don't see an easy way of avoiding duplicating the hashtag regex in data.py and t2t.lang, since we'd have to parse the XML with Python, which seems excessive. It's probably best to just add a comment in both places that changing one line implies changing the other. Regarding hex values and C++ preprocessor directives, I agree with you, good catch! |
I submitted the PR: #703 |
* Fixing url not recognized when hashtag symbol is followed by slash. Issue #556 * Adding more cpp directives to hashtag pattern in t2t. Adding comment regarding what each hashtag regex is used for in both files. --------- Co-authored-by: Jendrik Seipp <jendrikseipp@gmail.com>
Fixed in #703. |
…#703) * Fixing url not recognized when hashtag symbol is followed by slash. Issue jendrikseipp#556 * Adding more cpp directives to hashtag pattern in t2t. Adding comment regarding what each hashtag regex is used for in both files. --------- Co-authored-by: Jendrik Seipp <jendrikseipp@gmail.com>
Describe the bug
URL not detected correctly, when it contains a '#'
http://www.mywebsite.org/#/foobar
Url-detection stops at the '#'
To Reproduce
Use an URL with a hashtag, like the one mentioned above, and insert it in edit mode
and view the result in the preview mode.
Expected behavior
The URL is detected correctly completely and detection does not stop at the '#' symbol.
Versions:
Rednotebook 2.20, Arch-Linux, package 2.20-2 (2020-11-12).
The text was updated successfully, but these errors were encountered: