用emacs org-mode寫cnblogs博客
1 引言
以下3點敘述了為什么我要通過org-mode來書寫cnblogs:
1.目前通過emacs的博客插件可以書寫wordpress等類型的博客,但是寫cnblogs的時候會有一些問題,折騰了很久沒有出來結果,也可以參考博文:(未解決)使用emacs寫cnblogs 1
2.很喜歡org-mode的寫作模式,我想用emacs的朋友很多都對org-mode非常有印象,org-mode的寫作方式非常喜歡,結構化的視圖,而我只要更專注里內容地表述上就可以了。org-mode可以導出成html,latex,docbook,mindmap等多種形式。
3.代碼的着色問題。當然cnblogs的插入代碼已經非常優秀了,包含了非常多語言的代碼着色,但是畢竟能列舉的還是有限的,不能自己來進行擴展。而org-mode利用htmlize在這方面就非常出色,利用emacs的擴展性,只要emacs能高亮的代碼,就能夠利用htmlize輸出。比如Elisp就能很好地在cnblogs上進行語法高亮。下面會有效果演示。也可以使用其他方式進行小眾語言的代碼着色,可以參考博文:在博客園添加Lisp(或其它)代碼高亮 2
2 功能和問題
雖然利用org-mode能達到一些效果,但是實際使用地時候還是會遇到一些問題。 下面我利用一張org-mode導出地mindmap圖來顯示下整個過程和存在的問題。
3 效果演示
3.1 表格和圖片效果
org代碼:
| 姓名 | 性別 | 描述 | |--------+------+------| | 張三 | 男 | 張哥 | | 李四 | 女 | 李姐 | | 某某 | 男 | 某某 | | 莫某某 | 男 | 某某 |
效果:
姓名 | 性別 | 描述 |
---|---|---|
張三 | 男 | 張哥 |
李四 | 女 | 李姐 |
某某 | 男 | 某某 |
莫某某 | 男 | 某某 |
[[....url/a.jpg]]
3.2 代碼着色效果
3.2.1 java
下面是java的代碼高亮效果演示:
public void run() { // Loop until the termination semaphore is set while (!threadDone) { threadSleep(); try { log(); } catch (IOException ioe) { threadDone = true; } } }
3.2.2 Elisp
下面是Elisp的代碼高亮效果演示:
;;;;;;;;;設置elisp的函數,變量追蹤 (define-key global-map (kbd "C-c j") 'find-tag-at-point) (defun find-tag-at-point () "Find variable or function at point." (interactive) (let ((variable (variable-at-point)) (function (function-called-at-point))) (if (equal variable 0) (if function (find-function-do-it function nil 'switch-to-buffer)) (find-variable-at-point)) (find-file-at-point))) ;;;;;;;;;設置bookmark的ido候選方式 (defun bookmark-ido-read() (interactive) (bookmark-maybe-load-default-file) (let ((choise (ido-completing-read ">" bookmark-alist ))) (bookmark-jump choise))) (define-key global-map (kbd "C-x rb") 'bookmark-ido-read)
3.3 大綱結構效果
這篇博文的大綱結構就是org-mode導出的效果
3.4 腳注效果
可以參看本文地腳注部分,footnotes。