summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorVáclav Haisman <vhaisman@gmail.com>2017-09-07 00:28:37 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2017-09-06 15:28:37 -0700
commit19a06b0c831c08265194092bce27458a608f1a85 (patch)
tree41972fa9cd6e070a4e78684b4f33aab6342c696e /tools
parent743413a5b506351499fa2fb66d4184d74e125c54 (diff)
Add simple Emacs mode to help with Pandoc templates editing. (#3889)
tools/pandoc-template-mode.el
Diffstat (limited to 'tools')
-rw-r--r--tools/pandoc-template-mode.el58
1 files changed, 58 insertions, 0 deletions
diff --git a/tools/pandoc-template-mode.el b/tools/pandoc-template-mode.el
new file mode 100644
index 000000000..7a6346458
--- /dev/null
+++ b/tools/pandoc-template-mode.el
@@ -0,0 +1,58 @@
+ ;;; pandoc-template-mode.el --- Pandoc-Template major mode
+
+;; Copyright (C) 2017
+
+;; Author: Václav Haisman
+;; Keywords: extensions
+
+;; This file is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; This file 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 General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+ ;;; Commentary:
+
+;;
+
+ ;;; Code:
+
+(defvar pandoc-template-font-lock-keywords
+ '(("\\(\\$\\)\\(if\\|for\\)(\\([^)]+\\))\\(\\$\\)"
+ (1 font-lock-preprocessor-face)
+ (2 font-lock-keyword-face)
+ (3 font-lock-variable-name-face)
+ (4 font-lock-preprocessor-face))
+ ("\\(\\$\\)\\(endif\\|endfor\\|else\\)\\(\\$\\)"
+ (1 font-lock-preprocessor-face)
+ (2 font-lock-keyword-face)
+ (3 font-lock-preprocessor-face))
+ ("\\(\\$\\)\\(sep\\)\\(\\$\\)"
+ (1 font-lock-preprocessor-face)
+ (2 font-lock-builtin-face)
+ (3 font-lock-preprocessor-face))
+ ("\\(\\$\\)\\([^$]+\\)\\(\\$\\)"
+ (1 font-lock-preprocessor-face)
+ (2 font-lock-variable-name-face)
+ (3 font-lock-preprocessor-face))
+ )
+ "Keyword highlighting specification for `pandoc-template-mode'.")
+
+ ;;;###autoload
+(define-derived-mode pandoc-template-mode fundamental-mode "Pandoc-Template"
+ "A major mode for editing Pandoc-Template files."
+ :syntax-table nil
+ (setq-local font-lock-defaults
+ '(pandoc-template-font-lock-keywords)))
+
+(provide 'pandoc-template-mode)
+ ;;; pandoc-template.el ends here