we do these things not because they are easy, but because we thought they would be easy.
It seemed like a very simple idea. Org-mode already provided HTML rendering that worked quite well for static pages, and while the kits for WordPress posting use the dreaded xmlrpc api, with my server on the same LAN as the author, both behind a firewall, it seemed reasonably safe to give it a go. This would let me bring anything within reach of Emacs into my published works, and with all the lovely options of Org-Mode, while also enabling the wonderfulness of Fediverse presence, structured data and other perks of WordPress plugins.
That led me to Org2Blog
as a candidate, promising your first post in 5 minutes, and while it took 15, the result was impressive.
Figure 1: do not stare into the void
So I tried a more complex exampleβ¦
Everything was beautiful. Not as beautiful as I would have liked1 but acceptable in every respect except one: Footnotes were garbage. That tiny issue has resulted in a week of no progress, a lot of swearing, bad docs, blind alleys, obsolete advice, and still no closer.
I’ve dropped that post, starting again because I neglected to save the buffer and there is no re-fetch and edit option. I now know the publishing does not upload CSS, only the article body is uploaded, and the footnote mangle, which did not happen outside of Org2blog-WP, remains inexplicable, and persistent.
The Chrome browser View Source HTML makes no sense:
<div id="footnotes"> <h2 class="footnotes">Footnotes: </h2> <div id="text-footnotes"> <div class="footdef"> <sup> <a id="fn.1" class="footnum" href="#fnr.1" role="doc-backlink">1</a> </sup> </p> <!-- THE PHANTOM P :gm --> <div class="footpara" role="doc-footnote"> <p class="footpara"> this would be the footnote text. </p> </div> </div> </div> </div>
If I Inspect the footnote, I find a <p></p>
inserted on a line by itself after the <sub>
tag.
Two things: one is that stray closing P tag in Chrome View Source, the other is the footnote text in a P container that does not include the fn.1
anchor. It is my guess that stray tag is auto-completed by Chrome resulting in the Very Large Gap.
The stray tag does not appear in the WordPress editor receiving the generated post:
<div id="footnotes"> <h2 class="footnotes">Footnotes:</h2> <div id="text-footnotes"> <div class="footdef"> <sup> <a id="fn.1" class="footnum" role="doc-backlink" href="#fnr.1">1</a> </sup> <div class="footpara" role="doc-footnote"> <p class="footpara">the usual footnote sort of stuff.</p> </div> </div> </div> </div>
And yet, if I switch the editor to View mode, the phantom gap paragraph is rendered!
Chrome may be attempting to fix mis-matched tags, which doesn’t explain why the phantom is inserted where it is, only trying to excuse its presence. But why would it only appear when rendered by WordPress? A plugin conflict?
There is a general rule, probably buried in the W3 specs, where the P
tag cannot contain a DIV
, and using curl to extract the source direct into my editor, well, it’s curious because there are no violations of this particular rule, but there is that phantom </p>
appended after the </sup>
which is not in the HTML displayed by WordPress. And there is another as well, tucked in after the </label>
tag on an org-src-container
just before the <pre>
begins. Emacs gives up code-formatting at this point and complains of an unbalanced DIV
.
It seems WP adding extraneous P tags is common, and while it says nothing about extra closing P tags, this offers a theme patch to drop all auto-P injections, and, great googley moogleys it works!
// Prevent WP from adding <p> tags on all post types function disable_wp_auto_p( $content ) { remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); return $content; } add_filter( 'the_content', 'disable_wp_auto_p', 0 );
Which makes my Footnotes quite happy, which makes me happy too. I can move on, I just need to recall what it was I was doing 10 days ago when I hit this.
Ok, but what about \(\LaTeX\)?
It requires the MathJax plugin. If wp-latex
was built in, it wasn’t active.
- what part of \(c = \begin{bmatrix} \frac{\hbar {G_n}^\left(d\right)}{\left(e^{\frac{\phi}{d-1}}\right)^2}\end{bmatrix}^\frac{1}{3}\) did you not understand?
And that turns out nicely, the braces are perhaps a mis-use of bmatrix
but that’s ok, I’ll be more interested in MusicTeX anyway, and therein my next quest.
a collection of beginner Org2Blog resources
- Org2Blog README is surprisingly informative.
- Sharon’s Low-Down from 2013 includes a working configuration example
- Baty.net from 2022 suggests maybe it all still works?
Footnotes:
my benchmark is a beautiful org-mode fed blog called Two Wrongs although I suspect their process doesn’t involve either WordPress or Org2Blog.
@garym quite acceptable, and looks like the images just go.
@garym aha! Solution found!Turns out, it is a common #wordpress thing to install helpful p-tags, and apparently when turned off in config, the trailing p-closures remain which chrome helpfully completes.This article offers a functions.php hack that solved it for me, YMMV.https://templ.io/blog/prevent-wordpress-from-adding-p-tags-in-content/