YAMLLexer implementation contributed by Kirill Simonov

Create issue
Issue #328 resolved
jeffk created an issue

In response to my thread post on yaml-core mailing list, Kirill Simonov, author of PyYAML and libyaml, kindly posted an initial implementation of YAMLLexer: {{{ Date: Mon, 19 May 2008 03:18:57 +0300 From: "Kirill Simonov" xi@resolvent.net CC: yaml-core@lists.sourceforge.net Subject: Re: [Yaml-core] Pygments YAML Lexer (from Spec Update)

Here is my attempt to write a YAML lexer for Pygments. It's hardly tested, so expect bugs. I was also unable to choose suitable token types from the existing tokens provided by the package, so I had to create YAML-specific tokens

I've attached the lexer file as well as a yaml file I've used for tests.

Thanks, Kirill }}}

Testing the included yaml.py and example.yaml, integrated the code into lexers/text.py, per #pocoo suggestion of mitsuhiko.

Kirill's yaml.py carries the following docstring:

yaml.py

{{{ """ yaml.py

Lexer for YAML, a human-friendly data serialization language (http://yaml.org/).

Written by Kirill Simonov xi@resolvent.net.

License: Whatever suitable for inclusion into the Pygments package. """ }}}

Note that the custom token styles would greatly benefit from a pygments expert assigning the custom styles to pygments built-in styles, so that themes, etc. can work with YAMLLexer without additional effort.

Attached is the yamllexer.hg bundle, and a screenshot of the example.yaml output example.html with CSS id and style information overlay, for visual reference.

Please consider Kirill's YAMLLexer implementation for inclusion in pygments-main, Thank you.

Comments (2)

  1. gbrandl

    Thanks for the great contribution! Added in [0e137fe003ab] and adapted a bit to Pygments coding styles, also used common token types to get more highlighting with the default styles.

  2. Log in to comment