Multimarkdown and Glossary Function

I am exploring the use of the glossary markdown from scrivener to Latex. If I use:

[?(Glossary) The glossary collects information about important terms used in your documemnt]
I get this in Latex:

\newglossaryentry{Glossary}{name=Glossary, description={The glossary collects information about important terms used in your documemnt}}\gls{Glossary}
This is perfect!
But if I want to refer to that glossary item a second time, and of course don’t need to re-enter the description again, I expect this to work:

[?Glossary] is a glossary term.

That gives me this in the Latex document:

{[?Glossary]} is a glossary term.

But I am expecting:

\gls{Glossary} is a glossary term.

Can you help me understand the markdown syntax for glossary items, and what to expect when compiled to Latex.

I don’t think I’m familiar with glossary references in text. Isn’t a glossary just a list of terms and definitions/explanations? Are you trying to make an index of where the glossary terms fall within your document?

I looked at the MMD syntax guide, and I’m only finding syntax on how to create an entry, not how to refer back to it again… fletcher.github.io/MultiMarkdow … index.html

I do a REGEX search in Scriveners compile settings to search for all instances of words contained in square brackets with a leading question mark and replace that \gls(word). This creates the glossary references in the resulting Latex document.

What regex search expression are you using?

The ‘Replacement’ REGEX expression is:

\[\?(\w*?)\](\W)

And the ‘With’ code is:

\\gls\{$1\}$2

In the Latex template I have the following commands:

\usepackage[nonumberlist, nogroupskip, nopostdot]{glossaries} % Enables glossaries package. Removes numbers from glossary, groupings and final full stop \glstoctrue % Adds glossary to TOC \makenoidxglossaries % Gets Tex to sort glossaries

And in the Scrivener document I place the following where I want the glossary to appear:

\printnoidxglossary[type=main]

In the setup I am using for compile[Multimarkdown->LaTeX (.tex] and then using the format [MMD6 - Raw LaTeX] (Thanks to @Amber), I have had to solve the problem like this:
My “Replace” reg expression:

\[\?([^\]]+)\]

My “With” expression (which seems to NOT be a reg expression, but is driven by the MMD6 - Raw LaTeX format selection):

`\\gls{$1}`{=latex}

This enables me to use the markdown “[?glossaryitem]” in my scrivener file when I don’t want a definition, and then be able to see “\gls{glossaryitem}” in the .tex file.

Update: Because I want to finish my glossary later without re-reading the entire document, I prefer to put my newglossary entry in a separate chapter called “glossary” where I have listed all my glossary items with this format:

[?(Glossary) The glossary collects information about important terms used in your document]

This compiles to the following in LATEX:

\newglossaryentry{Glossary}{name=Glossary, description={The glossary collects information about important terms used in your document}}\gls{Glossary}

Unfortunately, I then have to edit my latex file to remove the final “\gls{Glossary}” at the end of each entry.

Does anyone have a solution for that? Is it possible to edit the xslt file somewhere in the scrivener preference files?

Basically you have to handle the MultiMarkdown automation yourself rather than having Scrivener do so. The trick is to set the compile file type to “MultiMarkdown” alone, which will gain you access to the Processing pane in the compile format design interface. From there, you can invoke the MultiMarkdown binary yourself, and include any additional processing you’d like to do to the .tex file after it is produced. This can be done simply, with UNIX pipes, or for more complicated cases, with a script.

There is a practical example of this approach in the user manual project, which is by the way an example of Scriv+MMD+LaTeX. I use a Ruby script to handle the processing phase. It first runs some greps on the .md source file Scrivener creates, then processes that to .tex, and finally does some tweaking to the output syntax before writing the file out to the disk.

For example, since the purpose of the final PDF is a digital reference rather than a printed book, I don’t want each and every Web link printing the full URL as a footnote at the bottom of the page. So I have a regex that strips that out of the .tex file.