From 58cad3a28747ec358c58b91fcd0f088644f7e7ac Mon Sep 17 00:00:00 2001 From: louie Date: Mon, 2 Mar 2020 00:10:53 +0800 Subject: [PATCH] Add styling utilities --- Changelog.org | 7 ++++- README.org | 12 +++++++- anki-editor.el | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 2 deletions(-) diff --git a/Changelog.org b/Changelog.org index 587de8f..a316797 100644 --- a/Changelog.org +++ b/Changelog.org @@ -17,8 +17,13 @@ 6. Added more utility commands/functions 7. ~anki-editor-use-math-jax~ was replaced with ~anki-editor-latex-style~ - 8. Minor internal code refactoring + 8. Code refactoring 9. Allows to put one field in heading + 10. Added options to copy custom head tags to card stylings + 1. Variable ~anki-editor-include-default-style~ + 2. Variable ~anki-editor-html-head~ + 3. Command ~anki-editor-copy-styles~ + 4. Command ~anki-editor-remove-styles~ ** v0.3.3 diff --git a/README.org b/README.org index 0094c3c..eed286b 100644 --- a/README.org +++ b/README.org @@ -84,11 +84,13 @@ there are any ambiguity or grammatical mistakes ;-)/ |-----------------------------------------------+------------------------+----------------------------------------------------------------------------------------------------------| | anki-editor-api-host | "127.0.0.1" | The network address AnkiConnect is listening. | | anki-editor-api-port | "8765" | The port number AnkiConnect is listening. | - | anki-editor-break-consecutive-braces-in-latex | nil | If non-nil, consecutive `}' will be automatically separated by spaces to prevent early-closing of cloze. | + | anki-editor-break-consecutive-braces-in-latex | nil | If non-nil, consecutive "}" will be automatically separated by spaces to prevent early-closing of cloze. | | anki-editor-ignored-org-tags | '("export" "noexport") | A list of Org tags that are ignored when constructing notes form entries. | | anki-editor-org-tags-as-anki-tags | t | If nil, tags of entries wont't be counted as Anki tags. | | anki-editor-protected-tags | '("marked" "leech") | A list of tags that won't be deleted from Anki even though they're absent in Org entries. | | anki-editor-latex-style | builtin | The style of latex to translate into. | + | anki-editor-include-default-style | t | Wheter or not to include `org-html-style-default' when using `anki-editor-copy-styles'. | + | anki-editor-html-head | nil | Additional html tags to append to card stylings when using `anki-editor-copy-styles'. | ** Functions and Macros @@ -141,6 +143,14 @@ there are any ambiguity or grammatical mistakes ;-)/ Find notes with QUERY. +*** anki-editor-copy-styles + + Copy `org-html-style-default' and `anki-editor-html-head' to Anki card stylings. + +*** anki-editor-remove-styles + + Remove from card stylings html tags generated by this mode. + * Limitations ** Tags between Anki and Org diff --git a/anki-editor.el b/anki-editor.el index 91fa3d2..d2c7b4e 100644 --- a/anki-editor.el +++ b/anki-editor.el @@ -107,6 +107,17 @@ form entries." :type '(radio (const :tag "Built-in" builtin) (const :tag "MathJax" mathjax))) +(defcustom anki-editor-include-default-style t + "Wheter or not to include `org-html-style-default' when using `anki-editor-copy-styles'. +For example, you might want to turn this off when you are going to +provide your custom styles in `anki-editor-html-head'." + :type 'boolean) + +(defcustom anki-editor-html-head nil + "Additional html tags to append to card stylings when using `anki-editor-copy-styles'. +For example, you can put custom styles or scripts in this variable." + :type 'string) + ;;; AnkiConnect @@ -937,6 +948,70 @@ entry." (message "%S" nids) nids))) +(defvar anki-editor--style-start "\n") +(defvar anki-editor--style-end "\n