summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2012-05-06 19:10:43 +0000
committermilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2012-05-06 19:10:43 +0000
commit70d08a48eb71481f8ce0cff14b47f5c2775cb85b (patch)
tree6059730df3410df86c0ff55f1b9dbd2c600964d4
parent691c65e0e917d5c3850bb269b0c5ee826d4f2b58 (diff)
downloaddocutils-70d08a48eb71481f8ce0cff14b47f5c2775cb85b.tar.gz
Stylesheet converter and example stylesheet for syntax highlight with LaTeX.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7427 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
-rw-r--r--sandbox/code-block-directive/tools/makesty.py53
-rw-r--r--sandbox/code-block-directive/tools/pygments-docutilsroles.sty122
2 files changed, 175 insertions, 0 deletions
diff --git a/sandbox/code-block-directive/tools/makesty.py b/sandbox/code-block-directive/tools/makesty.py
new file mode 100644
index 000000000..b1b0fe6f1
--- /dev/null
+++ b/sandbox/code-block-directive/tools/makesty.py
@@ -0,0 +1,53 @@
+#! /usr/bin/env python
+# Copyright: Raphael 'kena' Poss <r.c.poss@uva.nl>
+# this file is placed in the public domain.
+
+# Use with: pygmentize -S default -f html | python makesty.py >pygments-DUroles.sty
+
+import sys
+import re
+
+d = re.compile(r'.*[0-9]')
+
+print r'%% Stylesheet generated by %s' % sys.argv[0]
+print r'\usepackage{color}'
+
+cnt = 0
+for l in sys.stdin:
+
+ print "% " + l.split('*')[1]
+ key = l.split(' ', 1)[0][1:]
+
+ if d.match(key) is not None:
+ print "%% Can't generate style for '%s' because 'DUrole%s' is not a valid macro id." % (key,key)
+ continue
+
+ s = '#1'
+
+ if 'color:' in l:
+ col = l.split('#',1)[1][:6]
+ r = float(int(col[0:2], 16)) / 255.
+ g = float(int(col[2:4], 16)) / 255.
+ b = float(int(col[4:6], 16)) / 255.
+ s = r'\textcolor[rgb]{%.2f,%.2f,%.2f}{%s}' % (r, g, b, s)
+
+ if 'font-style: italic' in l:
+ s = r'\textit{%s}' % s
+ if 'font-weight: bold' in l:
+ s = r'\textbf{%s}' % s
+
+ if 'border:' in l:
+ col = l.split('#',1)[1][:6]
+ r = float(int(col[0:2], 16)) / 255.
+ g = float(int(col[2:4], 16)) / 255.
+ b = float(int(col[4:6], 16)) / 255.
+ cn = 'ducolor%d' % cnt
+ cnt += 1
+ print r'\definecolor{%s}{rgb}{%.2f,%.2f,%.2f}' % (cn, r, g, b)
+ s = r'\colorbox{%s}{%s}' % (cn, s)
+
+ print r'\newcommand\DUrole%s[1]{%s}' % (key, s)
+
+# These seem to be special
+print r'\newcommand\DUrolep[1]{#1}'
+
diff --git a/sandbox/code-block-directive/tools/pygments-docutilsroles.sty b/sandbox/code-block-directive/tools/pygments-docutilsroles.sty
new file mode 100644
index 000000000..a3caea642
--- /dev/null
+++ b/sandbox/code-block-directive/tools/pygments-docutilsroles.sty
@@ -0,0 +1,122 @@
+% Stylesheet generated by makesty.py
+\usepackage{color}
+% Comment
+\newcommand\docutilsrolec[1]{\textit{\textcolor[rgb]{0.25,0.50,0.50}{#1}}}
+% Error
+\definecolor{ducolor0}{rgb}{1.00,0.00,0.00}
+\newcommand\docutilsroleerr[1]{\colorbox{ducolor0}{#1}}
+% Keyword
+\newcommand\docutilsrolek[1]{\textbf{\textcolor[rgb]{0.00,0.50,0.00}{#1}}}
+% Operator
+\newcommand\docutilsroleo[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
+% Comment.Multiline
+\newcommand\docutilsrolecm[1]{\textit{\textcolor[rgb]{0.25,0.50,0.50}{#1}}}
+% Comment.Preproc
+\newcommand\docutilsrolecp[1]{\textcolor[rgb]{0.74,0.48,0.00}{#1}}
+% Comment.Single
+% Can't generate style for 'c1' because 'docutilsrolec1' is not a valid macro id.
+% Comment.Special
+\newcommand\docutilsrolecs[1]{\textit{\textcolor[rgb]{0.25,0.50,0.50}{#1}}}
+% Generic.Deleted
+\newcommand\docutilsrolegd[1]{\textcolor[rgb]{0.63,0.00,0.00}{#1}}
+% Generic.Emph
+\newcommand\docutilsrolege[1]{\textit{#1}}
+% Generic.Error
+\newcommand\docutilsrolegr[1]{\textcolor[rgb]{1.00,0.00,0.00}{#1}}
+% Generic.Heading
+\newcommand\docutilsrolegh[1]{\textbf{\textcolor[rgb]{0.00,0.00,0.50}{#1}}}
+% Generic.Inserted
+\newcommand\docutilsrolegi[1]{\textcolor[rgb]{0.00,0.63,0.00}{#1}}
+% Generic.Output
+\newcommand\docutilsrolego[1]{\textcolor[rgb]{0.50,0.50,0.50}{#1}}
+% Generic.Prompt
+\newcommand\docutilsrolegp[1]{\textbf{\textcolor[rgb]{0.00,0.00,0.50}{#1}}}
+% Generic.Strong
+\newcommand\docutilsrolegs[1]{\textbf{#1}}
+% Generic.Subheading
+\newcommand\docutilsrolegu[1]{\textbf{\textcolor[rgb]{0.50,0.00,0.50}{#1}}}
+% Generic.Traceback
+\newcommand\docutilsrolegt[1]{\textcolor[rgb]{0.00,0.25,0.82}{#1}}
+% Keyword.Constant
+\newcommand\docutilsrolekc[1]{\textbf{\textcolor[rgb]{0.00,0.50,0.00}{#1}}}
+% Keyword.Declaration
+\newcommand\docutilsrolekd[1]{\textbf{\textcolor[rgb]{0.00,0.50,0.00}{#1}}}
+% Keyword.Pseudo
+\newcommand\docutilsrolekp[1]{\textcolor[rgb]{0.00,0.50,0.00}{#1}}
+% Keyword.Reserved
+\newcommand\docutilsrolekr[1]{\textbf{\textcolor[rgb]{0.00,0.50,0.00}{#1}}}
+% Keyword.Type
+\newcommand\docutilsrolekt[1]{\textcolor[rgb]{0.69,0.00,0.25}{#1}}
+% Literal.Number
+\newcommand\docutilsrolem[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
+% Literal.String
+\newcommand\docutilsroles[1]{\textcolor[rgb]{0.73,0.13,0.13}{#1}}
+% Name.Attribute
+\newcommand\docutilsrolena[1]{\textcolor[rgb]{0.49,0.56,0.16}{#1}}
+% Name.Builtin
+\newcommand\docutilsrolenb[1]{\textcolor[rgb]{0.00,0.50,0.00}{#1}}
+% Name.Class
+\newcommand\docutilsrolenc[1]{\textbf{\textcolor[rgb]{0.00,0.00,1.00}{#1}}}
+% Name.Constant
+\newcommand\docutilsroleno[1]{\textcolor[rgb]{0.53,0.00,0.00}{#1}}
+% Name.Decorator
+\newcommand\docutilsrolend[1]{\textcolor[rgb]{0.67,0.13,1.00}{#1}}
+% Name.Entity
+\newcommand\docutilsroleni[1]{\textbf{\textcolor[rgb]{0.60,0.60,0.60}{#1}}}
+% Name.Exception
+\newcommand\docutilsrolene[1]{\textbf{\textcolor[rgb]{0.82,0.25,0.23}{#1}}}
+% Name.Function
+\newcommand\docutilsrolenf[1]{\textcolor[rgb]{0.00,0.00,1.00}{#1}}
+% Name.Label
+\newcommand\docutilsrolenl[1]{\textcolor[rgb]{0.63,0.63,0.00}{#1}}
+% Name.Namespace
+\newcommand\docutilsrolenn[1]{\textbf{\textcolor[rgb]{0.00,0.00,1.00}{#1}}}
+% Name.Tag
+\newcommand\docutilsrolent[1]{\textbf{\textcolor[rgb]{0.00,0.50,0.00}{#1}}}
+% Name.Variable
+\newcommand\docutilsrolenv[1]{\textcolor[rgb]{0.10,0.09,0.49}{#1}}
+% Operator.Word
+\newcommand\docutilsroleow[1]{\textbf{\textcolor[rgb]{0.67,0.13,1.00}{#1}}}
+% Text.Whitespace
+\newcommand\docutilsrolew[1]{\textcolor[rgb]{0.73,0.73,0.73}{#1}}
+% Literal.Number.Float
+\newcommand\docutilsrolemf[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
+% Literal.Number.Hex
+\newcommand\docutilsrolemh[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
+% Literal.Number.Integer
+\newcommand\docutilsrolemi[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
+% Literal.Number.Oct
+\newcommand\docutilsrolemo[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
+% Literal.String.Backtick
+\newcommand\docutilsrolesb[1]{\textcolor[rgb]{0.73,0.13,0.13}{#1}}
+% Literal.String.Char
+\newcommand\docutilsrolesc[1]{\textcolor[rgb]{0.73,0.13,0.13}{#1}}
+% Literal.String.Doc
+\newcommand\docutilsrolesd[1]{\textit{\textcolor[rgb]{0.73,0.13,0.13}{#1}}}
+% Literal.String.Double
+% Can't generate style for 's2' because 'docutilsroles2' is not a valid macro id.
+% Literal.String.Escape
+\newcommand\docutilsrolese[1]{\textbf{\textcolor[rgb]{0.73,0.40,0.13}{#1}}}
+% Literal.String.Heredoc
+\newcommand\docutilsrolesh[1]{\textcolor[rgb]{0.73,0.13,0.13}{#1}}
+% Literal.String.Interpol
+\newcommand\docutilsrolesi[1]{\textbf{\textcolor[rgb]{0.73,0.40,0.53}{#1}}}
+% Literal.String.Other
+\newcommand\docutilsrolesx[1]{\textcolor[rgb]{0.00,0.50,0.00}{#1}}
+% Literal.String.Regex
+\newcommand\docutilsrolesr[1]{\textcolor[rgb]{0.73,0.40,0.53}{#1}}
+% Literal.String.Single
+% Can't generate style for 's1' because 'docutilsroles1' is not a valid macro id.
+% Literal.String.Symbol
+\newcommand\docutilsroless[1]{\textcolor[rgb]{0.10,0.09,0.49}{#1}}
+% Name.Builtin.Pseudo
+\newcommand\docutilsrolebp[1]{\textcolor[rgb]{0.00,0.50,0.00}{#1}}
+% Name.Variable.Class
+\newcommand\docutilsrolevc[1]{\textcolor[rgb]{0.10,0.09,0.49}{#1}}
+% Name.Variable.Global
+\newcommand\docutilsrolevg[1]{\textcolor[rgb]{0.10,0.09,0.49}{#1}}
+% Name.Variable.Instance
+\newcommand\docutilsrolevi[1]{\textcolor[rgb]{0.10,0.09,0.49}{#1}}
+% Literal.Number.Integer.Long
+\newcommand\docutilsroleil[1]{\textcolor[rgb]{0.40,0.40,0.40}{#1}}
+\newcommand\docutilsrolep[1]{#1}