[gtksourceview/wip/latex] latex.lang: better command highlighting
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/latex] latex.lang: better command highlighting
- Date: Mon, 25 Nov 2013 21:43:36 +0000 (UTC)
commit 614bf081f7c125e21f8acc2985a9f27db5b04208
Author: Sébastien Wilmet <swilmet gnome org>
Date: Mon Nov 25 22:36:37 2013 +0100
latex.lang: better command highlighting
Highlight the name and the option.
Currently the common-commands have a higher priority, so for example
\usepackage[options]{name}
won't work, since \usepackage is in the common commands. A solution is
to transform the common-commands into a regex, and have two command
contexts: one for common commands, and one for other commands.
data/language-specs/latex.lang | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/data/language-specs/latex.lang b/data/language-specs/latex.lang
index 30e5490..248aea8 100644
--- a/data/language-specs/latex.lang
+++ b/data/language-specs/latex.lang
@@ -40,6 +40,11 @@
<style id="command" _name="Command" map-to="def:keyword"/>
<style id="verbatim" _name="Verbatim" map-to="def:comment"/>
<style id="special-char" _name="Special Character" map-to="def:special-char"/>
+
+ <!-- names, e.g., name of package, name of environment, name of class -->
+ <style id="name" _name="Name" map-to="def:character"/>
+
+ <style id="options" _name="Options" map-to="def:special-constant"/>
</styles>
<definitions>
@@ -200,8 +205,13 @@
</include>
</context>
- <context id="command" style-ref="command" class="no-spell-check">
- <match>\\[a-zA-Z ]+\*?</match>
+ <context id="command" class="no-spell-check">
+ <match>(\\[a-zA-Z ]+\*?)(\[(.*)\])?({(.*)})?</match>
+ <include>
+ <context sub-pattern="1" style-ref="command"/>
+ <context sub-pattern="3" style-ref="options"/>
+ <context sub-pattern="5" style-ref="name"/>
+ </include>
</context>
<context id="in-math" class="no-spell-check">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]