summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Hergert <christian@hergert.me>2023-03-09 21:19:07 +0000
committerChristian Hergert <christian@hergert.me>2023-03-09 21:19:07 +0000
commit94be3d9b4797a9d46021c17b75e057d3bc5f7d16 (patch)
treea181471b58e6a1b88f9b8c11c377c3dfb7a075e8
parent738183fa605780700e06113142d5f93cc64ed430 (diff)
parentb697b11fd4004ddf3f0da2404071c5a561c69ec2 (diff)
downloadgtksourceview-94be3d9b4797a9d46021c17b75e057d3bc5f7d16.tar.gz
Merge branch 'support-todotxt-format' into 'master'
language-specs: Add support for todo.txt format See merge request GNOME/gtksourceview!315
-rw-r--r--data/language-specs/todotxt.lang92
-rw-r--r--data/styles/Adwaita.xml1
-rw-r--r--tests/syntax-highlighting/todo.txt8
3 files changed, 101 insertions, 0 deletions
diff --git a/data/language-specs/todotxt.lang b/data/language-specs/todotxt.lang
new file mode 100644
index 00000000..c8a4c9ed
--- /dev/null
+++ b/data/language-specs/todotxt.lang
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ This file is part of GtkSourceView
+
+ Author: Victor Kareh <vkareh@vkareh.net>
+ Copyright (C) 2023 by Victor Kareh <vkareh@vkareh.net>
+
+ 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, see <http://www.gnu.org/licenses/>.
+-->
+
+<!--
+ The todo.txt format is a simple set of rules that make todo.txt both
+ human and machine-readable. The format supports priorities, creation and
+ completion dates, projects and contexts.
+
+ Project website: http://todotxt.org
+ Format rules: https://github.com/todotxt/todo.txt
+-->
+
+<language id="todotxt" name="todo.txt" version="2.0" _section="Markup">
+ <metadata>
+ <property name="mimetype">text/x-todo-txt</property>
+ <property name="line-comment-start">x </property>
+ </metadata>
+
+ <styles>
+ <style id="done" name="Done" map-to="def:deletion"/>
+ <style id="priority" name="Priority" map-to="def:list-marker"/>
+ <style id="date" name="Date" map-to="def:preprocessor"/>
+ <style id="link" name="Link" map-to="def:link-destination"/>
+ <style id="context" name="Context" map-to="def:type"/>
+ <style id="project" name="Project" map-to="def:special-char"/>
+ <style id="metadata" name="Metadata" map-to="def:emphasis"/>
+ </styles>
+
+ <definitions>
+ <context id="done" style-ref="done">
+ <match>^x .*</match>
+ </context>
+
+ <context id="priority" style-ref="priority">
+ <match>^\([A-Z]\) </match>
+ </context>
+
+ <context id="date" style-ref="date">
+ <match>[0-9]+-[0-9]+-[0-9]+</match>
+ </context>
+
+ <context id="link" style-ref="link">
+ <prefix>(ftp|git|http|mailto|ssh)s?:</prefix>
+ <keyword>[^\s]+</keyword>
+ </context>
+
+ <context id="context" style-ref="context">
+ <prefix>(?!\s+)\@</prefix>
+ <keyword>[^\s]+</keyword>
+ </context>
+
+ <context id="project" style-ref="project">
+ <prefix>(?!\s+)\+</prefix>
+ <keyword>[^\s]+</keyword>
+ </context>
+
+ <context id="metadata" style-ref="metadata">
+ <match>(?!\s)\w+:\w+(?!\s)?</match>
+ </context>
+
+ <context id="todotxt">
+ <include>
+ <context ref="context" />
+ <context ref="date" />
+ <context ref="done" />
+ <context ref="link" />
+ <context ref="project" />
+ <context ref="priority" />
+ <context ref="metadata" />
+ </include>
+ </context>
+ </definitions>
+</language>
diff --git a/data/styles/Adwaita.xml b/data/styles/Adwaita.xml
index 9e5af964..a3cff6ca 100644
--- a/data/styles/Adwaita.xml
+++ b/data/styles/Adwaita.xml
@@ -109,6 +109,7 @@
<style name="def:comment" foreground="dark_1"/>
<style name="def:constant" foreground="violet_4"/>
<style name="def:decimal" foreground="violet_4"/>
+ <style name="def:deletion" strikethrough="true"/>
<style name="def:doc-comment-element" foreground="dark_3"/>
<style name="def:emphasis" italic="true"/>
<style name="def:error" underline="error" underline-color="red_4"/>
diff --git a/tests/syntax-highlighting/todo.txt b/tests/syntax-highlighting/todo.txt
new file mode 100644
index 00000000..78369968
--- /dev/null
+++ b/tests/syntax-highlighting/todo.txt
@@ -0,0 +1,8 @@
+(A) Call Mom @Phone +Family
+(A) Schedule annual checkup +Health
+(B) Outline chapter 5 +Novel @Computer
+(C) Add cover sheets @Office +TPSReports
+Plan backyard herb garden @Home
+Pick up milk @GroceryStore
+Research self-publishing services +Novel @Computer
+x Download Todo.txt mobile app @Phone