[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/web-mode 7b5459f58c: anki support
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/web-mode 7b5459f58c: anki support |
Date: |
Wed, 15 Jun 2022 02:03:24 -0400 (EDT) |
branch: elpa/web-mode
commit 7b5459f58c381f31eed257480b000a9a46209094
Author: fxbois <fxbois@gmail.com>
Commit: fxbois <fxbois@gmail.com>
anki support
#1246
---
issues/1246.anki | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
web-mode.el | 35 ++++++++++++++++++++++++++++---
2 files changed, 96 insertions(+), 3 deletions(-)
diff --git a/issues/1246.anki b/issues/1246.anki
new file mode 100644
index 0000000000..0f1b802587
--- /dev/null
+++ b/issues/1246.anki
@@ -0,0 +1,64 @@
+<!-- Note that most of HTML's base structure is implied, it will be put in
<html><body> ... </body></html> -->
+What is the capital of {{Country}}?
+<!-- Anki templates are of two categories: the Front template, and the Back
template.
+ The Front template is for the question, the Back template is for the
answer.
+ They are completely separated (ie. different HTML code). -->
+<hr id="answer">
+
+The capital is <b>{{Capital}}</b>
+
+<!-- Conditional allow you to skip this if the field is empty (Region in this
case) -->
+<div>
+ {{#Region}}
+ And it is in <span class="region">{{Region}}</span>
+ {{/Region}}
+</div>
+<!-- or skip it if the field is *not* empty. Conditionals can be nested. -->
+{{^Region}}
+ {{Capital}} is in no region :/
+{{/Region}}
+
+
+{{tts en_US speed=0.8 voices=Apple_Otoya:Example Word}}
+<!-- or even, with cloze support -->
+{{tts en_US:cloze-only:Example Word}}
+
+<!-- cloze deletion: these will be replaced by [...] on the Front side, but
not on the Back side -->
+{{cloze:Example Word}}
+{{#c1}}
+ Hint for cloze deletion card <i>c1</i>
+{{/c1}}
+{{#c2}}
+ Hint for cloze deletion card <i>c2</i>
+{{/c2}}
+
+<!-- some of these fields have a special meaning: -->
+<p>{{Tags}} {{Type}} {{Deck}} {{Subdeck}} {{Card}} are always set.</p>
+<p>{{FrontSide}} is only set in the Back template (answer), but not in the
Front template (question)</p>
+It will render the Front side of the card.
+
+<!-- Hints are links that turn into regular text, with the content of the
field, when clicked -->
+{{hint:My Field}}
+
+<!-- Answers can be typed: this will make an input in the Front side, and will
compare what was typed-in
+ with the content of the field -->
+{{type:My Field}}
+<!-- This can even be mixed with cloze deletion -->
+{{type:cloze:MyField}}
+
+<!-- Fields can be embedded everywhere -->
+<a href="http://example.com/search?q={{Expression}}">check in dictionary</a>
+<!-- but they are still regular HTML: Expression might be "<b>a word</b>", or
even include some script -->
+<!-- for this reason, fields can be striped of their formatting, with -->
+<a href="http://example.com/search?q={{text:Expression}}">check in
dictionary</a>
+
+<!-- The syntax for embedding media is different -->
+<!-- a regular image -->
+<img src="something.jpg">
+<!-- a sound -->
+[sound:something.mp3]
+<!-- latex -->
+[latex]$\displaystyle\sum_0^\infty\frac1{n^2}=\frac{\pi^2}4$[/latex]
+but also inline [$]2+3=5[/$] equations, or [$$]centered equations[/$$].
+<!-- MathJax is also supported, with regular syntax -->
+Inline \(2+3=5\) euqations, or \[centered equations\].
diff --git a/web-mode.el b/web-mode.el
index f17b12605c..03be12e3b5 100644
--- a/web-mode.el
+++ b/web-mode.el
@@ -2,7 +2,7 @@
;; Copyright 2011-2022 François-Xavier Bois
-;; Version: 17.2.2
+;; Version: 17.2.3
;; Author: François-Xavier Bois
;; Maintainer: François-Xavier Bois <fxbois@gmail.com>
;; Package-Requires: ((emacs "23.1"))
@@ -23,7 +23,7 @@
;;---- CONSTS
------------------------------------------------------------------
-(defconst web-mode-version "17.2.2"
+(defconst web-mode-version "17.2.3"
"Web Mode version.")
;;---- GROUPS
------------------------------------------------------------------
@@ -879,6 +879,7 @@ Must be used in conjunction with
web-mode-enable-block-face."
(defvar web-mode-engines
'(("angular" . ("angularjs"))
+ ("anki" . ())
("archibus" . ())
("artanis" . ())
("asp" . ())
@@ -958,6 +959,7 @@ Must be used in conjunction with
web-mode-enable-block-face."
(defvar web-mode-engine-file-regexps
'(("angular" . "\\.component.html\\'")
+ ("anki" . "\\.anki\\'")
("archibus" . "\\.axvw\\'")
("artanis" . "\\.html\\.tpl\\'")
("asp" . "\\.asp\\'")
@@ -1146,6 +1148,7 @@ Must be used in conjunction with
web-mode-enable-block-face."
(defvar web-mode-engines-auto-pairs
'(("angular" . (("{{ " . " }}")))
+ ("anki" . (("{{ " . " }}")))
("artanis" . (("<% " . " %>")
("<%=" . " | %>")
("<@css" . " | %>")
@@ -1305,6 +1308,7 @@ Must be used in conjunction with
web-mode-enable-block-face."
(defvar web-mode-engine-open-delimiter-regexps
(list
'("angular" . "{{")
+ '("anki" . "{{")
'("artanis" . "<%\\|<@\\(css\\|icon\\|include\\|js\\)")
'("asp" .
"<%\\|</?[[:alpha:]]+:[[:alpha:]]+\\|</?[[:alpha:]]+Template")
'("aspx" . "<%.")
@@ -1977,6 +1981,15 @@ shouldn't be moved back.)")
'("/?>" 0 'web-mode-html-tag-bracket-face)
))
+(defvar web-mode-anki-font-lock-keywords
+ (list
+ '("{{[#/^]\\([[:alnum:]_.]+\\)" 1 'web-mode-block-control-face)
+ ;;'("\\_<\\([[:alnum:]_]+=\\)\\(\"[^\"]*\"\\|[[:alnum:]_.: ]*\\)"
+ ;; (1 'web-mode-block-attr-name-face)
+ ;; (2 'web-mode-block-attr-value-face))
+ '("{{\\(.+\\)}}" 1 'web-mode-variable-name-face)
+ ))
+
(defvar web-mode-dust-font-lock-keywords
(list
'("{[#:/?@><+^]\\([[:alpha:]_.]+\\)" 1 'web-mode-block-control-face)
@@ -2384,6 +2397,7 @@ shouldn't be moved back.)")
(defvar web-mode-engines-font-lock-keywords
'(("angular" . web-mode-angular-font-lock-keywords)
+ ("anki" . web-mode-anki-font-lock-keywords)
("artanis" . web-mode-artanis-font-lock-keywords)
("blade" . web-mode-blade-font-lock-keywords)
("cl-emb" . web-mode-cl-emb-font-lock-keywords)
@@ -3330,6 +3344,12 @@ Also return non-nil if it is the command
`self-insert-command' is remapped to."
)
) ;django
+ ((string= web-mode-engine "anki")
+ (setq closing-string "}}"
+ delim-open "{{[#/^]?"
+ delim-close "}}")
+ ) ;anki
+
((string= web-mode-engine "ejs")
(setq closing-string "%>"
delim-open "<%[=-]?"
@@ -4184,7 +4204,7 @@ Also return non-nil if it is the command
`self-insert-command' is remapped to."
"Set text-property 'block-token to 'delimiter-(beg|end) on block delimiters
(e.g. <?php and ?>)"
;;(message "reg-beg(%S) reg-end(%S) delim-open(%S) delim-close(%S)" reg-beg
reg-end delim-open delim-close)
(when (member web-mode-engine
- '("artanis" "asp" "aspx" "cl-emb" "clip" "closure" "ctemplate"
"django" "dust"
+ '("artanis" "anki" "asp" "aspx" "cl-emb" "clip" "closure"
"ctemplate" "django" "dust"
"elixir" "ejs" "erb" "expressionengine" "freemarker" "go"
"hero" "jsp" "lsp"
"mako" "mason" "mojolicious"
"smarty" "template-toolkit" "web2py" "xoops" "svelte"))
@@ -4862,6 +4882,15 @@ Also return non-nil if it is the command
`self-insert-command' is remapped to."
)
) ;dust
+ ((string= web-mode-engine "anki")
+ (cond
+ ((looking-at "{{[#^]\\([[:alpha:].]+\\)")
+ (setq controls (append controls (list (cons 'open
(match-string-no-properties 1))))))
+ ((looking-at "{{/\\([[:alpha:].]+\\)")
+ (setq controls (append controls (list (cons 'close
(match-string-no-properties 1))))))
+ )
+ ) ;anki
+
((member web-mode-engine '("mojolicious"))
(cond
((web-mode-block-ends-with "begin" reg-beg)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/web-mode 7b5459f58c: anki support,
ELPA Syncer <=