{"id":817,"date":"2012-10-09T01:00:00","date_gmt":"2012-10-08T23:00:00","guid":{"rendered":"https:\/\/www.fussylogic.co.uk\/blog\/?p=817"},"modified":"2012-10-09T10:13:03","modified_gmt":"2012-10-09T09:13:03","slug":"wordpress-fight","status":"publish","type":"post","link":"https:\/\/www.fussylogic.co.uk\/blog\/?p=817","title":{"rendered":"WordPress Fight"},"content":{"rendered":"<p>A quick note in case it helps someone else using WordPress. I had a bit of a fight trying to get WordPress to output the HTML that it was given for a post unaltered, this article records what I did.<\/p>\n<p>I write these articles in <a href=\"http:\/\/daringfireball.net\/projects\/markdown\/syntax\">markdown<\/a> syntax, then convert them to HTML using <a href=\"http:\/\/johnmacfarlane.net\/pandoc\/README.html\">pandoc<\/a>. One advantage of pandoc is that it supports inline Latex math markup. Here\u00e2\u20ac\u2122s a snippet from the source of an article:<\/p>\n<pre><code> - $\\frac{1}{2}$.  If half the roses are red, then half are not red.  Simple\n   logic.  Well done amusing student.<\/code><\/pre>\n<p>The dash at the front is markdown for a bulleted list. The dollars switch to math mode. Here\u00e2\u20ac\u2122s the HTML that pandoc converts that to (i.e.\u00c2\u00a0it\u00e2\u20ac\u2122s what appears in the post editor box in the wordpress interface):<\/p>\n<pre><code>&lt;li&gt;&lt;math display=&quot;inline&quot; xmlns=&quot;http:\/\/www.w3.org\/1998\/Math\/MathML&quot;&gt;\n&lt;mrow&gt;&lt;mfrac&gt;&lt;mn&gt;1&lt;\/mn&gt;&lt;mn&gt;2&lt;\/mn&gt;&lt;\/mfrac&gt;&lt;\/mrow&gt;&lt;\/math&gt;.  If half\nthe roses are red, then half are not red. Simple logic. Well done\namusing student.&lt;\/li&gt;<\/code><\/pre>\n<p>This is perfect. Now here\u00e2\u20ac\u2122s what WordPress was outputting (using \u00e2\u20ac\u0153View Source\u00e2\u20ac\u009d in a browser):<\/p>\n<pre><code>&lt;li&gt; &lt;math display=&quot;inline&quot; xmlns=&quot;http:\/\/www.w3.org\/1998\/Math\/MathML&quot;&gt;\n&lt;mrow&gt;&lt;mfrac&gt;&lt;mn&gt;1&lt;\/mn&gt;&lt;mn&gt;2&lt;\/mn&gt;&lt;\/mfrac&gt;&lt;\/mrow&gt;&lt;\/math&gt; &lt;p&gt;. If half\nthe roses are red, then half are not red. Simple logic.  Well done\namusing student.&lt;\/li&gt;<\/code><\/pre>\n<p>See it? WordPress has added a \u00e2\u20ac\u0153<code>&lt;p&gt;<\/code>\u00e2\u20ac\u009d all on its own. It\u00e2\u20ac\u2122s completely unwanted, and it\u00e2\u20ac\u2122s also unbalanced in that there is no closing \u00e2\u20ac\u0153<code>&lt;\/p&gt;<\/code>\u00e2\u20ac\u009d. It\u00e2\u20ac\u2122s clearly a bug in WordPress. It took me a while to find a fix, and it\u00e2\u20ac\u2122s not a real fix for the bug, but it\u00e2\u20ac\u2122s all I needed.<\/p>\n<p>It seems that WordPress has an output filter called \u00e2\u20ac\u0153wpautop\u00e2\u20ac\u009d that\u00e2\u20ac\u2122s adding this spurious markup. If you disable it, then what you get out is what you put in \u00e2\u20ac\u201c which is exactly what I want. I did that by editing the <code>wp-includes\/default-filters.php<\/code> file and commenting out these lines:<\/p>\n<pre><code>add_filter( &#39;the_content&#39;, &#39;wpautop&#39;            );<\/code><\/pre>\n<p>and<\/p>\n<pre><code>add_filter( &#39;the_excerpt&#39;, &#39;wpautop&#39;          );<\/code><\/pre>\n<p>All my embedded maths is correctly formatted inline as part of the paragraph now (unless you\u00e2\u20ac\u2122re viewing in IE, which doesn\u00e2\u20ac\u2122t support MathML at all).<\/p>\n<p>Perhaps this will help someone out there in the future.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A quick note in case it helps someone else using WordPress. I had a bit of a fight trying to get WordPress to output the HTML that it was given for a post unaltered, this article records what I did. I write these articles in markdown syntax, then convert them to HTML using pandoc. One\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.fussylogic.co.uk\/blog\/?p=817\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[6,44],"_links":{"self":[{"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/817"}],"collection":[{"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=817"}],"version-history":[{"count":2,"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/817\/revisions"}],"predecessor-version":[{"id":819,"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/817\/revisions\/819"}],"wp:attachment":[{"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fussylogic.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}