如题,将org文件导出到苹果的记事本应用,配合icloud,可以在手机上浏览org-mode文档。逛reddit时看到的,和大家分享。虽然不能完全渲染org-mode语法,但在apple note中的效果算是相当漂亮了。
使用:直接在org-mode buffer M-x oan-export
即可。默认保存在apple note的orgmode文件夹下。
代码来源:Importing all of your orgmode notes into Apple Notes for mobile access. - vxlabs
代码:
;; https://www.emacswiki.org/emacs/string-utils.el
(defun string-utils-escape-double-quotes (str-val)
"Return STR-VAL with every double-quote escaped with backslash."
(save-match-data
(replace-regexp-in-string "\"" "\\\\\"" str-val)))
(defun string-utils-escape-backslash (str-val)
"Return STR-VAL with every backslash escaped with an additional backslash."
(save-match-data
(replace-regexp-in-string "\\\\" "\\\\\\\\" str-val)))
(setq as-tmpl "set TITLE to \"%s\"
set NBODY to \"%s\"
tell application \"Notes\"
tell folder \"orgmode\"
if not (note named TITLE exists) then
make new note with properties {name:TITLE}
end if
set body of note TITLE to NBODY
end tell
end tell")
(defun oan-export ()
(interactive)
(let ((title (file-name-base (buffer-file-name))))
(with-current-buffer (org-export-to-buffer 'html "*orgmode-to-apple-notes*")
(let ((body (string-utils-escape-double-quotes
(string-utils-escape-backslash (buffer-string)))))
;; install title + body into template above and send to notes
(do-applescript (format as-tmpl title body))
;; get rid of temp orgmode-to-apple-notes buffer
(kill-buffer))
)))
效果: