Simplify and rename exporting command

This commit is contained in:
louie 2018-02-10 22:15:06 +08:00
parent 7270842948
commit 5f7e38929e
2 changed files with 15 additions and 24 deletions

View file

@ -51,15 +51,15 @@ anki-editor -- Make Anki Cards in Org-mode
** Command Cheatsheet ** Command Cheatsheet
| Command | Brief Description | | Command | Brief Description |
|-----------------------------------------------+---------------------------------------------------------------------| |--------------------------------------+---------------------------------------------------------------------|
| =anki-editor-submit= | Send notes in current buffer to Anki. | | =anki-editor-submit= | Send notes in current buffer to Anki. |
| =anki-editor-insert-deck= | Insert a deck heading. | | =anki-editor-insert-deck= | Insert a deck heading. |
| =anki-editor-insert-note= | Insert the skeleton of a note. | | =anki-editor-insert-note= | Insert the skeleton of a note. |
| =anki-editor-add-tags= | Add tags to property drawer of current heading with autocompletion. | | =anki-editor-add-tags= | Add tags to property drawer of current heading with autocompletion. |
| =anki-editor-cloze-region= | Cloze region. | | =anki-editor-cloze-region= | Cloze region. |
| =anki-editor-export-heading-contents-to-html= | Export the contents of the heading at point to HTML. | | =anki-editor-export-subtree-to-html= | Export subtree of the element at point to HTML. |
| =anki-editor-convert-region-to-html= | Convert and replace region to HTML. | | =anki-editor-convert-region-to-html= | Convert and replace region to HTML. |
Note that =anki-editor-submit= will fail if the deck does not exist Note that =anki-editor-submit= will fail if the deck does not exist
yet. New decks must be created in Anki first. yet. New decks must be created in Anki first.

View file

@ -336,22 +336,13 @@ Otherwise, it's inserted below current heading at point."
(princ "}}")))))) (princ "}}"))))))
;;;###autoload ;;;###autoload
(defun anki-editor-export-heading-contents-to-html () (defun anki-editor-export-subtree-to-html ()
"Export the contents of the heading at point to HTML." "Export subtree of the element at point to HTML."
(interactive) (interactive)
(let* ((tree (org-element-at-point)) (org-export-to-buffer
(contents (or (and (org-element-property :contents-begin tree) anki-editor--ox-anki-html-backend
(org-element-property :contents-end tree) anki-editor-buffer-html-output nil t nil t nil
(buffer-substring (org-element-property :contents-begin tree) (lambda () (html-mode))))
(org-element-property :contents-end tree)))
"")))
(if (or (null tree)
(not (eq (org-element-type tree) 'headline)))
(error "No element at point or it's not a heading")
(when (buffer-live-p (get-buffer anki-editor-buffer-html-output))
(kill-buffer anki-editor-buffer-html-output))
(switch-to-buffer-other-window (get-buffer-create anki-editor-buffer-html-output))
(insert (org-export-string-as contents anki-editor--ox-anki-html-backend t)))))
;;;###autoload ;;;###autoload
(defun anki-editor-convert-region-to-html () (defun anki-editor-convert-region-to-html ()