After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 781893 - Improve LaTeX highlighting for \url and \href
Improve LaTeX highlighting for \url and \href
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: Syntax files
3.24.x
Other Linux
: Normal enhancement
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2017-04-28 10:52 UTC by info
Modified: 2017-06-16 09:38 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch which adds \url and \href highlighting (2.92 KB, patch)
2017-04-28 10:52 UTC, info
needs-work Details | Review
Patch which adds \url and \href highlighting (3.12 KB, patch)
2017-05-01 14:47 UTC, info
none Details | Review
Patch which improves \url and \href highlighting (2.48 KB, patch)
2017-05-17 10:13 UTC, info
none Details | Review
Patch which improves \url and \href highlighting (2.54 KB, patch)
2017-06-13 13:22 UTC, info
none Details | Review
Patch which improves \url and \href highlighting (2.53 KB, patch)
2017-06-13 14:04 UTC, info
accepted-commit_now Details | Review

Description info 2017-04-28 10:52:40 UTC
Created attachment 350628 [details] [review]
Patch which adds \url and \href highlighting

- URLs, displayed with \url and \href commands, which contain dollars signs, break the syntax highlighting.
- URLs won't be highlighted like the markdown syntax does
Comment 1 Sébastien Wilmet 2017-04-29 08:41:13 UTC
Comment on attachment 350628 [details] [review]
Patch which adds \url and \href highlighting

The patch needs to be created with the "git format-patch" command.
Comment 2 info 2017-05-01 14:47:07 UTC
Created attachment 350805 [details] [review]
Patch which adds \url and \href highlighting
Comment 3 info 2017-05-01 14:49:19 UTC
I created a new attachment formatted with git format-patch.
Comment 4 Sébastien Wilmet 2017-05-02 14:41:47 UTC
Review of attachment 350805 [details] [review]:

I think the regexes are good, after a quick look.

For the commit message, the title should start with "latex.lang: ", otherwise it's difficult to know what the commit is about.
And at the end of the commit message there should be the URL to the bugzilla ticket.

Some more comments below.

::: data/language-specs/latex.lang
@@ +47,3 @@
     <style id="paragraph"          _name="Paragraph Heading"     map-to="def:heading5"/>
     <style id="subparagraph"       _name="SubParagraph Heading"  map-to="def:heading6"/>
+    <style id="url"                _name="URL"                   map-to="def:underlined"/>

I think it's better to not apply any style to the URL. Some text editors can underline the URL when the mouse is hover it, to do a right click -> open link. If the URL is constantly underlined, IMHO it would get in the way.

@@ +111,3 @@
+        Examples: \url{http://google.de}, \href{http://google.de}{Google} 
+
+        Supports also urls with math symbols: \url{https://zoidberg.ukp.informatik.tu-darmstadt.de/jenkins/job/DKPro\%20Core\%20Documentation\%20(GitHub)/de.tudarmstadt.ukp.dkpro.core$de.tudarmstadt.ukp.dkpro.core.doc-asl/doclinks/1/user-guide.html}

The last URL is a bit long, you should place it on a new line, or shorten the URL (giving an abstract example).
Comment 5 info 2017-05-08 08:21:31 UTC
OK, I will add prefix and ticket number to the commit message. 

Regarding the style I have a question. I looked at the markdown language spec and in this file they do the same thing for URL. Is this also wrong?
Comment 6 Sébastien Wilmet 2017-05-11 15:30:05 UTC
(In reply to info from comment #5)
> Regarding the style I have a question. I looked at the markdown language
> spec and in this file they do the same thing for URL. Is this also wrong?

Mmh, yes it's maybe wrong. As I said I would prefer to underline the URL only on mouse hover, but currently GtkSourceView or gedit doesn't do that.

Anyway for LaTeX I think it's better to not apply any style to the URL. When reading the text it's easy to recognize an URL.
Comment 7 info 2017-05-17 10:13:35 UTC
Created attachment 352016 [details] [review]
Patch which improves \url and \href highlighting
Comment 8 Sébastien Wilmet 2017-05-17 15:49:06 UTC
Review of attachment 352016 [details] [review]:

The title in the commit message should not exceed 72 characters. The URL to the bugzilla should be the last line of the commit message.

There are trailing spaces on some lines. git normally shows them in red when showing the diff. Please avoid trailing spaces.

::: data/language-specs/latex.lang
@@ +130,3 @@
+
+      <include>
+        <context sub-pattern="1" class="no-spell-check" style-ref="command"/>

The no-spell-check class should be applied to the whole context, the URL included.
Comment 9 info 2017-06-13 13:22:31 UTC
Created attachment 353679 [details] [review]
Patch which improves \url and \href highlighting
Comment 10 info 2017-06-13 14:04:25 UTC
Created attachment 353690 [details] [review]
Patch which improves \url and \href highlighting
Comment 11 Sébastien Wilmet 2017-06-16 09:36:08 UTC
Review of attachment 353690 [details] [review]:

Thanks, the regexes are well explained and the no-spell-check class is well applied.
Comment 12 Sébastien Wilmet 2017-06-16 09:38:55 UTC
Pushed on master:
commit d4f39a1315d9ee6f009d1f6fbdc0ee8b7818d627

And cherry-picked on gnome-3-24.