For those who using Emacs, Markdown and Blogger
You write your blog entry in Emacs and with Markdown format
Then you issue a M-x blogger-post
command in emacs, It convert
the markdown to html and post it to your Blogger blog.
How to Install
- See An Emacs Client For Blogger to install g-client (You'd better check it out from repository)
- See Emacs markdown-mode to install Emacs markdown-mode
- Put the following script to your emacs load path
The code
(require 'gblogger)
(defvar markdown-blogger-new-entry-template
"<entry xmlns='http://www.w3.org/2005/Atom'>
<generator url=\"%s\">%s</generator>
<author> <name>%s </name> </author>
<title mode=\"escaped\" type=\"text/html\">%s </title>
<content type='xhtml'>
<div xmlns=\"http://www.w3.org/1999/xhtml\">
%s
</div>
</content>
</entry>"
"Template for new Blogger entries.")
(defun blogger-post()
(interactive)
(markdown)
(set-buffer (get-buffer "*markdown-output*"))
(setq post-url "http://www\.blogger\.com/feeds/7841127/posts/default")
(setq markdown-buffer (current-buffer))
(setq markdown-content (buffer-string))
(setq title (read-string "Title: "))
(setq buffer (get-buffer-create "*markdown-blogger-post*"))
(declare (special gblogger-auth-handle markdown-blogger-new-entry-template
gblogger-generator-name ))
(g-auth-ensure-token gblogger-auth-handle)
(set-buffer buffer)
(erase-buffer)
(insert (format markdown-blogger-new-entry-template
gblogger-generator-name gblogger-generator-name
"Felix Sun" title markdown-content))
(switch-to-buffer buffer)
(g-app-mode)
(setq g-app-this-url post-url
g-app-auth-handle gblogger-auth-handle
g-app-publish-action 'g-app-post-entry)
(g-app-publish)
)
No comments:
Post a Comment