4

Say I have the following key-value file I want to highlight using the listings package:

some.key=Some value

I want the key to be red, the equal sign to be black and the value to be blue. How do I define a language in listings that does that? I am aware of the moredelim, morekeywords but I can't figure out how to use their options to do what I want.

johnrl
  • 447
  • Welcome to TeX.SX! Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Mar 21 '14 at 14:50
  • Perhaps there is a language that uses this syntax? – Sean Allred Mar 21 '14 at 14:50
  • @SeanAllred: Perhaps the language is TeX or LaTeX itself? –  Mar 21 '14 at 14:52
  • It may be possible. It depends on the language you're using. What is it? Could you post a longer code sample and list all your syntax highlighting specs? Related: http://tex.stackexchange.com/questions/81646/how-can-i-highlight-text-before-a-character-with-listing, http://tex.stackexchange.com/questions/152829/lstdefinelanguage-for-yaml – jub0bs Mar 21 '14 at 14:53
  • @Christian Perhaps, but I would be at least a little surprised if it took keyval syntax into account. (Does the PGF manual use listings?) – Sean Allred Mar 21 '14 at 14:54
  • @Jubobs I think those links answered my questions. It seems the real problem here is how to highlight the key automatically without hardcoding it as a keyword in listings. And it seems like the answer in general is: not possible. Too bad – johnrl Mar 21 '14 at 14:58
  • @SeanAllred: I have used listings only for c or c++ code so far, I can't tell about TeX support or even keyval syntax. –  Mar 21 '14 at 14:59
  • 1
    @johnrl Should we close this question as a duplicate? – jub0bs Mar 21 '14 at 14:59
  • @Jubobs yes please – johnrl Mar 21 '14 at 14:59

0 Answers0