Add a command to convert region to HTML
This commit is contained in:
parent
873e3dfaa3
commit
ed80e1c25f
2 changed files with 11 additions and 0 deletions
|
@ -25,6 +25,9 @@ anki-editor -- an Emacs package that helps you create Anki cards in Org-mode
|
||||||
| =anki-editor-insert-deck= | C-c a i d | Insert a deck heading with the same level as current heading. With prefix, only insert the deck name. |
|
| =anki-editor-insert-deck= | C-c a i d | Insert a deck heading with the same level as current heading. With prefix, only insert the deck name. |
|
||||||
| =anki-editor-insert-note= | C-c a i n | Insert a note heading that's one level lower to current heading. The inserted heading will be structured with the property drawer and subheadings that correspond to the fields of the selected note type. |
|
| =anki-editor-insert-note= | C-c a i n | Insert a note heading that's one level lower to current heading. The inserted heading will be structured with the property drawer and subheadings that correspond to the fields of the selected note type. |
|
||||||
| =anki-editor-export-heading-contents-to-html= | C-c a e | Export the contents of the heading at point to HTML. |
|
| =anki-editor-export-heading-contents-to-html= | C-c a e | Export the contents of the heading at point to HTML. |
|
||||||
|
| =anki-editor-convert-region-to-html= | N/A | Convert and replace region to HTML. |
|
||||||
|
|
||||||
|
*Not a native speaker, hope this README is clear enough. Happy hacking :)*
|
||||||
|
|
||||||
** Demo
|
** Demo
|
||||||
[[./demo.gif]]
|
[[./demo.gif]]
|
||||||
|
|
|
@ -121,6 +121,14 @@ note type."
|
||||||
(switch-to-buffer-other-window (get-buffer-create anki-editor-html-output-buffer-name))
|
(switch-to-buffer-other-window (get-buffer-create anki-editor-html-output-buffer-name))
|
||||||
(insert (anki-editor--generate-html contents)))))
|
(insert (anki-editor--generate-html contents)))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun anki-editor-convert-region-to-html ()
|
||||||
|
"Convert and replace region to HTML."
|
||||||
|
(interactive)
|
||||||
|
(unless (region-active-p) (error "No active region"))
|
||||||
|
(insert (anki-editor--generate-html
|
||||||
|
(delete-and-extract-region (region-beginning) (region-end)))))
|
||||||
|
|
||||||
(setq anki-editor--key-map `((,(kbd "C-c a s") . ,#'anki-editor-submit)
|
(setq anki-editor--key-map `((,(kbd "C-c a s") . ,#'anki-editor-submit)
|
||||||
(,(kbd "C-c a i d") . ,#'anki-editor-insert-deck)
|
(,(kbd "C-c a i d") . ,#'anki-editor-insert-deck)
|
||||||
(,(kbd "C-c a i n") . ,#'anki-editor-insert-note)
|
(,(kbd "C-c a i n") . ,#'anki-editor-insert-note)
|
||||||
|
|
Loading…
Reference in a new issue