emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Solution for export to Blogger


From: Samuel Wales
Subject: [Orgmode] Solution for export to Blogger
Date: Mon, 27 Dec 2010 14:27:53 -0700

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]