area / language-latex

Syntax highlighting for LaTeX for Atom.
Other
78 stars 47 forks source link

Multiple citation highlighting isn't implemented #14

Open jtkiley opened 10 years ago

jtkiley commented 10 years ago

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.

cedhuf commented 9 years ago

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.

jtkiley commented 9 years ago

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.

maxheld83 commented 9 years ago

+1

area commented 7 years ago

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.

jtkiley commented 7 years ago

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.

area commented 7 years ago

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

yudai-nkt commented 7 years ago

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.

jtkiley commented 7 years ago

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