From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Wales Subject: Solution for export to Blogger Date: Mon, 27 Dec 2010 14:27:53 -0700 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Return-path: Received: from [140.186.70.92] (port=38417 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PXKbj-0007W3-SX for emacs-orgmode@gnu.org; Mon, 27 Dec 2010 16:27:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PXKbi-00050D-E9 for emacs-orgmode@gnu.org; Mon, 27 Dec 2010 16:27:55 -0500 Received: from mail-gy0-f169.google.com ([209.85.160.169]:39893) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PXKbi-000505-AU for emacs-orgmode@gnu.org; Mon, 27 Dec 2010 16:27:54 -0500 Received: by gyd10 with SMTP id 10so672003gyd.0 for ; Mon, 27 Dec 2010 13:27:53 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Here is my solution for posting to Blogger, and the reasons I chose it. The insight that led to the correct solution was that you have to use the new edit box on Blogger. Thanks for that. I took it from there. This works on Emacs 22. It will probably work on 23 also, but I have not tried it. I like its output. I would like to get mail2blogger to work, if I can find out how to get it to grok HTML. For an example of this code in action, see http://thekafkapandemic.blogspot.com/ . This is my new blog. Please tell me if you like the formatting. Samuel === (defun alpha-org-blog-subtree () "Copy the subtree, converted to HTML, for pasting into Blogger as a blog post. For an example of this code in action, see http://thekafkapandemic.blogspot.com/ . Currently to use it you have to turn off Blogger's conversion of newline to br tags in two places. This requires the new editor. === mail2blogger === I tried using mail2blogger, but the HTML got posted. There might be a way to fix this. How do you do an HTML email in a format that gets recognized as HTML? We want to use raw programmatic email, such as sent using msmtp or the built-in Emacs client. The ability to do so will obviate the need to use Google's command line client or to run Emacs 23. This is the next thing to try. Patch welcome. I have no idea how to do it. === Another good thing to try would be to automate grabbing the source from the page automatically to compare what you just created. This is for edits. Also, save the whole blog someplace gittable. Also, check for fixmes. (Or org could check for fixmes before all export. Is there a hook?) === You should turn off Blogger's showing of titles. Turning off the titles has one convenience: you don't have to enter it manually. It also has one drawback: people who link to your post by copying that link cannot do so. Perhaps mail2blogger will fix that by letting you set the title. Of course you could manually enter the title. In which case pretend it is a page. Is there HTML for a title? I will guess not. === Mark pages with the tag, :page:. This will remove the top headline. " (interactive) (save-excursion ;;say about to publish editing or about to publish post. with ;;mail2blogger, we can automate this and assume publish. ;; ;;technically, this should be later in case you kill something inside ;;the note. (org-add-note) ;; ;;could add sugu here. donekeep or tag should be done manually. ;; ;;how do we want blogs to sort? probably donekeep. probably not by ;;latest edit but by publish. ;;i have an issue with "--", which is perfect for emdash in ascii, but ;;gets converted to endash in html. i'd like it to be emdash in html. ;;is there an option for that? ;; ;;if not, we have to replace -- with --- somehow here before exporting. ;;that requires a temporary buffer. ;;org converts headlines to html h numbers according to the level in the ;;org file, not the level in the region. i prefer the latter. ;; ;;kludge it. ;; ;;for a blog we want it to start with delta 0 = h1. delta 1 respects ;;the variable. ;; ;;for some reason, blogger does not format h2 bold on firefox. so h3 ;;looks bigger? if so, do delta 2. css wizards please weigh in on this. (let ((delta 2)) (outline-mark-subtree) (when (member "page" (org-get-tags)) ;;remove title (forward-line 1) ;;might be nice to add hr here ;;we will start with the first headilne's title (decf delta)) (switch-to-buffer (let ((org-export-html-toplevel-hlevel (+ delta (- org-export-html-toplevel-hlevel (org-reduced-level (org-current-level))))) (org-export-headline-levels (+ delta (- org-export-headline-levels (org-reduced-level (org-current-level))))) org-export-with-tags org-export-with-todo-keywords org-export-with-timestamps ;;note: priority must be after todo kw for export ;;already nil org-export-with-priority ) (org-export-region-as-html (region-beginning) (region-end) t ;;seems to erase, which we want (get-buffer-create "*alpha-org-blog-subtree*"))) ;;one drawback is it leaves spaces around text. like "tag> text". there ;;might be other drawbacks. ;;(hoka-unfill-region-special (point-min) (point-max)) ;;(goto-char (point-min)) ;;this does not work because it will join lines with no space in between; ;;we have to actually fill paragraphs. ;;; (while (search-forward "\n" nil t) ;;; (replace-match "")) ;;; (insert "\n") ;;unnec if blogger knows to treat whitespace as insignificant ;;; (goto-char (point-min)) ;;; (delete-matching-lines "^$") (kill-ring-save (point-min) (point-max)))))) Samuel -- Q: How many CDC "scientists" does it take to change a lightbulb? A: "You only think it's dark." [CDC has denied a deadly serious disease for 25 years] ========== HIV-like virus: http://www.wpinstitute.org/xmrv/index.html -- PLEASE DONATE === I want to see the original (pre-hold) Lo et al. 2010 NIH/FDA/Harvard MLV paper.