Add option to prepend heading to content before first (sub)heading
Like this, when exactly one field is missing and there is content before the first (sub)heading, the heading is seen as part of that content and one can avoid having to duplicate it there. The content with the prepended heading will be mapped to the missing field. Notes in Anki and Org can be made to look more similar without always needing a separate field for the heading.
This commit is contained in:
parent
b0ecbbe4ad
commit
3c1bab3c03
1 changed files with 28 additions and 7 deletions
|
@ -123,6 +123,12 @@ For example, you can put custom styles or scripts in this variable."
|
||||||
A leading logical operator like `+' or `&' is required."
|
A leading logical operator like `+' or `&' is required."
|
||||||
:type 'string)
|
:type 'string)
|
||||||
|
|
||||||
|
(defcustom anki-editor-prepend-note-heading nil
|
||||||
|
"Prepend note heading to contents before first (sub)heading.
|
||||||
|
This is only in effect when exactly one note-type field is not found
|
||||||
|
among the note subheadings and there is content before the first subheading."
|
||||||
|
:type 'boolean)
|
||||||
|
|
||||||
|
|
||||||
;;; AnkiConnect
|
;;; AnkiConnect
|
||||||
|
|
||||||
|
@ -776,18 +782,33 @@ Return a list of cons of (FIELD-NAME . FIELD-CONTENT)."
|
||||||
(if (equal "" (string-trim content-before-subheading))
|
(if (equal "" (string-trim content-before-subheading))
|
||||||
(push (cons (car fields-missing) heading)
|
(push (cons (car fields-missing) heading)
|
||||||
fields)
|
fields)
|
||||||
(push (cons (car fields-missing) content-before-subheading)
|
(if anki-editor-prepend-note-heading
|
||||||
fields))
|
(push (cons (car fields-missing)
|
||||||
|
(concat heading "\n\n"
|
||||||
|
content-before-subheading))
|
||||||
|
fields)
|
||||||
|
(push (cons (car fields-missing)
|
||||||
|
content-before-subheading)
|
||||||
|
fields)))
|
||||||
(if (equal "" (string-trim content-before-subheading))
|
(if (equal "" (string-trim content-before-subheading))
|
||||||
(push (cons (car fields-missing)
|
(push (cons (car fields-missing)
|
||||||
(anki-editor--concat-fields
|
(anki-editor--concat-fields
|
||||||
fields-extra subheading-fields level))
|
fields-extra subheading-fields level))
|
||||||
fields)
|
fields)
|
||||||
|
(if anki-editor-prepend-note-heading
|
||||||
|
(push (cons (car fields-missing)
|
||||||
|
(concat heading "\n\n"
|
||||||
|
content-before-subheading
|
||||||
|
(anki-editor--concat-fields
|
||||||
|
fields-extra subheading-fields
|
||||||
|
level)))
|
||||||
|
fields)
|
||||||
(push (cons (car fields-missing)
|
(push (cons (car fields-missing)
|
||||||
(concat content-before-subheading
|
(concat content-before-subheading
|
||||||
(anki-editor--concat-fields
|
(anki-editor--concat-fields
|
||||||
fields-extra subheading-fields level)))
|
fields-extra subheading-fields
|
||||||
fields))))
|
level)))
|
||||||
|
fields)))))
|
||||||
((equal 2 (length fields-missing))
|
((equal 2 (length fields-missing))
|
||||||
(if (equal 0 (length fields-extra))
|
(if (equal 0 (length fields-extra))
|
||||||
(progn
|
(progn
|
||||||
|
|
Loading…
Reference in a new issue