From 89175dfa3d4b576fe187d92e167d0593cc9170e1 Mon Sep 17 00:00:00 2001 From: milde Date: Wed, 27 Mar 2013 16:48:25 +0000 Subject: [PATCH] Fix LaTeX syntax-highlight stylesheets pygments*sty and generating script. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Bugfix for pygments_css2sty.py by Juan Luis Cano Rodríguez. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7642 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- sandbox/stylesheets/pygments-default.sty | 6 +++--- sandbox/stylesheets/pygments-long.sty | 28 +++++++++++++++++----------- sandbox/stylesheets/pygments_css2sty.py | 7 +++++-- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/sandbox/stylesheets/pygments-default.sty b/sandbox/stylesheets/pygments-default.sty index 12c5a42f4..343862a10 100644 --- a/sandbox/stylesheets/pygments-default.sty +++ b/sandbox/stylesheets/pygments-default.sty @@ -18,7 +18,7 @@ % Comment.Preproc \providecommand*\DUrolecp[1]{\textcolor[rgb]{0.74,0.48,0.00}{#1}} % Comment.Single -\providecommand\csname DUrolec1\endcsname[1]{\textit{\textcolor[rgb]{0.25,0.50,0.50}{#1}}} +\expandafter\providecommand\csname DUrolec1\endcsname[1]{\textit{\textcolor[rgb]{0.25,0.50,0.50}{#1}}} % Comment.Special \providecommand*\DUrolecs[1]{\textit{\textcolor[rgb]{0.25,0.50,0.50}{#1}}} % Generic.Deleted @@ -100,7 +100,7 @@ % Literal.String.Doc \providecommand*\DUrolesd[1]{\textit{\textcolor[rgb]{0.73,0.13,0.13}{#1}}} % Literal.String.Double -\providecommand\csname DUroles2\endcsname[1]{\textcolor[rgb]{0.73,0.13,0.13}{#1}} +\expandafter\providecommand\csname DUroles2\endcsname[1]{\textcolor[rgb]{0.73,0.13,0.13}{#1}} % Literal.String.Escape \providecommand*\DUrolese[1]{\textbf{\textcolor[rgb]{0.73,0.40,0.13}{#1}}} % Literal.String.Heredoc @@ -112,7 +112,7 @@ % Literal.String.Regex \providecommand*\DUrolesr[1]{\textcolor[rgb]{0.73,0.40,0.53}{#1}} % Literal.String.Single -\providecommand\csname DUroles1\endcsname[1]{\textcolor[rgb]{0.73,0.13,0.13}{#1}} +\expandafter\providecommand\csname DUroles1\endcsname[1]{\textcolor[rgb]{0.73,0.13,0.13}{#1}} % Literal.String.Symbol \providecommand*\DUroless[1]{\textcolor[rgb]{0.10,0.09,0.49}{#1}} % Name.Builtin.Pseudo diff --git a/sandbox/stylesheets/pygments-long.sty b/sandbox/stylesheets/pygments-long.sty index 103aa2988..0ba09af2b 100644 --- a/sandbox/stylesheets/pygments-long.sty +++ b/sandbox/stylesheets/pygments-long.sty @@ -1,13 +1,20 @@ -/* example stylesheet for Docutils */ - -/* :Author: Günter Milde */ -/* :Copyright: © 2012 G. Milde */ -/* :License: This stylesheet is placed in the public domain. */ - -/* Syntax highlight rules for LaTeX documents generated with Docutils */ -/* using the ``--syntax-highlight=long`` option (new in v. 0.9). */ - -/* This stylesheet implements a very basic style with only few rules. */ +% Minimal syntax highlight style for Docutils +% +% :Author: Günter Milde +% :Copyright: © 2013 G. Milde +% :License: Released under the terms of the `2-Clause BSD license`_, in short: +% +% Copying and distribution of this file, with or without modification, +% are permitted in any medium without royalty provided the copyright +% notice and this notice are preserved. +% This file is offered as-is, without any warranty. +% +% .. _2-Clause BSD license: http://www.spdx.org/licenses/BSD-2-Clause +% +% Syntax highlight rules for LaTeX documents generated with Docutils +% using the ``--syntax-highlight=long`` option (new in v. 0.9). +% +% This stylesheet implements a very basic style with only few rules. \newcommand\DUrolecomment[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}} \newcommand\DUrolekeyword[1]{\textbf{#1}} @@ -15,4 +22,3 @@ \newcommand\DUrolebuiltin[1]{\textbf{#1}} \newcommand\DUrolestring[1]{\textit{#1}} % \newcommand\DUroleoperator[1]{\textcolor[rgb]{0.72,0.53,0.04}{#1}} - diff --git a/sandbox/stylesheets/pygments_css2sty.py b/sandbox/stylesheets/pygments_css2sty.py index ef079054c..185050b7a 100644 --- a/sandbox/stylesheets/pygments_css2sty.py +++ b/sandbox/stylesheets/pygments_css2sty.py @@ -16,6 +16,8 @@ # Support for digits in role names. # ``\providecommand`` instead of ``\newcommand``. # Renamed from makesty.py to pygments_css2sty.py. +# 2013-03-27: Günter Milde: +# Implement bugfix from Juan Luis Cano Rodríguez for csnames. import sys import re @@ -58,6 +60,7 @@ for l in sys.stdin: s = r'\colorbox{%s}{%s}' % (cname, s) if re.match(r'.*[0-9]', key) is None: - print r'\providecommand*\DUrole%s[1]{%s}' % (key, s) + print(r'\providecommand*\DUrole%s[1]{%s}' % (key, s)) else: - print r'\providecommand\csname DUrole%s\endcsname[1]{%s}' % (key, s) + print(r'\expandafter\providecommand\csname DUrole%s\endcsname[1]{%s}' + % (key, s)) -- 2.11.4.GIT