{"id":7115,"date":"2018-04-15T12:13:27","date_gmt":"2018-04-15T16:13:27","guid":{"rendered":"http:\/\/irreal.org\/blog\/?p=7115"},"modified":"2018-04-15T12:20:20","modified_gmt":"2018-04-15T16:20:20","slug":"update-one-down","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=7115","title":{"rendered":"Update: One Down"},"content":{"rendered":"<p> 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&rsquo;ve developed a workaround for the formatting problems that I wrote about <a href=\"http:\/\/irreal.org\/blog\/?p=7098\">yesterday<\/a>. The problem, I believe, is that the WordPress <i>editor<\/i> interprets newlines as a request for a line break and inserts the line break tag (<code>&lt;b \/&gt;<\/code>). That only happen when you&rsquo;re using the editor so it doesn&rsquo;t come up unless I&rsquo;m trying to paste HTML into the <code>Text<\/code> tab of the editor. <\/p>\n<p> Although there are plenty of articles on the Internet explaining how to force a line break in WP, I couldn&rsquo;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 <code>blog-post<\/code> that calls <code>org-html-export-as-html<\/code> with a parameter asking it to only export the &lt;body&gt;&#x2026;&lt;\/body&gt; 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&rsquo;s the code: <\/p>\n<div\n class=\"org-src-container\"> <\/p>\n<pre class=\"src src-emacs-lisp\">(<span\r\n style=\"color: #a020f0;\">defun<\/span> <span style=\"color:\r\n #0000ff;\">blog-post<\/span> () <span style=\"color: #8b2252;\">\r\n  \"Export an org buffer as HTML but only export the body.<\/span>\r\n <span\r\n style=\"color: #8b2252;\">Remove all singleton newlines so the\r\n WordPress editor doesn't insert<\/span> <span style=\"color:\r\n #8b2252;\">break tags (&lt;b \/&gt;).\"<\/span>\r\n (<span style=\"color:\r\n #a020f0;\">interactive<\/span>) \r\n (org-html-export-as-html nil nil nil t)\r\n (goto-char (point-min))\r\n (<span style=\"color: #a020f0;\">while<\/span> (re-search-forward <span style=\"color: #8b2252;\">\"\\n<\/span><span\r\n style=\"color: #8b2252; font-weight: bold;\">\\\\<\/span><span\r\n style=\"color: #8b2252; font-weight: bold;\">(<\/span><span\r\n style=\"color: #8b2252;\">[<\/span><span style=\"color:\r\n #8b2252;\">^<\/span><span style=\"color: #8b2252;\">\\n]<\/span><span\r\n style=\"color: #8b2252; font-weight: bold;\">\\\\<\/span><span\r\n style=\"color: #8b2252; font-weight: bold;\">)<\/span><span\r\n style=\"color: #8b2252;\">\"<\/span> nil t)\r\n   (replace-match <span\r\n style=\"color: #8b2252;\">\" \\\\1\"<\/span>))) <\/pre>\n<\/p><\/div>\n<p> That&rsquo;s one problem down. Now all I have to do is to get <code>org2blog<\/code> working again and things will return to what passes for normal around here. Please let me know if you&rsquo;re still getting formatting problems. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&rsquo;ve developed a workaround for the formatting problems that I wrote about yesterday. The problem, I &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=7115\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[18],"class_list":["post-7115","post","type-post","status-publish","format-standard","hentry","category-blogging","tag-emacs"],"_links":{"self":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7115"}],"version-history":[{"count":10,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7115\/revisions"}],"predecessor-version":[{"id":7125,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7115\/revisions\/7125"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}