0

I use minted for syntax highlighting

If I give it this C code

int foo () {
   return 123;
}

int bar () {
    int x = foo ();
    ++x;
}

it will colour-highlight foo in the first line, but later when foo is called in the body of bar, it will not be coloured.

How can I add foo to minted's dictionary so that it will be highlighted everywhere that it appears? Similarly, how can I add the variable x to the dictionary so that it will be highlighted in the line ++x?

The minimum requirement is that all minted usages (\begin{minted} or \inputminted) will use the same dictionary of function/variable names (per language).

Ideally, code such as \definecfunction{foo} could appear anywhere in the document (repeatedly), and all minted usages everywhere would pick it up (presumably this would be a two-pass process). Non-ideally, a full list of symbols could be provided in advance.

How can I make this happen?

Browse other questions tagged or ask your own question.