-
-
Notifications
You must be signed in to change notification settings - Fork 89
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
Faster link highlighting with more types supported #188
Faster link highlighting with more types supported #188
Conversation
markdownhighlighter.cpp
Outdated
@@ -2051,7 +2026,7 @@ void MarkdownHighlighter::highlightInlineRules(const QString &text) { | |||
*/ | |||
int MarkdownHighlighter::highlightInlineSpans(const QString &text, | |||
int currentPos, const QChar c) { | |||
//clear code span ranges for this block | |||
// clear code span ranges for this block |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing changed below this spot, except the formatting. The next change is in the next file
I noticed something: It highlights HTML tags as links, I need to fix this |
Thank you for your concern. @Waqar144, opinions? |
Yeah, I ripped the old code out which used regular expressions. It was just to unreliable so I replaced it |
868e3eb
to
8d1c397
Compare
It is fixed now! |
You can test it by using the following file (https://raw.githubusercontent.com/tim-gromeyer/html2md/main/tests/links.md) to check the highlighting. It should match the behavior as it did before. You can copy the content of the linked file and try out the old behavior here (https://tim-gromeyer.github.io/MarkdownEdit/markdownedit.html). Then, compare it to a locally built version with this PR integrated. |
Yes, but it makes reviewing harder than it needs to be as one has to go through changes that are meaningless. Thus I would suggest you to remove the formatting changes, or at least put them in a separate commit, then rebase the actual feature changes on top. The way it currently is, it is hard to see what is going on. It is also bad for git blame history. |
Code wise things look okay I think. The new link highlighting code probably won't be able to handle complex link cases but those don't matter usually and I haven't tested to be sure. |
I'd also rather like to have whitespace changes in a different PR... |
Allright, I'll try to revert the formatting changes |
39823a4
to
9030278
Compare
And this PR breaks lots of links... <link%20destination.md>
<linkdestination.md>
[Link test](Link%20test.txt)
[Link Destination - Heading 2](Link%20Destination.md#Heading%202)
[Link test - A heading](Link%20test.md#A%20heading)
---
[Test 1](Test%201.md#Heading%201)
[# Test 1](Link%20Destination.md#Heading%201)
[# Test 2](Link%20Destination.md#Heading%202)
[# Test 3](Link%20Destination.md#Heading)
[# Test 3](Link%20Destination.md#Heading)
[# Test 4](.#A%20Heading)
[Link test](Link%20test.md#A%20Heading)
[# Test 3](Link%20Destination.md)
<Link%20Destination.md>
<Link%20Destination.md>
asdas www.github.com asdasd
www.github.com
https://www.github.com
- [Rename test](folder/Rename%20test3c.md)
- [Rename test](Rename%20test3b.md)
- [Note with one bracket](Note%20with%20one%20bracket%5D.md)
- [Note with one bracket](Note%20with one bracket].md)
- [Note with one bracket](Note%20with one bracket].md) |
9030278
to
231a188
Compare
For the links enclosed in angle brackets ( And for the greyed links... I didn't saw it. You couldn't really see it with dark mode What highlighter state Edit: It also fixes things like this: ## Images with References
[![Forest][forest-image]][forest-link]
[forest-image]: https://www.example.com/images/forest.jpg
[forest-link]: https://www.example.com/nature/forest |
e93567c
to
c18ab90
Compare
@pbek, can you test it again, please? It should be fixed now |
c18ab90
to
b597cbf
Compare
b597cbf
to
53c4c59
Compare
Those still don't work: ## PR 188
- <note://QOwnNotes_Todo>
- <link%20destination.md>
- <linkdestination.md>
- <attachments/1672212884.pdf>
- note://Note_2018_06_26T22_11_10
- <../p11.md> |
Can you please give some examples when it doesn't work? I'm still very unhappy to lose all the documentation on what cases of links the regular expressions cover... |
The files don't work on purpose. Use And for But 1 Question: Should |
Images with references... don't work with this PR either. It's just way too complex
I can add more documentation if you would like; it's a pretty simple task |
imo, Those shouldn't be handled by this library as they aren't really links I think but only something that QON considers as links. As such, QON should highlight these in it's highlighter subclass. The base class should be more generic |
This would be fine with me, but then someone would need to do the migration in https://github.com/pbek/QOwnNotes/blob/main/src/helpers/qownnotesmarkdownhighlighter.cpp first before I'd consider merging that PR... |
I already added support for it here |
QLatin1String("spotify:"), QLatin1String("steam:"), | ||
QLatin1String("bitcoin:"), QLatin1String("magnet:"), | ||
QLatin1String("ed2k://"), QLatin1String("news:"), | ||
QLatin1String("ssh://"), QLatin1String("note://")}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note://
is supported here
yes, but just the |
What else do you want? The files? They caused problems with some HTML tags being highlighted. They are not highlighted on purpose because of this. You can use |
I think he means that we still need to be able to support all the kind of links that previous code did. Some links that may not be "generic" enough and are only needed to by QOwnNotes need to be supported there, so someone, must add support for them in QON before this PR can be considered for merging. |
It had a tendency to highlight HTML tags, but of course I'll add support for that |
Works now |
LGTM, thank you! |
You are welcome! |
@tim-gromeyer, unfortunately 53c4c598 did break something else too: wget http://google.com
|
I opened an issue for it #199. |
.
in it (not true anymore, since it wes requested to support files...)