To snippet or not to snippet

My last post spoke of the need to use a snippet of XHTML in order to include it in a WordPress Page. This rule was short-lived. Why am I recanting my story? I switched to MultiMarkdown 3 and attempted the use its XSLT transformation capabilities; something of which requires an entire XHTML file (well-formed XML). The process in which one attempts an XSLT transformation with MMD3 is not an easy one at first glance. This is largely because I have yet to see how Scrivener can trigger MMD3 to perform the task at the completion of a successful compile. In order for Scrivener to be aware of the presence of MMD3 (Scrivener ships with MMD 2), an install of the MMD 3 Support package is required. This package installs in /Library/Application Support/MultiMarkdown. Scrivener is inherently aware of the files in this location, and makes use of them in lieu of the MMD 2 files contained within its app package. One small problem, according to the MMD 3 docs, the XHTML XSLT metadata tag has been removed from the spec.

In the absence of the XHTML XSLT: xhtml-toc-h2.xslt metadata tag, I had to run the mmd-xslt utility from the command line — run it from within its bin/ directory when you do. This script transforms the XHTML file into one that includes a ToC at the top. In my drive towards a successful transformation, I realized that if I had a well-formed XML document, then surely there were commands in PHP that would allow me to gain a reference to the BODY node, and inject it and its inner XML into the WordPress Page output. Sure enough, the necessary functions exist. I did however go back to scratch with the template files. I created a dupe of page.php and content-page.php (doc.php and content-doc.php respectively), and modified the content-doc.php thusly:

Please take note of the use of libxml_use_internal_errors(true);. I’m keeping the page from showing error in the output. IMHO, it’s a security issue if you expose internal paths to the outside world. Now, back to bending MMD 3 and Scrivener to match my particular requirements. Thanks.

Comments are closed.