Fixed a broken render of a cloze note
This commit is contained in:
parent
d9ca850a6c
commit
db56dfabd1
3 changed files with 32 additions and 4 deletions
|
@ -7,9 +7,9 @@
|
|||
;; Created: Thu May 11 14:05:13 2023 (+0300)
|
||||
;; Version:
|
||||
;; Package-Requires: ((ert))
|
||||
;; Last-Updated: Mon May 22 18:18:50 2023 (+0300)
|
||||
;; Last-Updated: Mon Jun 26 08:41:59 2023 (+0300)
|
||||
;; By: Renat Galimov
|
||||
;; Update #: 247
|
||||
;; Update #: 256
|
||||
;; URL: https://github.com/orgtre/anki-editor
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
|
@ -218,5 +218,24 @@ Simple note body
|
|||
nil))))))))
|
||||
|
||||
|
||||
;; The problem with this behavior is that it gets "Back Extra" from
|
||||
;; the headline. I'd prefer back-extra to be empty.
|
||||
(ert-deftest test--note-at-point-for-cloze-with-front-should-render-note()
|
||||
"Test `anki-editor--note-at-point' for cloze with front should render note."
|
||||
(save-window-excursion
|
||||
(with-current-buffer (anki-editor-test--test-org-buffer "test.org")
|
||||
|
||||
(anki-editor-test--go-to-headline "Cloze with text")
|
||||
(anki-editor-test--patch-variables
|
||||
(lambda ()
|
||||
(should (equal
|
||||
(anki-editor-note-at-point)
|
||||
#s(anki-editor-note nil
|
||||
"Cloze"
|
||||
"Tests"
|
||||
(("Back Extra" . "<p>\ntest <b>Cloze with text</b></p>\n")
|
||||
("Text" . "<p>\nLorem {{c1::lorem}}.\n</p>\n"))
|
||||
nil))))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; anki-editor-tests.el ends here
|
||||
|
|
|
@ -925,11 +925,12 @@ Return a list of cons of (FIELD-NAME . FIELD-CONTENT)."
|
|||
(let* ((formatted-heading (or (and format (anki-editor--export-field (format heading-format heading) format))
|
||||
heading))
|
||||
(heading-field (unless prepend-heading formatted-heading))
|
||||
(formatted-subheading-fields (mapcar (lambda (field) (anki-editor--export-field (cdr field) format)) subheading-fields))
|
||||
(body-field (seq-reduce (lambda (acc value) (string-trim (concat acc "\n\n" (string-trim (or value "")))))
|
||||
(list
|
||||
(when prepend-heading formatted-heading)
|
||||
(anki-editor--export-field content-before-subheading format)
|
||||
(anki-editor--concat-fields fields-extra subheading-fields level))
|
||||
(anki-editor--concat-fields fields-extra formatted-subheading-fields level))
|
||||
""))
|
||||
;; `field-pool' ia list of all extra fields available to fill the missing fields
|
||||
(field-pool (remq nil (list heading-field body-field))))
|
||||
|
@ -941,7 +942,6 @@ Return a list of cons of (FIELD-NAME . FIELD-CONTENT)."
|
|||
(cl-loop for missing-field in fields-missing
|
||||
for field = (pop field-pool)
|
||||
do (push (cons missing-field field) fields)))
|
||||
|
||||
fields)))
|
||||
|
||||
(defun anki-editor--concat-fields (field-names field-alist level)
|
||||
|
|
|
@ -77,5 +77,14 @@ Note with file link
|
|||
** Back
|
||||
[[file:test-attachments/1x1.gif][Test image]]
|
||||
|
||||
|
||||
* Cloze with text
|
||||
:PROPERTIES:
|
||||
:ANKI_NOTE_TYPE: Cloze
|
||||
:ANKI_DECK: Tests
|
||||
:END:
|
||||
** Text
|
||||
Lorem {{c1::lorem}}.
|
||||
|
||||
* Whatever
|
||||
as
|
||||
|
|
Loading…
Reference in a new issue