Yes, the output process looks like this:1. Scrivener compiles all the bits of the draft; creates titles with the appropriate header depth, if the user has specified that option; inserts MMD meta-data information specified in File menu / MultiMarkdown settings, and then creates a temporary plain text file. Exporter stops here if plain MMD export was used.
- This is fed to the standard MMD Perl scripts, depending on the output option selected in the export pane. These produce a valid XHTML file. Export stops here if XHTML export was used.
- The scripts then take that file and using the XSLT language, transform the XHTML into the intended output format (generally LaTeX, but it can be anything at that point, even variations of XHTML or other XML formats, such as OpenDoc).
The step where you want to inject customisations is the final one. The first thing I would recommend doing is downloading MultiMarkdown and placing the MMD directory in [pre]~/Library/Application Support/MultiMarkdown[/pre]. Scrivener by default uses a version that is built into Scrivener, but if you have a copy installed there, or at the computer’s Library level, it will defer to that instead. This makes it much easier to customise your MMD installation.
The rest is up to you. There is a folder in there called XSLT, which contains all of the transformation scripts. You’ll notice there are quite a few options out of the box. Most of the final stage transformers rely upon a cascading of generalised ones, so making changes to the general ‘xhtml2latex.xslt’ will impact ‘memoir.xslt’, ‘article.xslt’, and so forth. Further, many are variations on ‘memoir.xslt’, so changes there will impact them. The reason for knowing this is that the parts of the LaTeX file you wish to change may not actually be in the final XSLT specified in your MMD meta-data header (or the default memoir.xslt).
Recommended practice is to duplicate the XSLT you wish to modify, preferring to modify the final XSLT (such as ‘science,xslt’, rather than the generalised ones, such as ‘xhtml2latex.xslt’), if possible, and then specifying the name of this new customised XSLT in the MMD meta-data settings. If you do want to modify one of the base transformers, I suggest duplicating it, and saving the original copy for back-up purposes.
If you make a lot of revisions, take care to preserve them somewhere safe so the next time you upgrade MMD you do not accidentally delete your XSLT folder.
Further customisation is possible. Since the entire export process is Perl and XSLT, the whole engine is rather easily modified to the very core. The only limit is how good you are with these languages, or how willing you are to learn them. For example, I have coded a customised version of MMD that allows me to add CSS classes to elements, and I use this to create variations in the final product.