How to use org-mode to write blog
October 10, 2010 at 4:51 am Leave a comment
I begin to write blog recently, naturally I choose org-mode to do this
task. However, org-mode export to html with whole page of html tags with
head and body. While writing to blog, we only need the body part. When I
just copy the body part, I loose its format. If I copy the whole html,
blogspot general some unwanted space, title, etc and I also lost title
link. I read w3schools.com about html and css and realized that if I can
change the template of blogstpot.com, add those css, I should be able to
keep the format. Read google’s own online help, and then I changed my
template, done! Only thing left is that I still need manually copy body
part. After a long search, I known that there is a variable
org-export-as-html whose fifth option can be set to body-only
(refer to discuss part in EMACS-FU ). But I known very little about
lisp. A promising setting is from http://comments.gmane.org/gmane.emacs.orgmode/18069
,---- | (setq html (org-export-region-as-html beg end t 'string)) `----
I tried substituting the string with body-only, but it’s wrong.
Thanks to Tamas K Papp’s blog, who gives the whole solution. The only
thing I didn’t follow his solution is CSS apart for syntax highlight,
since inline-css works for me. If I choose ccs instead of inline-css,
local html will be generated without syntax hight.
So the whole step is
- Copy CSS part of a org-mode generated html into template of blogspot
(Only part 1 of CSS mentioned in Tamas K Papp’s blog). The first
line should be removed, since it cause some problem, especially when
I use them in wordpress.com, it cause<pre>part notoverflow
(scroll bar not shown when space is not enough), i.e.html { font-family: Times, serif; font-size: 12pt; }The location
is to add CSS is<b:skin> .... * Varaible definitions apart CSS you added original CSS setting .... </b:skin>
- add following line into
.emacsfile(defun org-export-body-as-html () (interactive) (org-export-as-html 3 nil nil "blog" t)) (add-hook 'org-mode-hook (lambda () (local-set-key (quote [?\C-c ?\C-x]) 'org-export-body-as-html)))
- Use C-c C-x to generate body part of the blog
- Use scribefire to update blog and preview the results. I feel this is
more convenient than webloger.el. Since webloger.el cannot update
title and set label, I have to manually change it every time if I use
this. Need use new version scribefire, old version have bugs, when
encounter `<’ and `>’ inside <pre> tags, it convert them into `<’,
and ‘>’ respectively. While <pre> tags may have other tags inside
them, especial for color setting <span>. - If use blogspot to update blog, in
post optionpart, chooseUse br tags. Otherwise, unwanted line breaks will be added.
Entry filed under: Emacs. Tags: .

Trackback this post | Subscribe to the comments via RSS Feed