get error when use XSLT post-processing

Hi there,

I’m new for Scrivener, i have been configuring a Scrivener template to write my papers using MMD for a whole day, but now i still can not understand the workflow of Scrivener to compile MMD to latex file, and i have some questions about it.

my computer is OS X EL Capitan 10.11.1, i have Scrivener 2.7, multimarkdown 5.0.0 installed from brew
There are NO MultiMarkdown folder in both /Library/Application Support/ and ~/Library/Application Support/(i search for some info about MMD, many of them notice these path, but i can not found MultiMarkdown folder in these path after i install it from brew or from the official .pkg file)

my meta-datas are:

latex input: configs/config-header
latex input: configs/config-newCommands
latex input: configs/cover
Base Header Level: 2
latex footer: configs/footer

these include all the needed latex config code

some of my content are like:(i’m testing the citation syntax, all the cite key are defined on the .bib file and are correct set in the latex input file)

Blabla, [#Ferrarese&Merritt2000ApJ, Gebhardt2000ApJ]
Blabla, [#Ferrarese&Merritt2000ApJ, Gebhardt2000ApJ;]

i can successfully compile it without “use XSLT post-processing”

but after i select the “use XSLT post-processing”, i got error
-:32: parser error : EntityRef: expecting ‘;’

Blabla, [#Ferrarese&Merritt2000ApJ, Gebhardt20 ^ -:34: parser error : EntityRef: expecting ';'

Blabla, [#Ferrarese&Merritt2000ApJ, Gebhardt20

I also do some test:
test1:
add new meta-data
latex XSLT: latex-snippet.xslt
Without “use XSLT post-processing”
Result: successfully compiled

Test2:
With “use XSLT post-processing”
Result: error:
warning: failed to load external entity “/Applications/Scrivener.app/Contents/Resources/MultiMarkdown/xslt-bin/…/XSLT/configs/XSLT/latex-snippet.xslt”

Then I Download github.com/fletcher/MultiMarkdown.git

Test3:
Rename /Applications/Scrivener.app/Contents/Resources/MultiMarkdown to MultiMarkdown-old
Without “use XSLT post-processing”
Result: successfully compiled
(it seems that Scrivener do not use this MultiMarkdown without “use XSLT post-processing”)

Test4:
With “use XSLT post-processing”
Result: nothing happened after I click compile

Test5:
Use files from github.com/fletcher/MultiMarkdown.git to update /Applications/Scrivener.app/Contents/Resources/MultiMarkdown
With “use XSLT post-processing”
Result:
-:33: parser error : EntityRef: expecting ‘;’

Blabla, [#Ferrarese&Merritt2000ApJ, Gebhardt20
^
-:35: parser error : EntityRef: expecting ‘;’

Blabla, [#Ferrarese&Merritt2000ApJ, Gebhardt20
(same as the first error)
(it seems that Scrivener find the new latex-snippet.xslt file and begin to run the MultiMarkdown, but have the same runtime error )

Here are my questions:
1. How did Scrivener compile MMD to latex without “use XSLT post-processing”(what binary program did it use? From my test I knew that It did not use /Applications/Scrivener.app/Contents/Resources/MultiMarkdown)?
2. Where did the error parser error : EntityRef: expecting ‘;’ come from when select “use XSLT post-processing”? How can I solve it?
3. How can I config Scrivener to use outer MultiMarkdown(like use /usr/local/bin/MultiMarkdown)(I have tried to copy github.com/fletcher/MultiMarkdown.git files to both /Library/Application Support/ and ~/Library/Application Support/, after some test, I find that Scrivener still use the /Applications/Scrivener.app/Contents/Resources/MultiMarkdown)
4. How can I config the MultiMarkdown files (the XSLT files? The .pl files?) to custom the compile(some thing like use [#citekey;;] to have \citealt{citekey})?

thank your for your reading

My guess on the XSLT error would be that bare ampersand found within the citation key. It looks like MMD isn’t escaping those, or maybe indeed there isn’t a good way of escaping them and their use should be avoided in citation keys—I’m not really sure about that as I’m not an expert in this area of MMD. You might try asking on the MMD support board. Scrivener itself isn’t doing any of this to be clear, you’re just running into a condition where MMD is generating a bad XML file and asking it to pass that through xsltproc which requires a 100% valid XML file—hence, errors. :slight_smile:

By the way, if you intend to customise the MMD output with XSLT, I highly recommend installing your own copy of the MultiMarkdown support folder into your ~/Library/Application Support folder. Scrivener will use it for XSLT if it finds it, and meanwhile the modifications you make and the .xslt files you add will not get blown away whenever Scrivener updates itself.

Okay, to answer your questions in order:

  1. Scrivener uses /usr/local/bin/multimarkdown if it is discovered, with the appropriate command-line flags to produce a LaTeX document.
  2. As noted above, I suspect you have invalid XML file. Ampersands must be encoded, just like in HTML.
  3. You don’t need to do that, it automatically checks for /usr/local/bin/multimarkdown and uses that binary if it is found. I’m not sure what you are doing to determine otherwise though—it sounds like you’ve been modifying the Scrivener.app package and whatnot though, so I’m not sure if your system is functioning as “expected” at this point. :slight_smile:
  4. All right, yeah that’s the kind of thing you would want to use XSLT for. Again, just download the Mac support package available on Fletcher’s website. Scrivener will use that instead of its built-in package.

Or to put all of this simply: if you have nothing related to MMD on your Mac, Scrivener falls back to using the built-in copies we distribute in the software. Otherwise it uses any found components of MMD in their expected locations.

Thanks for your quick reply :slight_smile: @AmberV

i remove one of the citation: Ferrarese&Merritt2000ApJ, and there is no such error, it seems that i should avoid using & in cite keys.

I copy the github.com/fletcher/MultiMarkdown.git into my ~/Library/Application Support, and now i have a MultiMarkdown folder under it, it’s struct tree is
├── Documentation
│ ├── GPL.txt
│ ├── Markdown\ Readme.text
│ ├── Markdown\ Syntax.md
│ ├── MultiMarkdown\ User’s\ Guide.md
│ └── SmartyPants\ Readme.txt
├── MultiMarkdownXSLTMathML
│ ├── README
│ ├── cmarkup.xsl
│ ├── entities.xsl
│ ├── glayout.xsl
│ ├── mmltex.xsl
│ ├── scripts.xsl
│ ├── tables.xsl
│ └── tokens.xsl
├── README.txt
├── Utilities
│ ├── align_elastic_tabstops.pl
│ ├── autocomplete.pl
│ ├── cleancites.pl
│ ├── mmd_merge.pl
│ └── table_cleanup.pl
├── XSLT
│ ├── 6x9book-poetry.xslt
│ ├── 6x9book-real-poetry.xslt
│ ├── 6x9book.xslt
│ ├── article-natbib.xslt
│ ├── article.xslt
│ ├── beamer.xslt
│ ├── clean-text-allow-latex.xslt
│ ├── clean-text-poetry.xslt
│ ├── clean-text-rtf.xslt
│ ├── clean-text.xslt
│ ├── custom-envelope.xslt
│ ├── custom-letterhead.xslt
│ ├── envelope.xslt
│ ├── latex-snippet.xslt
│ ├── letterhead.xslt
│ ├── manuscript-novel.xslt
│ ├── memoir-natbib.xslt
│ ├── memoir-poetry.xslt
│ ├── memoir-twosided.xslt
│ ├── memoir-xelatex.xslt
│ ├── memoir.xslt
│ ├── multimarkdown.xslt
│ ├── natbib-support.xslt
│ ├── opml2mmd.xslt
│ ├── s5.xslt
│ ├── science.xslt
│ ├── sffms-no-chapter-titles.xslt
│ ├── sffms.xslt
│ ├── snippet.xslt
│ ├── xhtml-google-docs.xslt
│ ├── xhtml-poetry-support.xslt
│ ├── xhtml-static-site.xslt
│ ├── xhtml-toc-h2.xslt
│ ├── xhtml-toc.xslt
│ ├── xhtml2latex.xslt
│ └── xhtml2rtf.xslt
├── bin
├── ASCIIMathML.pm
├── MultiMarkdown
│ └── Support.pm
├── MultiMarkdown.pl
├── OPML2mmd.pl
├── SmartyPants.pl
├── SmartyPantsDutch.pl
├── SmartyPantsFrench.pl
├── SmartyPantsGerman.pl
├── SmartyPantsSwedish.pl
├── XHTML2mmd.pl
├── addmetadata.pl
├── mmd2LaTeX.pl
├── mmd2OPML.pl
├── mmd2PDF.pl
├── mmd2PDFXeLaTeX.pl
├── mmd2RTF.pl
├── mmd2XHTML.pl
├── mmd2letter.pl
├── mmd2web.pl
├── multimarkdown2RTF.pl
├── multimarkdown2XHTML.pl -> mmd2XHTML.pl
└── multimarkdown2latex.pl -> mmd2LaTeX.pl

and my metadata is
latex XSLT: latex-snippet.xslt

i still get the error
warning: failed to load external entity “/Applications/Scrivener.app/Contents/Resources/MultiMarkdown/xslt-bin/…/XSLT/latex-snippet.xslt”
cannot parse /Applications/Scrivener.app/Contents/Resources/MultiMarkdown/xslt-bin/…/XSLT/latex-snippet.xslt

so it seems that Scrivener did not use XSLT files in the ~/Library

How can i correctly install the MultiMarkdown in to the ~/Library/Application Support?
(install it from brew or from official .pkg only install binary programs in /usr/local/bin, no other files)
(is there some place to set the Scrivener command-line env? i suspect it can not see programs in the /usr/local/bin)

No problem!

Okay, not surprised it was only the ampersand messing things up. That may be worth a bug report to Fletcher’s forum.

I see what the problem is, you should be getting the support package installer from the MultiMarkdown homepage, not from this old Git repository—that’s for version 2.x, and all of those scripts and XSLT files are incompatible with how MMD works in 5.x, and Scrivener isn’t going to use any of those shell scripts because the new modern ones have different names (deliberately—so that this very condition will fail).


By the way, you won’t find a ‘latex-snippet.xslt’ in the modern distribution. MMD has a snippet mode built into the core LaTeX generator: simply omit any document descriptive meta-data keys from your compile, such as “Title” or “Date”. That works for HTML as well, if you don’t want the head and body wrapper and just something you can paste into an existing boilerplate file.

Thank your for your help :slight_smile:

I have made a bug report for the MMD support