From 0de81bba8ca5a4fedace010a88027591071cde36 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 26 Dec 2013 07:49:20 +0100 Subject: Help: Workaround pygments reporting an error for genexes. Without the workaround, CMake code snippets are not highlighted at all because pygments can not lex the generator expressions. --- Utilities/Sphinx/cmake.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Utilities/Sphinx/cmake.py b/Utilities/Sphinx/cmake.py index 1955e42..336c74a 100644 --- a/Utilities/Sphinx/cmake.py +++ b/Utilities/Sphinx/cmake.py @@ -12,6 +12,16 @@ import os import re +# Monkey patch for pygments reporting an error when generator expressions are +# used. +# https://bitbucket.org/birkenfeld/pygments-main/issue/942/cmake-generator-expressions-not-handled +from pygments.lexers import CMakeLexer +from pygments.token import Name, Operator +from pygments.lexer import bygroups +CMakeLexer.tokens["args"].append(('(\\$<)(.+?)(>)', + bygroups(Operator, Name.Variable, Operator))) + + from docutils.parsers.rst import Directive, directives from docutils.transforms import Transform try: -- cgit v0.12