scoavoux / PandocTools

Sublime Text 3 package for pandoc markdown academic writing.
2 stars 0 forks source link

PandocCite removes everything from first opened square bracket of paragraph #7

Closed scoavoux closed 9 years ago

scoavoux commented 9 years ago

When there are already square brackets in a paragraph, if PandocCite is triggered without a @ character, inserting a citation will discard everything from the last opened square bracket.

For instance, if I want to cite otherauth2000 (with PandocCite as the moment where I trigger the command)

Some ref[@auth2000] and I want to include another one[@`PandocCite`

Gives

Some ref[@auth2000] and I want to include another one[@otherauth2000

But

Some ref[@auth2000] and I want to include another one[`PandocCite`

gives

Some ref[@otherauth2000
XachaB commented 9 years ago

This bug should be fixed. The issue was with the regex used. The regex was enforcing that something was typed after the opening bracket.

  Some ref[@auth2000] and I want to include another one[

The program reverses the sentence :

  [eno rehtona edulcni ot tnaw I dna ]0002htua@[fer emoS

It previously used the following regex :

   ([^,^;]+?@?)([;,].+?\[|\[)

This matched correctly when something was following the opening square bracket, but not when the bracket was bare. The fix is to use a star instead of the plus sign, to allow for the first group to be empty :

   ([^,^;]*?@?)([;,].+?\[|\[)