Regex replacements behaving erratic in MMD to LaTeX

Hi,

I’m working with Regex in project replacements to manually insert some LaTeX code. For some reason (which I can’t figure out) results seem to be erratic:

Given the minimal example:

I created the minimal example since text just disappeared where I was using this actually, for no obvious reason. Anyhow, with the minimal example, the results are different.

I use the following two replacement rules:

and

I’ve tested both Regex sets using http://www.regexr.com/ where they work just fine.

I then proceed to put that minimal example into a new page of an empty project and have it exported as LaTeX via MMD (However results seem consistent when exporting as .txt, .docx, or .md). Within the project, I have defined the two project replacement rules and turned off any transformations. Following is the outcome of the relevant section:

So for some reason, the code block initiated by tilde followed by “gll” (with 2 l) is correctly parsed, while the one initiated by tilde followed by “glll” (with 3 l) is not. I’ve tried replacing “~glll” by any other string but results are the same. Beats me.

I expect this to be a bug in either Scrivener, MMD, or both. I’m using Scrivener 2.6 (Build 25480) and MultiMarkdown version 4.6 on OSX 10.10.2. A quick google search brought me to comparable errors in Pandoc https://github.com/jgm/pandoc/issues/964, and MMD http://support.multimarkdown.com/discussions/problems/1259-text-cut-after-tilde-is-inserted-yosemite, but both sources claim this issue to be fixed, and the error occurs also where Scrivener does not export via MMD. However since the issue appears for triggers with and without a tilde, I have the suspicion that there are two issues/bugs here.

Even if it is an error withouth an immediate fix, I’d be glad for a work around.

Thanks for the support

Anyone, please? The issue persists and I have been unable to work my way around it…

Don’t have much advice, but Scrivener uses PCRE regex engine, which may be subtly different for your regexes than the Javascript regex library used by regexr.

What happens if you swap the order of the two replacement rules?

Have you tried MMD 4.7.1 (the latest installable by homebrew at least…)

You have an un-escaped repetition indicator in the second parenthetical. Try backslashing the “}”. When I do that, I get a match on the test data. By the way you can test using regular old Cmd-F find, in Scrivener. That should make debugging these a little easier than running compile over and over.

code ([^^\n]+}?)\n([^^\n]+)\n([^^\n]+)\n([^^\n]+)
-HERE-----------^
[/code]