[gtksourceview] tera.lang: Add new lang file for Tera templates
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] tera.lang: Add new lang file for Tera templates
- Date: Sat, 3 Mar 2018 15:45:39 +0000 (UTC)
commit 96947910524ef313f5b452880862d1ff71bc3010
Author: Tobias Schönberg <tobias47n9e gmail com>
Date: Sat Mar 3 14:58:29 2018 +0100
tera.lang: Add new lang file for Tera templates
Changes to be committed:
modified: data/language-specs/Makefile.am
new file: data/language-specs/tera.lang
modified: po/POTFILES.skip
new file: tests/syntax-highlighting/file.tera
https://bugzilla.gnome.org/show_bug.cgi?id=794022
data/language-specs/Makefile.am | 1 +
data/language-specs/tera.lang | 142 +++++++++++++++++++++++++++++++++++
po/POTFILES.skip | 1 +
tests/syntax-highlighting/file.tera | 15 ++++
4 files changed, 159 insertions(+), 0 deletions(-)
---
diff --git a/data/language-specs/Makefile.am b/data/language-specs/Makefile.am
index 98c8371..88f01c4 100644
--- a/data/language-specs/Makefile.am
+++ b/data/language-specs/Makefile.am
@@ -119,6 +119,7 @@ LANGUAGES = \
systemverilog.lang \
t2t.lang \
tcl.lang \
+ tera.lang \
texinfo.lang \
thrift.lang \
vala.lang \
diff --git a/data/language-specs/tera.lang b/data/language-specs/tera.lang
new file mode 100644
index 0000000..31af1ae
--- /dev/null
+++ b/data/language-specs/tera.lang
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ This file is part of GtkSourceView
+
+ Copyright (C) 2018 Tobias Schönberg <tobias47n9e gmail com>
+
+ GtkSourceView is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ GtkSourceView is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+-->
+<language id="tera" _name="Tera Template" version="2.0" _section="Markup">
+ <metadata>
+ <property name="globs">*.tera</property>
+ <property name="line-comment-start">**</property>
+ <property name="block-comment-start">**</property>
+ <property name="block-comment-end">**</property>
+ </metadata>
+
+ <styles>
+ <style id="comment" name="Comment" map-to="def:comment"/>
+ <style id="error" name="Error" map-to="def:error"/>
+ <style id="escape" name="Escaped Character" map-to="def:special-char"/>
+ <style id="string" name="String" map-to="def:string"/>
+ <style id="keyword" name="Keyword" map-to="def:keyword"/>
+ <style id="filters" name="Null Value" map-to="def:function"/>
+ <style id="boolean" name="Boolean value" map-to="def:boolean"/>
+ <style id="floating-point" name="Floating point number" map-to="def:floating-point"/>
+ <style id="decimal" name="Decimal number" map-to="def:decimal"/>
+ <style id="octal" name="Octal number" map-to="def:base-n-integer"/>
+ <style id="hexadecimal" name="Hexadecimal number" map-to="def:base-n-integer"/>
+ </styles>
+
+ <definitions>
+ <context id="keywords" style-ref="keyword">
+ <prefix>\s</prefix>
+ <suffix>\b</suffix>
+ <keyword>and</keyword>
+ <keyword>as</keyword>
+ <keyword>block</keyword>
+ <keyword>elif</keyword>
+ <keyword>else</keyword>
+ <keyword>endblock</keyword>
+ <keyword>endfor</keyword>
+ <keyword>endif</keyword>
+ <keyword>endmacro</keyword>
+ <keyword>endraw</keyword>
+ <keyword>extends</keyword>
+ <keyword>for</keyword>
+ <keyword>if</keyword>
+ <keyword>import</keyword>
+ <keyword>include</keyword>
+ <keyword>in</keyword>
+ <keyword>is</keyword>
+ <keyword>macro</keyword>
+ <keyword>not</keyword>
+ <keyword>or</keyword>
+ <keyword>raw</keyword>
+ <keyword>set_global</keyword>
+ <keyword>set</keyword>
+ </context>
+
+ <context id="filters" style-ref="filters">
+ <prefix>\|</prefix>
+ <keyword>addslashes</keyword>
+ <keyword>capitalize</keyword>
+ <keyword>date</keyword>
+ <keyword>default</keyword>
+ <keyword>escape</keyword>
+ <keyword>filesizeformat</keyword>
+ <keyword>first</keyword>
+ <keyword>get</keyword>
+ <keyword>join</keyword>
+ <keyword>json_encode</keyword>
+ <keyword>last</keyword>
+ <keyword>length</keyword>
+ <keyword>lower</keyword>
+ <keyword>pluralize</keyword>
+ <keyword>replace</keyword>
+ <keyword>reverse</keyword>
+ <keyword>round</keyword>
+ <keyword>safe</keyword>
+ <keyword>slice</keyword>
+ <keyword>slugify</keyword>
+ <keyword>sort</keyword>
+ <keyword>split</keyword>
+ <keyword>striptags</keyword>
+ <keyword>title</keyword>
+ <keyword>trim</keyword>
+ <keyword>truncate</keyword>
+ <keyword>urlencode</keyword>
+ <keyword>wordcount</keyword>
+ </context>
+
+ <context id="tera-block" end-at-line-end="true">
+ <start>{({|%)(/?)</start>
+ <end>(}|%)}</end>
+ <include>
+ <context sub-pattern="0" where="start" style-ref="boolean"/>
+ <context sub-pattern="0" where="end" style-ref="boolean"/>
+ <context ref="dtl:double-quoted-string"/>
+ <context ref="dtl:single-quoted-string"/>
+ <context ref="keywords"/>
+ <context ref="filters"/>
+ <context ref="dtl:boolean"/>
+ <context ref="dtl:float"/>
+ <context ref="dtl:decimal-number"/>
+ <context ref="rust:scope"/>
+ </include>
+ </context>
+
+ <context id="tera-comment-block" style-ref="comment" end-at-line-end="true">
+ <start>{(#)(/?)</start>
+ <end>(#)}</end>
+ <include>
+ <context sub-pattern="0" where="start" style-ref="comment"/>
+ <context sub-pattern="0" where="end" style-ref="comment"/>
+ </include>
+ </context>
+
+ <replace id="html:embedded-lang-hook" ref="tera-block"/>
+
+ <context id="tera">
+ <include>
+ <context ref="tera-comment-block"/>
+ <context ref="tera-block"/>
+ <context ref="html:html"/>
+ </include>
+ </context>
+ </definitions>
+</language>
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 3927763..cec9d5d 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -122,6 +122,7 @@ data/language-specs/swift.lang
data/language-specs/systemverilog.lang
data/language-specs/t2t.lang
data/language-specs/tcl.lang
+data/language-specs/tera.lang
data/language-specs/texinfo.lang
data/language-specs/thrift.lang
data/language-specs/vala.lang
diff --git a/tests/syntax-highlighting/file.tera b/tests/syntax-highlighting/file.tera
new file mode 100644
index 0000000..be0ddd7
--- /dev/null
+++ b/tests/syntax-highlighting/file.tera
@@ -0,0 +1,15 @@
+{% extends "master" %}
+
+{% set_global number = 1.2 + 4 %}
+
+<html>
+ {% import "macros.tera" as macros %}
+ {# Comment #}
+ {{ macros::input(label="Name", type="text") }}
+
+ {% set result = call_function() %}
+
+ {{ type|first }}
+
+ <h1 class="{{ type|slugify }}">{{ value|join(sep=",") }}</h1>
+</html>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]