joostkremers / pandoc-mode

An Emacs minor mode for interacting with Pandoc.
https://joostkremers.github.io/pandoc-mode/
178 stars 14 forks source link

Including '[' before citation causes mistaken face #73

Open adql opened 6 years ago

adql commented 6 years ago

Including [ in a paragraph before a citation with suffix causes the pandoc-citation-extra-face (of the suffix) to be applied to the entire text between the first bracket and the citation key.

Steps to reproduce:

  1. Insert a citation+suffix in square brackets in a paragraph.
  2. Insert [ anywhere before the citation in the same paragraph.

Pandoc version 20170720.127 (melpa), Emacs 25.3.2

adql commented 6 years ago

Sorry for the mess, I accidentally published the issue while typing the title.

joostkremers commented 6 years ago

Hmm. I don't seem to be able to reproduce this. Could you share a text snippet that displays the problem?

adql commented 6 years ago

Yes, I now see that I missed some detail: it happens when the citation has a postnote such as page number or some comment. I'll update the description.

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, [quis] nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat [@Jones2010, 5].

The wrong face begins right with the quis which is inside square brackets and continues all the way to the end (where it's correctly applied to the postnote), excluding the key itself which has its own face.

So far I had tried it in markdown-mode+pandoc-mode. Now I tried it in simple text-mode (without any hooks) and got the same result. If it still doesn't reproduce then I can try it on vanilla emacs some time later.

joostkremers commented 6 years ago

Ah yes, I see it now, too. I'll take a look as soon as I can. Most likely it's an incorrect regexp.

Note, BTW, that it only happens with text on a single line. So in the example above the effect disappears if you fill with M-q. Of course that introduces hard breaks into the paragraph, which doesn't really matter for Markdown but it may matter to you.

adql commented 6 years ago

Thanks for the great work!

(Old enough for Emacs, too young for hard breaks)

adql commented 6 years ago

Another workaround: add an html comment <!-- --> with at least one character anywhere between the first [ that causes the problem and the @ marking the citation key. So taking the example above:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, [quis]<!-- --> nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat [@Jones2010, 5].

Should make the facing correct.