In another thread, Amber suggested using the MMD outputs as a custom processor to mangle the output as I need. She said the following (which matches the comments in the manual 22.5.8)
Amber, I am trying to work on this path and I think your description here leaves a lot unsaid. Can you please provide some clear documentation on how this works?
You said
I see no such flag, only one checkbox for MultiMarkdown 2 compatibility. Does this enable XSLT mode? The manual is also vague on this but the more I read the more I think that’s what it does – both the UI and the manual need some clarity on this.
Please clarify: the manual says to install MMD3’s support package but on this post from last year you are saying it uses MMD4. viewtopic.php?f=21&t=497&start=45#p159289
Furthermore, a basic check…
$ /Applications/Scrivener.app/Contents/Resources/MultiMarkdown/bin/multimarkdown --version
peg-multimarkdown version 3.7
First of all, none of the MMD-Support packages provide the same directory structure used in Scrivener 2.6. All of the stuff from MultiMarkdown/bin is in MultiMarkdown/xslt-bin in your version. Looks like the multimarkdown from the MMD package installed in /usr/local/bin is placed in MultiMarkdown/bin
Does scrivener figure out the differences in paths? Or do we need to do the renaming ourselves?
The really key thing missing here is the most basic map. If I use X compile choice, which script/s is/are run? This would be really key to hacking up the support.
From what I am reading in the script files, if I was to create an htmlbook.xslt file and place it in the MultiMarkdown/XSLT directory, then name that file with a Meta Data key XSLT XHTML then I could do any replacements I want without screwing up the normal MultiMarkdown export options, yeah? No?
This is really the case where 10 lines of documentation would have saved me 5 hours so far.
Also it seems like every one of these options still produces an output file which is pre-mangled for MultiMarkdown, such as surrounding my Formatted headers with Markdown header tags
“For example, setting XSLT usage with the LaTeX option selected will trigger the ‘mmd2tex-xslt’ shell script”. That has both options you need to set in Compile, LaTeX and XSLT post-processing, linked with the script that is actually executed, if found within the “~/Library/Application Support/MultiMarkdown” folder.
You don’t have to do anything special. Just install the support package and the matching MMD binaries from the MultiMarkdown website. There is no variability in where these files go—it is very easy for Scrivener to check for their existence.
Yes, but to be clear at that point we would be talking about just using a custom XSLT, rather than hacking into the MMD script toolchain and subverting it to do something else entirely (like turn your compiled document into SQL queries and fire them off to a remote server). If all you wish to do is impact the text output in a fashion that can be done with XSL programming, then you don’t need to worry about which bin script is being used.
At that stage, you can do whatever you want since XSL is programmable. I generated this BBCode document with it, it can be used to generate complex formats like LaTeX, whatever. So if you can get everything you need into an .xslt file—so that you can take any MultiMarkdown document and convert it to HTMLDoc or whatever, then all you need is that one .xslt file and the custom meta-data field to trigger it.
Maybe so, but modifying how MultiMarkdown works isn’t something the Scrivener user manual should be messing with, in my opinion, any more than it should be delving into such topics as how to use Microsoft Word after you’ve compiled to .docx.
Scrivener adds those automatically for MultiMarkdown outputs, in the Formatting pane. If you’re creating an XSLT though, wouldn’t you still want headings? Those are after all going to be converted to the h1 – 6 HTML5 elements, which you’ll be using in the XSLT to detect and convert. If you don’t want headings, then you shouldn’t have the “Title” checkboxes in the Formatting pane.
Or, if you are inserting your own code entirely (i.e. MMD won’t be touching the output), then try using the <$title> placeholder code in your prefix, and packing the whole thing into the prefix at that. For example:
<my-header-tag><$title></my-header-tag>
The <$title> code is synonymous with the “Title” checkbox, but you can put it anywhere a document-specific placeholder can be used, and using it won’t trigger MMD output.
So just to be clear, since you seem to be referring to two different things here:
You can use XSL to manipulate the default HTML5 output that MMD produces, to create or alter existing outputs. Example scripts provided by the MMD support install. If you want to produce a document, this is often the best approach (unless one is ignorant of XSL and has no desire to learn the language of course). This requires no knowledge of scripting, no hacking into anything—it’s a completely streamlined and official way of using MMD.
As a complete subversion of Scrivener’s automation, one can look at the execution toolchain and insert their own shell scripts as described above. At this point you aren’t even using MMD—though of course Scrivener will assumes you are with the output it produces. Just avoid its built-in title generator, image, footnote, comments and preserve formatting features if you don’t want MMD output in the text file that goes processed.
Which option to use is up to you, but I wanted to make sure these were not conflated. One is an official way to use MMD, we even have a checkbox for it, the other is really just sniping an NSTask method call and using it to… whatever, print coffee mug silkscreens, whatever your computer can do at that point, but it is hardly necessary if what you want to do is take an MMD text document and turn it into a text file using X format.