Update: One Down

Those of you who read Irreal on mobile devices or who just have a heightened sense of aesthetics will be happy to know that I’ve developed a workaround for the formatting problems that I wrote about yesterday. The problem, I believe, is that the WordPress editor interprets newlines as a request for a line break and inserts the line break tag (<b />). That only happen when you’re using the editor so it doesn’t come up unless I’m trying to paste HTML into the Text tab of the editor.

Although there are plenty of articles on the Internet explaining how to force a line break in WP, I couldn’t find any explaining how to inhibit them. So I looked at the problem the other way around and eliminated the newlines that WP was misinterpreting as a line break request. I have a local function called blog-post that calls org-html-export-as-html with a parameter asking it to only export the <body>…</body> portion of the HTML. I added a couple of lines of Elisp to replace singleton newlines with a space. That appears to make WordPress happy. For anyone interested, here’s the code:

(defun blog-post () 
  "Export an org buffer as HTML but only export the body.
 Remove all singleton newlines so the
 WordPress editor doesn't insert break tags (<b />)."
 (interactive) 
 (org-html-export-as-html nil nil nil t)
 (goto-char (point-min))
 (while (re-search-forward "\n\\([^\n]\\)" nil t)
   (replace-match " \\1"))) 

That’s one problem down. Now all I have to do is to get org2blog working again and things will return to what passes for normal around here. Please let me know if you’re still getting formatting problems.

This entry was posted in Blogging and tagged . Bookmark the permalink.