language-latex icon indicating copy to clipboard operation
language-latex copied to clipboard

Multiple citation highlighting isn't implemented

Open jtkiley opened this issue 10 years ago • 8 comments

The single citation commands and keys look fine, but the multiple citation commands do not (e.g. \autocites{}).

I took a look to see if it looked like an easy fix, but it wasn't obvious to me. That's not too surprising, as I haven't had time to dig into really understanding how language packages and the regexes work.

jtkiley avatar Jun 18 '14 21:06 jtkiley

Thanks for the reporting, and sorry for the delay. I'm not used to citations, please can you send me a minimal 'not' working example, and the result you're expected, so i can try to see what's wrong.

cedhuf avatar Sep 01 '14 17:09 cedhuf

No worries. The easiest example is looking at the syntax highlighting for the following commands in Atom:

% The plural version is not highlighted like the singular version.
\autocite{key}
\autocites{key, key2}

% It is also true for starred forms.
\autocite*{key}
\autocites*{key, key2}

% Capitalized versions are not highlighted like the singular version.
\Autocite{key}
\Autocites{key, key2}

% More interesting samples.
\autocite[see][300-311]{key}
\autocites(see)(both generally describing how something relates to something else)[][99-102]{key}[][511-522]{key2}

As far as what I expect, I'd guess that all of the citation commands would have the same syntax highlighting applied. It's a different issue perhaps, but I'd also find it very useful to see keys highlighted.

This issue seems to extend to many citation commands (singular or plural). For a more complete reference of these commands, see The Biblatex Package (pdf) at pp. 83–92. It may just be me, but I cannot recall using anything described in the Special, Low-level, or Miscellaneous command sections of that document.

I'd send you a pull request if I could, but I'm not sure (i) how the syntax definitions work and (ii) what the overall highlighting design is (i.e. categories that should get the same styles; e.g. math, quotes, commands, options). If you have some links or examples, just point me in the right direction. I'm fairly time constrained in the short term, but, in the medium term, a lot of these (or similar issues) could be easy fixes if I had knowledge of the pattern.

jtkiley avatar Sep 02 '14 17:09 jtkiley

+1

maxheld83 avatar Oct 14 '14 21:10 maxheld83

I don't believe it's possible for the last example to be highlighted correctly, as it involves an unknown number of groups, which isn't something that regex can deal with. If I'm wrong, do let me know.

I've also not introduced the capitalised versions - in my experience LaTeX commands are lowercase by convention. If enough people object to that though, I'll revisit.

area avatar Oct 02 '16 13:10 area

The capitalized versions are defined in the package as a way of handling capitalization of name prefixes (e.g. when an cited work has an author last name with a prefix that is lower case by convention but needs to be capitalized for style or sentence beginning reasons). See the pdf I linked above, pp. 93-101.

There are also other capitalized commands in the package, too.

jtkiley avatar Oct 03 '16 02:10 jtkiley

Ah, apologies, I hadn't appreciated that the capitalised versions of these commands provided distinct functionality.

area avatar Oct 03 '16 08:10 area

an unknown number of groups, which isn't something that regex can deal with

I think we can parse \autocites' syntax by the following regex (this is the result):

/(\\[aA]utocites)(?:(\()([^)]*)(\))){0,2}(?:(?:(\[)([^\]]*)(\])){0,2}(\{)([^}]*)(\}))+/

However, this regex doesn't highlight the syntax properly, which lead me to open a question at Atom's forum. After we get some reaction there, we can decide whether it is possible or not.

yudai-nkt avatar Oct 03 '16 10:10 yudai-nkt

@area: No worries. Thanks for your work on this.

jtkiley avatar Oct 03 '16 17:10 jtkiley