diff options
author | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2012-05-09 13:42:58 +0000 |
---|---|---|
committer | milde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2012-05-09 13:42:58 +0000 |
commit | 5aa46e8d12bd92b7d541ddd22fa81a8164deb46f (patch) | |
tree | 3f6b49db491a209d70ca0107387ff8da0bacd98b /sandbox/code-block-directive/tools/makesty.py | |
parent | a37d1d928b4a49c118bb17c0d49b09f1fc1e685b (diff) | |
download | docutils-5aa46e8d12bd92b7d541ddd22fa81a8164deb46f.tar.gz |
Clean up code-block-directive sandbox project.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@7430 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'sandbox/code-block-directive/tools/makesty.py')
-rw-r--r-- | sandbox/code-block-directive/tools/makesty.py | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/sandbox/code-block-directive/tools/makesty.py b/sandbox/code-block-directive/tools/makesty.py deleted file mode 100644 index 27e17bb09..000000000 --- a/sandbox/code-block-directive/tools/makesty.py +++ /dev/null @@ -1,62 +0,0 @@ -#! /usr/bin/env python -# coding: utf8 -# Copyright: Raphael 'kena' Poss <r.c.poss@uva.nl> -# this file is placed in the public domain. -# -# Convert a CSS stylesheet into one for Docutils' LaTeX output. -# -# Usage example:: -# -# pygmentize -S default -f html | python makesty.py >pygments-default.sty -# -# Versions: -# -# 2012-05-09: Günter Milde <milde@users.sf.net>: -# Bugfix: do not fail at lines without comment. -# Support for digits in role names. -# ``\providecommand`` instead of ``\newcommand``. - -import sys -import re - -print '% Stylesheet for syntax highlight with Docutils' -print '% Generated by makesty.py from a Pygments CSS style' -print '% (output of `pygmentize -S <style> -f html`).' -print -print r'\RequirePackage{color}' - -cnt = 0 -for l in sys.stdin: - - if '/*' in l: - print "% " + l.split('*')[1] - key = l.split(' ', 1)[0][1:] - - 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. - cname = 'DUcolor%d' % cnt - cnt += 1 - print r'\definecolor{%s}{rgb}{%.2f,%.2f,%.2f}' % (cname, r, g, b) - 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) - else: - print r'\providecommand\csname DUrole%s\endcsname[1]{%s}' % (key, s) |