summaryrefslogtreecommitdiff
path: root/sandbox/code-block-directive/docs
diff options
context:
space:
mode:
authormilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2009-02-24 11:40:50 +0000
committermilde <milde@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2009-02-24 11:40:50 +0000
commit17b8a432d43e18bec738fbec1ebd2cca1ebcf041 (patch)
treebbdad678bad69c9f957066e2a2d1c74f7b2fa4d7 /sandbox/code-block-directive/docs
parent3eeffd4ba5169690bf321b6a96a1e814e74e259d (diff)
downloaddocutils-17b8a432d43e18bec738fbec1ebd2cca1ebcf041.tar.gz
sandbox/code-block-directive: Add LaTeX front end, update
documentation and examples git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@5873 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'sandbox/code-block-directive/docs')
-rw-r--r--sandbox/code-block-directive/docs/myfunction.py.htm119
-rw-r--r--sandbox/code-block-directive/docs/myfunction.py.newlatex2e.pdfbin16929 -> 0 bytes
-rw-r--r--sandbox/code-block-directive/docs/myfunction.py.newlatex2e.tex209
-rw-r--r--sandbox/code-block-directive/docs/myfunction.py.pdfbin0 -> 38686 bytes
-rw-r--r--sandbox/code-block-directive/docs/myfunction.py.tex6
-rw-r--r--sandbox/code-block-directive/docs/myfunction.py.txt4
-rw-r--r--sandbox/code-block-directive/docs/pygments_code_block_directive-bunt.py.htm314
-rw-r--r--sandbox/code-block-directive/docs/pygments_code_block_directive-bunt.py.txt191
-rw-r--r--sandbox/code-block-directive/docs/pygments_code_block_directive.py.htm263
-rw-r--r--sandbox/code-block-directive/docs/syntax-highlight.txt91
10 files changed, 163 insertions, 1034 deletions
diff --git a/sandbox/code-block-directive/docs/myfunction.py.htm b/sandbox/code-block-directive/docs/myfunction.py.htm
index edc700246..62f7ae00f 100644
--- a/sandbox/code-block-directive/docs/myfunction.py.htm
+++ b/sandbox/code-block-directive/docs/myfunction.py.htm
@@ -1,29 +1,126 @@
-<?xml version="1.0" encoding="iso-8859-1" ?>
+<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
-<meta name="generator" content="Docutils 0.4.1: http://docutils.sourceforge.net/" />
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
<title></title>
-<link rel="stylesheet" href="../data/pygments-default.css" type="text/css" />
+<style type="text/css">
+
+/* Stylesheet for pygments enhanced reStructured Text */
+/* ================================================== */
+
+/* :Author: Guenter Milde */
+/* :Copyright: 2007 G. Milde */
+/* This stylesheet is released under the GPL v. 2 or later */
+
+/* This stylesheet provides syntax highlight for documents generated with a */
+/* pygments_ enhanced reStructured Text -> html converter. */
+
+/* Import the default docutils style sheet */
+/* --------------------------------------- */
+/* :: */
+
+@import url("/stylesheets/html4css1.css");
+
+/* Indent the code block */
+/* --------------------- */
+
+/* Content copied from the `html4css1.css` rule for literal blocks. */
+/* Selector adapted to the output of Pygments_. :: */
+
+div.highlight {
+ margin-left: 2em ;
+ margin-right: 2em ;
+ background-color: #eeeeee
+ }
+
+
+/* Colour code blocks */
+/* ------------------ */
+
+/* Pygments_ has an option to generate stylesheets for html and latex. */
+/* The following code is generated with the command */
+/* `pygmentize -S default -f html > pygments-default.css`:: */
+
+.c { color: #008800; font-style: italic } /* Comment */
+.err { border: 1px solid #FF0000 } /* Error */
+.k { color: #AA22FF; font-weight: bold } /* Keyword */
+.o { color: #666666 } /* Operator */
+.cm { color: #008800; font-style: italic } /* Comment.Multiline */
+.cp { color: #008800 } /* Comment.Preproc */
+.c1 { color: #008800; font-style: italic } /* Comment.Single */
+.gd { color: #A00000 } /* Generic.Deleted */
+.ge { font-style: italic } /* Generic.Emph */
+.gr { color: #FF0000 } /* Generic.Error */
+.gh { color: #000080; font-weight: bold } /* Generic.Heading */
+.gi { color: #00A000 } /* Generic.Inserted */
+.go { color: #808080 } /* Generic.Output */
+.gp { color: #000080; font-weight: bold } /* Generic.Prompt */
+.gs { font-weight: bold } /* Generic.Strong */
+.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
+.gt { color: #0040D0 } /* Generic.Traceback */
+.kc { color: #AA22FF; font-weight: bold } /* Keyword.Constant */
+.kd { color: #AA22FF; font-weight: bold } /* Keyword.Declaration */
+.kp { color: #AA22FF } /* Keyword.Pseudo */
+.kr { color: #AA22FF; font-weight: bold } /* Keyword.Reserved */
+.kt { color: #AA22FF; font-weight: bold } /* Keyword.Type */
+.m { color: #666666 } /* Literal.Number */
+.s { color: #BB4444 } /* Literal.String */
+.na { color: #BB4444 } /* Name.Attribute */
+.nb { color: #AA22FF } /* Name.Builtin */
+.nc { color: #0000FF } /* Name.Class */
+.no { color: #880000 } /* Name.Constant */
+.nd { color: #AA22FF } /* Name.Decorator */
+.ni { color: #999999; font-weight: bold } /* Name.Entity */
+.ne { color: #D2413A; font-weight: bold } /* Name.Exception */
+.nf { color: #00A000 } /* Name.Function */
+.nl { color: #A0A000 } /* Name.Label */
+.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
+.nt { color: #008000; font-weight: bold } /* Name.Tag */
+.nv { color: #B8860B } /* Name.Variable */
+.ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
+.mf { color: #666666 } /* Literal.Number.Float */
+.mh { color: #666666 } /* Literal.Number.Hex */
+.mi { color: #666666 } /* Literal.Number.Integer */
+.mo { color: #666666 } /* Literal.Number.Oct */
+.sb { color: #BB4444 } /* Literal.String.Backtick */
+.sc { color: #BB4444 } /* Literal.String.Char */
+.sd { color: #BB4444; font-style: italic } /* Literal.String.Doc */
+.s2 { color: #BB4444 } /* Literal.String.Double */
+.se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
+.sh { color: #BB4444 } /* Literal.String.Heredoc */
+.si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
+.sx { color: #008000 } /* Literal.String.Other */
+.sr { color: #BB6688 } /* Literal.String.Regex */
+.s1 { color: #BB4444 } /* Literal.String.Single */
+.ss { color: #B8860B } /* Literal.String.Symbol */
+.bp { color: #AA22FF } /* Name.Builtin.Pseudo */
+.vc { color: #B8860B } /* Name.Variable.Class */
+.vg { color: #B8860B } /* Name.Variable.Global */
+.vi { color: #B8860B } /* Name.Variable.Instance */
+.il { color: #666666 } /* Literal.Number.Integer.Long */
+
+/* .. _pygments: http://pygments.org/ */
+
+</style>
</head>
<body>
<div class="document">
+
+
<p>This is a test of the new code-block directive:</p>
<!-- Translate this document to HTML with a pygments enhanced frontend, e.g.
-rst2html-highlight - -stylesheet=pygments-default.css - -link-stylesheet -->
+../rst2html-highlight - -stylesheet=../data/pygments-default.css
+
+../rst2latex-highlight - -stylesheet=../data/pygments-docutileroles.sty -->
<pre class="code-block python literal-block">
<span class="k">def</span> <span class="nf">my_function</span><span class="p">():</span>
<span class="s">&quot;just a test&quot;</span>
- <span class="k">print</span> <span class="mi">8</span><span class="o">/</span><span class="mi">2</span>
+ <span class="k">print</span> <span class="mf">8</span><span class="o">/</span><span class="mf">2</span>
</pre>
</div>
-<div class="footer">
-<hr class="footer" />
-Generated on: 2007-06-05.
-
-</div>
</body>
</html>
diff --git a/sandbox/code-block-directive/docs/myfunction.py.newlatex2e.pdf b/sandbox/code-block-directive/docs/myfunction.py.newlatex2e.pdf
deleted file mode 100644
index 658eb59d7..000000000
--- a/sandbox/code-block-directive/docs/myfunction.py.newlatex2e.pdf
+++ /dev/null
Binary files differ
diff --git a/sandbox/code-block-directive/docs/myfunction.py.newlatex2e.tex b/sandbox/code-block-directive/docs/myfunction.py.newlatex2e.tex
deleted file mode 100644
index d2d67cfea..000000000
--- a/sandbox/code-block-directive/docs/myfunction.py.newlatex2e.tex
+++ /dev/null
@@ -1,209 +0,0 @@
-% Generated by Docutils 0.4.1 <http://docutils.sourceforge.net>.
-
-% Docutils settings:
-\providecommand{\Dlanguageiso}{en}
-\providecommand{\Dlanguagebabel}{english}
-
-% Docutils stylesheet:
-\input{/usr/lib/python2.4/site-packages/docutils/writers/newlatex2e/base.tex}
-
-% Default definitions for Docutils nodes:
-\providecommand{\DNText}[1]{#1}
-\providecommand{\DNabbreviation}[1]{#1}
-\providecommand{\DNacronym}[1]{#1}
-\providecommand{\DNaddress}[1]{#1}
-\providecommand{\DNadmonition}[1]{#1}
-\providecommand{\DNattention}[1]{#1}
-\providecommand{\DNattribution}[1]{#1}
-\providecommand{\DNauthor}[1]{#1}
-\providecommand{\DNauthors}[1]{#1}
-\providecommand{\DNblockquote}[1]{#1}
-\providecommand{\DNbulletlist}[1]{#1}
-\providecommand{\DNcaption}[1]{#1}
-\providecommand{\DNcaution}[1]{#1}
-\providecommand{\DNcitation}[1]{#1}
-\providecommand{\DNcitationreference}[1]{#1}
-\providecommand{\DNclassifier}[1]{#1}
-\providecommand{\DNcolspec}[1]{#1}
-\providecommand{\DNcomment}[1]{#1}
-\providecommand{\DNcompound}[1]{#1}
-\providecommand{\DNcontact}[1]{#1}
-\providecommand{\DNcontainer}[1]{#1}
-\providecommand{\DNcopyright}[1]{#1}
-\providecommand{\DNdanger}[1]{#1}
-\providecommand{\DNdate}[1]{#1}
-\providecommand{\DNdecoration}[1]{#1}
-\providecommand{\DNdefinition}[1]{#1}
-\providecommand{\DNdefinitionlist}[1]{#1}
-\providecommand{\DNdefinitionlistitem}[1]{#1}
-\providecommand{\DNdescription}[1]{#1}
-\providecommand{\DNdocinfo}[1]{#1}
-\providecommand{\DNdoctestblock}[1]{#1}
-\providecommand{\DNdocument}[1]{#1}
-\providecommand{\DNemphasis}[1]{#1}
-\providecommand{\DNentry}[1]{#1}
-\providecommand{\DNenumeratedlist}[1]{#1}
-\providecommand{\DNerror}[1]{#1}
-\providecommand{\DNfield}[1]{#1}
-\providecommand{\DNfieldbody}[1]{#1}
-\providecommand{\DNfieldlist}[1]{#1}
-\providecommand{\DNfieldname}[1]{#1}
-\providecommand{\DNfigure}[1]{#1}
-\providecommand{\DNfooter}[1]{#1}
-\providecommand{\DNfootnote}[1]{#1}
-\providecommand{\DNfootnotereference}[1]{#1}
-\providecommand{\DNgenerated}[1]{#1}
-\providecommand{\DNheader}[1]{#1}
-\providecommand{\DNhint}[1]{#1}
-\providecommand{\DNimage}[1]{#1}
-\providecommand{\DNimportant}[1]{#1}
-\providecommand{\DNinline}[1]{#1}
-\providecommand{\DNlabel}[1]{#1}
-\providecommand{\DNlegend}[1]{#1}
-\providecommand{\DNline}[1]{#1}
-\providecommand{\DNlineblock}[1]{#1}
-\providecommand{\DNlistitem}[1]{#1}
-\providecommand{\DNliteral}[1]{#1}
-\providecommand{\DNliteralblock}[1]{#1}
-\providecommand{\DNnote}[1]{#1}
-\providecommand{\DNoption}[1]{#1}
-\providecommand{\DNoptionargument}[1]{#1}
-\providecommand{\DNoptiongroup}[1]{#1}
-\providecommand{\DNoptionlist}[1]{#1}
-\providecommand{\DNoptionlistitem}[1]{#1}
-\providecommand{\DNoptionstring}[1]{#1}
-\providecommand{\DNorganization}[1]{#1}
-\providecommand{\DNparagraph}[1]{#1}
-\providecommand{\DNpending}[1]{#1}
-\providecommand{\DNproblematic}[1]{#1}
-\providecommand{\DNraw}[1]{#1}
-\providecommand{\DNreference}[1]{#1}
-\providecommand{\DNrevision}[1]{#1}
-\providecommand{\DNrow}[1]{#1}
-\providecommand{\DNrubric}[1]{#1}
-\providecommand{\DNsection}[1]{#1}
-\providecommand{\DNsidebar}[1]{#1}
-\providecommand{\DNstatus}[1]{#1}
-\providecommand{\DNstrong}[1]{#1}
-\providecommand{\DNsubscript}[1]{#1}
-\providecommand{\DNsubstitutiondefinition}[1]{#1}
-\providecommand{\DNsubstitutionreference}[1]{#1}
-\providecommand{\DNsubtitle}[1]{#1}
-\providecommand{\DNsuperscript}[1]{#1}
-\providecommand{\DNsystemmessage}[1]{#1}
-\providecommand{\DNtable}[1]{#1}
-\providecommand{\DNtarget}[1]{#1}
-\providecommand{\DNtbody}[1]{#1}
-\providecommand{\DNterm}[1]{#1}
-\providecommand{\DNtgroup}[1]{#1}
-\providecommand{\DNthead}[1]{#1}
-\providecommand{\DNtip}[1]{#1}
-\providecommand{\DNtitle}[1]{#1}
-\providecommand{\DNtitlereference}[1]{#1}
-\providecommand{\DNtopic}[1]{#1}
-\providecommand{\DNtransition}[1]{#1}
-\providecommand{\DNversion}[1]{#1}
-\providecommand{\DNwarning}[1]{#1}
-
-% Auxiliary definitions:
-\providecommand{\Dsetattr}[2]{}
-\providecommand{\Dparent}{} % variable
-\providecommand{\Dattr}[5]{#5}
-\providecommand{\Dattrlen}{} % variable
-\providecommand{\Dtitleastext}{x} % variable
-\providecommand{\Dsinglebackref}{} % variable
-\providecommand{\Dmultiplebackrefs}{} % variable
-\providecommand{\Dparagraphindented}{false} % variable
-
-
-\Dvisitdocument%
- \Dattr{}{source}{/home/milde/.python/PyLit/trunk/rstdocs/features/myfunction.py.txt}{document}{%
- }%
- \renewcommand{\Dparent}{document}%
- \DNdecoration{%
- \renewcommand{\Dparent}{decoration}%
- \DNfooter{%
- \renewcommand{\Dparagraphindented}{false}%
- \renewcommand{\Dparent}{footer}%
- \DNparagraph{%
- Generated{ }on:{ }2007{-}06{-}05.{ }%
- }%
- }%
- }%
- \renewcommand{\Dparagraphindented}{true}%
- \renewcommand{\Dparent}{document}%
- \DNparagraph{%
- This{ }is{ }a{ }test{ }of{ }the{ }new{ }code{-}block{ }directive:%
- }%
- \Dauxiliaryspace%
- \renewcommand{\Dparent}{document}%
- \DNcomment{%
- \Dattr{}{xml:space}{preserve}{comment}{%
- % Translate this document to HTML with a pygments enhanced frontend, e.g.
- %
- % rst2html-highlight --stylesheet=pygments-default.css --link-stylesheet
- }}%
- \renewcommand{\Dparent}{document}%
- \def\DcurrentNliteralblockAraw_content{[u'def my_function():', u' "{}just a test"{}', u' print 8/2']}%
- \DNliteralblock{%
- \renewcommand{\Dattrlen}{2}%
- \Dattr{1}{classes}{code-block}{literalblock}{%
- \Dattr{2}{classes}{python}{literalblock}{%
- \Dattr{}{raw_content}{[u'def my_function():', u' "{}just a test"{}', u' print 8/2']}{literalblock}{%
- \Dattr{}{xml:space}{preserve}{literalblock}{%
- \renewcommand{\Dparent}{literalblock}%
- \DNinline{%
- \renewcommand{\Dattrlen}{1}%
- \Dattr{1}{classes}{k}{inline}{%
- def%
- }}%
- ~%
- \renewcommand{\Dparent}{literalblock}%
- \DNinline{%
- \renewcommand{\Dattrlen}{1}%
- \Dattr{1}{classes}{nf}{inline}{%
- my{\Dtextunderscore}function%
- }}%
- \renewcommand{\Dparent}{literalblock}%
- \DNinline{%
- \renewcommand{\Dattrlen}{1}%
- \Dattr{1}{classes}{p}{inline}{%
- ():%
- }}%
- \mbox{}\\~~~~%
- \renewcommand{\Dparent}{literalblock}%
- \DNinline{%
- \renewcommand{\Dattrlen}{1}%
- \Dattr{1}{classes}{s}{inline}{%
- {"}just~a~test{"}%
- }}%
- \mbox{}\\~~~~%
- \renewcommand{\Dparent}{literalblock}%
- \DNinline{%
- \renewcommand{\Dattrlen}{1}%
- \Dattr{1}{classes}{k}{inline}{%
- print%
- }}%
- ~%
- \renewcommand{\Dparent}{literalblock}%
- \DNinline{%
- \renewcommand{\Dattrlen}{1}%
- \Dattr{1}{classes}{mi}{inline}{%
- 8%
- }}%
- \renewcommand{\Dparent}{literalblock}%
- \DNinline{%
- \renewcommand{\Dattrlen}{1}%
- \Dattr{1}{classes}{o}{inline}{%
- /%
- }}%
- \renewcommand{\Dparent}{literalblock}%
- \DNinline{%
- \renewcommand{\Dattrlen}{1}%
- \Dattr{1}{classes}{mi}{inline}{%
- 2%
- }}%
- \mbox{}\\%
- }}}}}%
- \let\DcurrentNliteralblockAraw_content=\relax%
-\Ddepartdocument%
diff --git a/sandbox/code-block-directive/docs/myfunction.py.pdf b/sandbox/code-block-directive/docs/myfunction.py.pdf
new file mode 100644
index 000000000..5b847ab6f
--- /dev/null
+++ b/sandbox/code-block-directive/docs/myfunction.py.pdf
Binary files differ
diff --git a/sandbox/code-block-directive/docs/myfunction.py.tex b/sandbox/code-block-directive/docs/myfunction.py.tex
index 689a02703..6d5ddd5dd 100644
--- a/sandbox/code-block-directive/docs/myfunction.py.tex
+++ b/sandbox/code-block-directive/docs/myfunction.py.tex
@@ -56,7 +56,7 @@
\newcommand{\titlereference}[1]{\textsl{#1}}
% end of "some commands"
% user specified packages and stylesheets:
-\usepackage{cmlgc}
+\usepackage{../data/pygments-docutilsroles}
\ifthenelse{\isundefined{\hypersetup}}{
\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
}{}
@@ -80,7 +80,9 @@
This is a test of the new code-block directive:
% Translate this document to HTML with a pygments enhanced frontend, e.g.
%
-% rst2html-highlight --stylesheet=pygments-default.css --link-stylesheet
+% rst2html-highlight --stylesheet=../data/pygments-default.css --link-stylesheet
+%
+% rst2latex-highlight --stylesheet=../data/pygments-docutileroles.sty
\begin{quote}{\ttfamily \raggedright \noindent
\DUrole{k}{def}~\DUrole{nf}{my{\_}function}\DUrole{p}{():}~\\
~~~~\DUrole{s}{"just~a~test"}~\\
diff --git a/sandbox/code-block-directive/docs/myfunction.py.txt b/sandbox/code-block-directive/docs/myfunction.py.txt
index 926733dc0..783e5b0b6 100644
--- a/sandbox/code-block-directive/docs/myfunction.py.txt
+++ b/sandbox/code-block-directive/docs/myfunction.py.txt
@@ -2,7 +2,9 @@ This is a test of the new code-block directive:
.. Translate this document to HTML with a pygments enhanced frontend, e.g.
- rst2html-highlight --stylesheet=pygments-default.css --link-stylesheet
+ ../rst2html-highlight --stylesheet=../data/pygments-default.css
+
+ ../rst2latex-highlight --stylesheet=../data/pygments-docutileroles.sty
.. code-block:: python
diff --git a/sandbox/code-block-directive/docs/pygments_code_block_directive-bunt.py.htm b/sandbox/code-block-directive/docs/pygments_code_block_directive-bunt.py.htm
deleted file mode 100644
index 78bb809e9..000000000
--- a/sandbox/code-block-directive/docs/pygments_code_block_directive-bunt.py.htm
+++ /dev/null
@@ -1,314 +0,0 @@
-<?xml version="1.0" encoding="iso-8859-1" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
-<meta name="generator" content="Docutils 0.4.1: http://docutils.sourceforge.net/" />
-<title></title>
-<meta name="author" content="a Pygments author|contributor; Felix Wiemann; Guenter Milde" />
-<meta name="date" content="2007-06-08" />
-<meta name="copyright" content="This module has been placed in the public domain." />
-<style type="text/css">
-
-/* Stylesheet for pygments enhanced reStructured Text */
-/* ================================================== */
-
-/* :Author: Guenter Milde */
-/* :Copyright: 2007 G. Milde */
-/* This stylesheet is released under the GPL v. 2 or later */
-
-/* This stylesheet provides syntax highlight for documents generated with a */
-/* pygments_ enhanced reStructured Text -> html converter. */
-
-/* Import the default docutils style sheet */
-/* --------------------------------------- */
-/* :: */
-
-@import url("/stylesheets/html4css1.css");
-
-/* Indent the code block */
-/* --------------------- */
-
-/* Content copied from the `html4css1.css` rule for literal blocks. */
-/* Selector adapted to the output of Pygments_. :: */
-
-div.highlight {
- margin-left: 2em ;
- margin-right: 2em ;
- background-color: #eeeeee
- }
-
-
-/* Colour code blocks */
-/* ------------------ */
-
-/* Pygments_ has an option to generate stylesheets for html and latex. */
-/* The following code is generated with the command */
-/* `pygmentize -S default -f html > pygments-default.css`:: */
-
-.c { color: #008800; font-style: italic } /* Comment */
-.err { border: 1px solid #FF0000 } /* Error */
-.k { color: #AA22FF; font-weight: bold } /* Keyword */
-.o { color: #666666 } /* Operator */
-.cm { color: #008800; font-style: italic } /* Comment.Multiline */
-.cp { color: #008800 } /* Comment.Preproc */
-.c1 { color: #008800; font-style: italic } /* Comment.Single */
-.gd { color: #A00000 } /* Generic.Deleted */
-.ge { font-style: italic } /* Generic.Emph */
-.gr { color: #FF0000 } /* Generic.Error */
-.gh { color: #000080; font-weight: bold } /* Generic.Heading */
-.gi { color: #00A000 } /* Generic.Inserted */
-.go { color: #808080 } /* Generic.Output */
-.gp { color: #000080; font-weight: bold } /* Generic.Prompt */
-.gs { font-weight: bold } /* Generic.Strong */
-.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
-.gt { color: #0040D0 } /* Generic.Traceback */
-.kc { color: #AA22FF; font-weight: bold } /* Keyword.Constant */
-.kd { color: #AA22FF; font-weight: bold } /* Keyword.Declaration */
-.kp { color: #AA22FF } /* Keyword.Pseudo */
-.kr { color: #AA22FF; font-weight: bold } /* Keyword.Reserved */
-.kt { color: #AA22FF; font-weight: bold } /* Keyword.Type */
-.m { color: #666666 } /* Literal.Number */
-.s { color: #BB4444 } /* Literal.String */
-.na { color: #BB4444 } /* Name.Attribute */
-.nb { color: #AA22FF } /* Name.Builtin */
-.nc { color: #0000FF } /* Name.Class */
-.no { color: #880000 } /* Name.Constant */
-.nd { color: #AA22FF } /* Name.Decorator */
-.ni { color: #999999; font-weight: bold } /* Name.Entity */
-.ne { color: #D2413A; font-weight: bold } /* Name.Exception */
-.nf { color: #00A000 } /* Name.Function */
-.nl { color: #A0A000 } /* Name.Label */
-.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
-.nt { color: #008000; font-weight: bold } /* Name.Tag */
-.nv { color: #B8860B } /* Name.Variable */
-.ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
-.mf { color: #666666 } /* Literal.Number.Float */
-.mh { color: #666666 } /* Literal.Number.Hex */
-.mi { color: #666666 } /* Literal.Number.Integer */
-.mo { color: #666666 } /* Literal.Number.Oct */
-.sb { color: #BB4444 } /* Literal.String.Backtick */
-.sc { color: #BB4444 } /* Literal.String.Char */
-.sd { color: #BB4444; font-style: italic } /* Literal.String.Doc */
-.s2 { color: #BB4444 } /* Literal.String.Double */
-.se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
-.sh { color: #BB4444 } /* Literal.String.Heredoc */
-.si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
-.sx { color: #008000 } /* Literal.String.Other */
-.sr { color: #BB6688 } /* Literal.String.Regex */
-.s1 { color: #BB4444 } /* Literal.String.Single */
-.ss { color: #B8860B } /* Literal.String.Symbol */
-.bp { color: #AA22FF } /* Name.Builtin.Pseudo */
-.vc { color: #B8860B } /* Name.Variable.Class */
-.vg { color: #B8860B } /* Name.Variable.Global */
-.vi { color: #B8860B } /* Name.Variable.Instance */
-.il { color: #666666 } /* Literal.Number.Integer.Long */
-
-/* .. _pygments: http://pygments.org/ */
-
-</style>
-</head>
-<body>
-<div class="document">
-<table class="docinfo" frame="void" rules="none">
-<col class="docinfo-name" />
-<col class="docinfo-content" />
-<tbody valign="top">
-<tr><th class="docinfo-name">Author:</th>
-<td>a Pygments author|contributor; Felix Wiemann; Guenter Milde</td></tr>
-<tr><th class="docinfo-name">Date:</th>
-<td>2007-06-08</td></tr>
-<tr><th class="docinfo-name">Copyright:</th>
-<td>This module has been placed in the public domain.</td></tr>
-</tbody>
-</table>
-<!-- #!/usr/bin/python -->
-<p>This is a merge of <a class="reference" href="http://pygments.org/docs/rstdirective/">Using Pygments in ReST documents</a> from the <a class="reference" href="http://pygments.org/">pygments</a>
-documentation, and a <a class="reference" href="http://article.gmane.org/gmane.text.docutils.user/3689">proof of concept</a> by Felix Wiemann.</p>
-<table border="1" class="docutils">
-<colgroup>
-<col width="14%" />
-<col width="86%" />
-</colgroup>
-<tbody valign="top">
-<tr><td>2007-06-01</td>
-<td>Removed redundancy from class values.</td>
-</tr>
-<tr><td>2007-06-04</td>
-<td>Merge of successive tokens of same type
-(code taken from pygments.formatters.others).</td>
-</tr>
-<tr><td>2007-06-05</td>
-<td>Separate docutils formatter script
-Use pygments' CSS class names (like the html formatter)
-allowing the use of pygments-produced style sheets.</td>
-</tr>
-<tr><td>2007-06-07</td>
-<td>Merge in the formatting of the parsed tokens
-(misnamed as docutils_formatter) as class DocutilsInterface</td>
-</tr>
-<tr><td>2007-06-08</td>
-<td>Failsave implementation (fallback to a standard literal block
-if pygments not found)</td>
-</tr>
-</tbody>
-</table>
-<!-- to get the syntax highlight in the html output of this file, convert with::
-
-./rst2html-highlight - -stylesheet=data/pygments-default.css -->
-<pre class="code-block python literal-block">
-<span class="sd">&quot;&quot;&quot;Define and register a code-block directive using pygments
-&quot;&quot;&quot;</span>
-
-</pre>
-<div class="section">
-<h1><a id="requirements" name="requirements">Requirements</a></h1>
-<pre class="code-block python literal-block">
-<span class="k">from</span> <span class="nn">docutils</span> <span class="k">import</span> <span class="n">nodes</span>
-<span class="k">from</span> <span class="nn">docutils.parsers.rst</span> <span class="k">import</span> <span class="n">directives</span>
-<span class="k">try</span><span class="p">:</span>
- <span class="k">import</span> <span class="nn">pygments</span>
- <span class="k">from</span> <span class="nn">pygments.lexers</span> <span class="k">import</span> <span class="n">get_lexer_by_name</span>
- <span class="k">from</span> <span class="nn">pygments.formatters.html</span> <span class="k">import</span> <span class="n">_get_ttype_class</span>
-<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
- <span class="k">pass</span>
-
-</pre>
-</div>
-<div class="section">
-<h1><a id="customisation" name="customisation">Customisation</a></h1>
-<p>Do not insert inline nodes for the following tokens.
-(You could add e.g. Token.Punctuation like <tt class="docutils literal"><span class="pre">['',</span> <span class="pre">'p']</span></tt>.)</p>
-<pre class="code-block python literal-block">
-<span class="n">unstyled_tokens</span> <span class="o">=</span> <span class="p">[</span><span class="s">''</span><span class="p">]</span>
-
-</pre>
-</div>
-<div class="section">
-<h1><a id="docutilsinterface" name="docutilsinterface">DocutilsInterface</a></h1>
-<p>This interface class combines code from
-pygments.formatters.html and pygments.formatters.others.</p>
-<p>It does not require anything of docutils and could also become a part of
-pygments</p>
-<pre class="code-block python literal-block">
-<span class="k">class</span> <span class="nc">DocutilsInterface</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
- <span class="sd">&quot;&quot;&quot;Parse `code` string and yield &quot;classified&quot; tokens.
-
- Arguments
-
- code -- string of source code to parse
- language -- formal language the code is written in.
-
- Merge subsequent tokens of the same token-type.
-
- Yields the tokens as ``(ttype_class, value)`` tuples,
- where ttype_class is taken from pygments.token.STANDARD_TYPES and
- corresponds to the class argument used in pygments html output.
-
- &quot;&quot;&quot;</span>
-
- <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">code</span><span class="p">,</span> <span class="n">language</span><span class="p">):</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">code</span> <span class="o">=</span> <span class="n">code</span>
- <span class="bp">self</span><span class="o">.</span><span class="n">language</span> <span class="o">=</span> <span class="n">language</span>
-
- <span class="k">def</span> <span class="nf">lex</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
- <span class="c"># Get lexer for language (use text as fallback)</span>
- <span class="k">try</span><span class="p">:</span>
- <span class="n">lexer</span> <span class="o">=</span> <span class="n">get_lexer_by_name</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">language</span><span class="p">)</span>
- <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
- <span class="c"># info: &quot;no pygments lexer for %s, using 'text'&quot;%self.language</span>
- <span class="n">lexer</span> <span class="o">=</span> <span class="n">get_lexer_by_name</span><span class="p">(</span><span class="s">'text'</span><span class="p">)</span>
- <span class="k">return</span> <span class="n">pygments</span><span class="o">.</span><span class="n">lex</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">code</span><span class="p">,</span> <span class="n">lexer</span><span class="p">)</span>
-
-
- <span class="k">def</span> <span class="nf">join</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">tokens</span><span class="p">):</span>
- <span class="sd">&quot;&quot;&quot;join subsequent tokens of same token-type
- &quot;&quot;&quot;</span>
- <span class="n">tokens</span> <span class="o">=</span> <span class="nb">iter</span><span class="p">(</span><span class="n">tokens</span><span class="p">)</span>
- <span class="p">(</span><span class="n">lasttype</span><span class="p">,</span> <span class="n">lastval</span><span class="p">)</span> <span class="o">=</span> <span class="n">tokens</span><span class="o">.</span><span class="n">next</span><span class="p">()</span>
- <span class="k">for</span> <span class="n">ttype</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">tokens</span><span class="p">:</span>
- <span class="k">if</span> <span class="n">ttype</span> <span class="ow">is</span> <span class="n">lasttype</span><span class="p">:</span>
- <span class="n">lastval</span> <span class="o">+=</span> <span class="n">value</span>
- <span class="k">else</span><span class="p">:</span>
- <span class="k">yield</span><span class="p">(</span><span class="n">lasttype</span><span class="p">,</span> <span class="n">lastval</span><span class="p">)</span>
- <span class="p">(</span><span class="n">lasttype</span><span class="p">,</span> <span class="n">lastval</span><span class="p">)</span> <span class="o">=</span> <span class="p">(</span><span class="n">ttype</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
- <span class="k">yield</span><span class="p">(</span><span class="n">lasttype</span><span class="p">,</span> <span class="n">lastval</span><span class="p">)</span>
-
- <span class="k">def</span> <span class="nf">__iter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
- <span class="sd">&quot;&quot;&quot;parse code string and yield &quot;clasified&quot; tokens
- &quot;&quot;&quot;</span>
- <span class="k">try</span><span class="p">:</span>
- <span class="n">tokens</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">lex</span><span class="p">()</span>
- <span class="k">except</span> <span class="ne">IOError</span><span class="p">:</span>
- <span class="k">print</span> <span class="s">&quot;INFO: Pygments lexer not found, using fallback&quot;</span>
- <span class="c"># TODO: write message to INFO</span>
- <span class="k">yield</span> <span class="p">(</span><span class="s">''</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">code</span><span class="p">)</span>
- <span class="k">return</span>
-
- <span class="k">for</span> <span class="n">ttype</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">tokens</span><span class="p">):</span>
- <span class="k">yield</span> <span class="p">(</span><span class="n">_get_ttype_class</span><span class="p">(</span><span class="n">ttype</span><span class="p">),</span> <span class="n">value</span><span class="p">)</span>
-
-</pre>
-</div>
-<div class="section">
-<h1><a id="code-block-directive" name="code-block-directive">code_block_directive</a></h1>
-<pre class="code-block python literal-block">
-<span class="k">def</span> <span class="nf">code_block_directive</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">arguments</span><span class="p">,</span> <span class="n">options</span><span class="p">,</span> <span class="n">content</span><span class="p">,</span> <span class="n">lineno</span><span class="p">,</span>
- <span class="n">content_offset</span><span class="p">,</span> <span class="n">block_text</span><span class="p">,</span> <span class="n">state</span><span class="p">,</span> <span class="n">state_machine</span><span class="p">):</span>
- <span class="sd">&quot;&quot;&quot;parse and classify content of a code_block
- &quot;&quot;&quot;</span>
- <span class="n">language</span> <span class="o">=</span> <span class="n">arguments</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
- <span class="c"># create a literal block element and set class argument</span>
- <span class="n">code_block</span> <span class="o">=</span> <span class="n">nodes</span><span class="o">.</span><span class="n">literal_block</span><span class="p">(</span><span class="n">classes</span><span class="o">=</span><span class="p">[</span><span class="s">&quot;code-block&quot;</span><span class="p">,</span> <span class="n">language</span><span class="p">])</span>
-
- <span class="c"># parse content with pygments and add to code_block element</span>
- <span class="k">for</span> <span class="n">cls</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">DocutilsInterface</span><span class="p">(</span><span class="n">u</span><span class="s">'</span><span class="se">\n</span><span class="s">'</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">content</span><span class="p">),</span> <span class="n">language</span><span class="p">):</span>
- <span class="k">if</span> <span class="n">cls</span> <span class="ow">in</span> <span class="n">unstyled_tokens</span><span class="p">:</span>
- <span class="c"># insert as Text to decrease the verbosity of the output.</span>
- <span class="n">code_block</span> <span class="o">+=</span> <span class="n">nodes</span><span class="o">.</span><span class="n">Text</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
- <span class="k">else</span><span class="p">:</span>
- <span class="n">code_block</span> <span class="o">+=</span> <span class="n">nodes</span><span class="o">.</span><span class="n">inline</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">classes</span><span class="o">=</span><span class="p">[</span><span class="n">cls</span><span class="p">])</span>
-
- <span class="k">return</span> <span class="p">[</span><span class="n">code_block</span><span class="p">]</span>
-
-</pre>
-</div>
-<div class="section">
-<h1><a id="register-directive" name="register-directive">Register Directive</a></h1>
-<pre class="code-block python literal-block">
-<span class="n">code_block_directive</span><span class="o">.</span><span class="n">arguments</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
-<span class="n">code_block_directive</span><span class="o">.</span><span class="n">content</span> <span class="o">=</span> <span class="mi">1</span>
-<span class="n">directives</span><span class="o">.</span><span class="n">register_directive</span><span class="p">(</span><span class="s">'code-block'</span><span class="p">,</span> <span class="n">code_block_directive</span><span class="p">)</span>
-
-</pre>
-</div>
-<div class="section">
-<h1><a id="test-output" name="test-output">Test output</a></h1>
-<p>If called from the command line, call the docutils publisher to render the
-input</p>
-<pre class="code-block python literal-block">
-<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">'__main__'</span><span class="p">:</span>
- <span class="k">from</span> <span class="nn">docutils.core</span> <span class="k">import</span> <span class="n">publish_cmdline</span><span class="p">,</span> <span class="n">default_description</span>
- <span class="n">description</span> <span class="o">=</span> <span class="s">&quot;code-block directive test output&quot;</span> <span class="o">+</span> <span class="n">default_description</span>
- <span class="k">try</span><span class="p">:</span>
- <span class="k">import</span> <span class="nn">locale</span>
- <span class="n">locale</span><span class="o">.</span><span class="n">setlocale</span><span class="p">(</span><span class="n">locale</span><span class="o">.</span><span class="n">LC_ALL</span><span class="p">,</span> <span class="s">''</span><span class="p">)</span>
- <span class="k">except</span><span class="p">:</span>
- <span class="k">pass</span>
- <span class="c"># Uncomment the desired output format:</span>
- <span class="n">publish_cmdline</span><span class="p">(</span><span class="n">writer_name</span><span class="o">=</span><span class="s">'pseudoxml'</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="n">description</span><span class="p">)</span>
- <span class="c"># publish_cmdline(writer_name='xml', description=description)</span>
- <span class="c"># publish_cmdline(writer_name='html', description=description)</span>
- <span class="c"># publish_cmdline(writer_name='latex', description=description)</span>
- <span class="c"># publish_cmdline(writer_name='newlatex2e', description=description)</span>
-
-</pre>
-</div>
-</div>
-<div class="footer">
-<hr class="footer" />
-Generated on: 2007-06-13.
-
-</div>
-</body>
-</html>
diff --git a/sandbox/code-block-directive/docs/pygments_code_block_directive-bunt.py.txt b/sandbox/code-block-directive/docs/pygments_code_block_directive-bunt.py.txt
deleted file mode 100644
index d7112e255..000000000
--- a/sandbox/code-block-directive/docs/pygments_code_block_directive-bunt.py.txt
+++ /dev/null
@@ -1,191 +0,0 @@
-.. #!/usr/bin/python
-
-:Author: a Pygments author|contributor; Felix Wiemann; Guenter Milde
-:Date: $Date$
-:Copyright: This module has been placed in the public domain.
-
-This is a merge of `Using Pygments in ReST documents`_ from the pygments_
-documentation, and a `proof of concept`_ by Felix Wiemann.
-
-========== ===========================================================
-2007-06-01 Removed redundancy from class values.
-2007-06-04 Merge of successive tokens of same type
- (code taken from pygments.formatters.others).
-2007-06-05 Separate docutils formatter script
- Use pygments' CSS class names (like the html formatter)
- allowing the use of pygments-produced style sheets.
-2007-06-07 Merge in the formatting of the parsed tokens
- (misnamed as docutils_formatter) as class DocutilsInterface
-2007-06-08 Failsave implementation (fallback to a standard literal block
- if pygments not found)
-========== ===========================================================
-
-.. to get the syntax highlight in the html output of this file, convert with::
-
- ./rst2html-highlight --stylesheet=data/pygments-default.css
-
-.. code-block:: python
-
- """Define and register a code-block directive using pygments
- """
-
-Requirements
-------------
-
-.. code-block:: python
-
- from docutils import nodes
- from docutils.parsers.rst import directives
- try:
- import pygments
- from pygments.lexers import get_lexer_by_name
- from pygments.formatters.html import _get_ttype_class
- except ImportError:
- pass
-
-
-
-Customisation
--------------
-
-Do not insert inline nodes for the following tokens.
-(You could add e.g. Token.Punctuation like ``['', 'p']``.)
-
-.. code-block:: python
-
- unstyled_tokens = ['']
-
-DocutilsInterface
------------------
-
-This interface class combines code from
-pygments.formatters.html and pygments.formatters.others.
-
-It does not require anything of docutils and could also become a part of
-pygments
-
-.. code-block:: python
-
- class DocutilsInterface(object):
- """Parse `code` string and yield "classified" tokens.
-
- Arguments
-
- code -- string of source code to parse
- language -- formal language the code is written in.
-
- Merge subsequent tokens of the same token-type.
-
- Yields the tokens as ``(ttype_class, value)`` tuples,
- where ttype_class is taken from pygments.token.STANDARD_TYPES and
- corresponds to the class argument used in pygments html output.
-
- """
-
- def __init__(self, code, language):
- self.code = code
- self.language = language
-
- def lex(self):
- # Get lexer for language (use text as fallback)
- try:
- lexer = get_lexer_by_name(self.language)
- except ValueError:
- # info: "no pygments lexer for %s, using 'text'"%self.language
- lexer = get_lexer_by_name('text')
- return pygments.lex(self.code, lexer)
-
-
- def join(self, tokens):
- """join subsequent tokens of same token-type
- """
- tokens = iter(tokens)
- (lasttype, lastval) = tokens.next()
- for ttype, value in tokens:
- if ttype is lasttype:
- lastval += value
- else:
- yield(lasttype, lastval)
- (lasttype, lastval) = (ttype, value)
- yield(lasttype, lastval)
-
- def __iter__(self):
- """parse code string and yield "clasified" tokens
- """
- try:
- tokens = self.lex()
- except IOError:
- print "INFO: Pygments lexer not found, using fallback"
- # TODO: write message to INFO
- yield ('', self.code)
- return
-
- for ttype, value in self.join(tokens):
- yield (_get_ttype_class(ttype), value)
-
-
-
-code_block_directive
---------------------
-
-.. code-block:: python
-
- def code_block_directive(name, arguments, options, content, lineno,
- content_offset, block_text, state, state_machine):
- """parse and classify content of a code_block
- """
- language = arguments[0]
- # create a literal block element and set class argument
- code_block = nodes.literal_block(classes=["code-block", language])
-
- # parse content with pygments and add to code_block element
- for cls, value in DocutilsInterface(u'\n'.join(content), language):
- if cls in unstyled_tokens:
- # insert as Text to decrease the verbosity of the output.
- code_block += nodes.Text(value, value)
- else:
- code_block += nodes.inline(value, value, classes=[cls])
-
- return [code_block]
-
-
-Register Directive
-------------------
-
-.. code-block:: python
-
- code_block_directive.arguments = (1, 0, 1)
- code_block_directive.content = 1
- directives.register_directive('code-block', code_block_directive)
-
-.. _doctutils: http://docutils.sf.net/
-.. _pygments: http://pygments.org/
-.. _Using Pygments in ReST documents: http://pygments.org/docs/rstdirective/
-.. _proof of concept:
- http://article.gmane.org/gmane.text.docutils.user/3689
-
-Test output
------------
-
-If called from the command line, call the docutils publisher to render the
-input
-
-.. code-block:: python
-
- if __name__ == '__main__':
- from docutils.core import publish_cmdline, default_description
- description = "code-block directive test output" + default_description
- try:
- import locale
- locale.setlocale(locale.LC_ALL, '')
- except:
- pass
- # Uncomment the desired output format:
- publish_cmdline(writer_name='pseudoxml', description=description)
- # publish_cmdline(writer_name='xml', description=description)
- # publish_cmdline(writer_name='html', description=description)
- # publish_cmdline(writer_name='latex', description=description)
- # publish_cmdline(writer_name='newlatex2e', description=description)
-
-
-
diff --git a/sandbox/code-block-directive/docs/pygments_code_block_directive.py.htm b/sandbox/code-block-directive/docs/pygments_code_block_directive.py.htm
deleted file mode 100644
index ba7364dbe..000000000
--- a/sandbox/code-block-directive/docs/pygments_code_block_directive.py.htm
+++ /dev/null
@@ -1,263 +0,0 @@
-<?xml version="1.0" encoding="iso-8859-1" ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
-<meta name="generator" content="Docutils 0.4.1: http://docutils.sourceforge.net/" />
-<title></title>
-<meta name="author" content="a Pygments author|contributor; Felix Wiemann; Guenter Milde" />
-<meta name="date" content="2007-06-08" />
-<meta name="copyright" content="This module has been placed in the public domain." />
-<link rel="stylesheet" href="../../../../lib/python2.4/site-packages/docutils/writers/html4css1/html4css1.css" type="text/css" />
-</head>
-<body>
-<div class="document">
-<table class="docinfo" frame="void" rules="none">
-<col class="docinfo-name" />
-<col class="docinfo-content" />
-<tbody valign="top">
-<tr><th class="docinfo-name">Author:</th>
-<td>a Pygments author|contributor; Felix Wiemann; Guenter Milde</td></tr>
-<tr><th class="docinfo-name">Date:</th>
-<td>2007-06-08</td></tr>
-<tr><th class="docinfo-name">Copyright:</th>
-<td>This module has been placed in the public domain.</td></tr>
-</tbody>
-</table>
-<!-- #!/usr/bin/python -->
-<p>This is a merge of <a class="reference" href="http://pygments.org/docs/rstdirective/">Using Pygments in ReST documents</a> from the <a class="reference" href="http://pygments.org/">pygments</a>
-documentation, and a <a class="reference" href="http://article.gmane.org/gmane.text.docutils.user/3689">proof of concept</a> by Felix Wiemann.</p>
-<table border="1" class="docutils">
-<colgroup>
-<col width="14%" />
-<col width="86%" />
-</colgroup>
-<tbody valign="top">
-<tr><td>2007-06-01</td>
-<td>Removed redundancy from class values.</td>
-</tr>
-<tr><td>2007-06-04</td>
-<td>Merge of successive tokens of same type
-(code taken from pygments.formatters.others).</td>
-</tr>
-<tr><td>2007-06-05</td>
-<td>Separate docutils formatter script
-Use pygments' CSS class names (like the html formatter)
-allowing the use of pygments-produced style sheets.</td>
-</tr>
-<tr><td>2007-06-07</td>
-<td>Merge in the formatting of the parsed tokens
-(misnamed as docutils_formatter) as class DocutilsInterface</td>
-</tr>
-<tr><td>2007-06-08</td>
-<td>Failsave implementation (fallback to a standard literal block
-if pygments not found)</td>
-</tr>
-</tbody>
-</table>
-<div class="system-message">
-<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">/usr/src/docutils-svn/sandbox/code-block-directive/pygments_code_block_directive.py.txt</tt>, line 23)</p>
-<p>Unknown directive type &quot;code-block&quot;.</p>
-<pre class="literal-block">
-.. code-block::
-
- &quot;&quot;&quot;Define and register a code-block directive using pygments
- &quot;&quot;&quot;
-
-</pre>
-</div>
-<div class="section">
-<h1><a id="requirements" name="requirements">Requirements</a></h1>
-<div class="system-message">
-<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">/usr/src/docutils-svn/sandbox/code-block-directive/pygments_code_block_directive.py.txt</tt>, line 31)</p>
-<p>Unknown directive type &quot;code-block&quot;.</p>
-<pre class="literal-block">
-.. code-block::
-
- from docutils import nodes
- from docutils.parsers.rst import directives
- try:
- import pygments
- from pygments.lexers import get_lexer_by_name
- from pygments.formatters.html import _get_ttype_class
- except ImportError:
- pass
-
-
-
-</pre>
-</div>
-</div>
-<div class="section">
-<h1><a id="customisation" name="customisation">Customisation</a></h1>
-<p>Do not insert inline nodes for the following tokens.
-(You could add e.g. Token.Punctuation like <tt class="docutils literal"><span class="pre">['',</span> <span class="pre">'p']</span></tt>.)</p>
-<div class="system-message">
-<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">/usr/src/docutils-svn/sandbox/code-block-directive/pygments_code_block_directive.py.txt</tt>, line 50)</p>
-<p>Unknown directive type &quot;code-block&quot;.</p>
-<pre class="literal-block">
-.. code-block::
-
- unstyled_tokens = ['']
-
-</pre>
-</div>
-</div>
-<div class="section">
-<h1><a id="docutilsinterface" name="docutilsinterface">DocutilsInterface</a></h1>
-<p>This interface class combines code from
-pygments.formatters.html and pygments.formatters.others.</p>
-<p>It does not require anything of docutils and could also become a part of
-pygments</p>
-<div class="system-message">
-<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">/usr/src/docutils-svn/sandbox/code-block-directive/pygments_code_block_directive.py.txt</tt>, line 63)</p>
-<p>Unknown directive type &quot;code-block&quot;.</p>
-<pre class="literal-block">
-.. code-block::
-
- class DocutilsInterface(object):
- &quot;&quot;&quot;Parse `code` string and yield &quot;classified&quot; tokens.
-
- Arguments
-
- code -- string of source code to parse
- language -- formal language the code is written in.
-
- Merge subsequent tokens of the same token-type.
-
- Yields the tokens as ``(ttype_class, value)`` tuples,
- where ttype_class is taken from pygments.token.STANDARD_TYPES and
- corresponds to the class argument used in pygments html output.
-
- &quot;&quot;&quot;
-
- def __init__(self, code, language):
- self.code = code
- self.language = language
-
- def lex(self):
- # Get lexer for language (use text as fallback)
- try:
- lexer = get_lexer_by_name(self.language)
- except ValueError:
- # info: &quot;no pygments lexer for %s, using 'text'&quot;%self.language
- lexer = get_lexer_by_name('text')
- return pygments.lex(self.code, lexer)
-
-
- def join(self, tokens):
- &quot;&quot;&quot;join subsequent tokens of same token-type
- &quot;&quot;&quot;
- tokens = iter(tokens)
- (lasttype, lastval) = tokens.next()
- for ttype, value in tokens:
- if ttype is lasttype:
- lastval += value
- else:
- yield(lasttype, lastval)
- (lasttype, lastval) = (ttype, value)
- yield(lasttype, lastval)
-
- def __iter__(self):
- &quot;&quot;&quot;parse code string and yield &quot;clasified&quot; tokens
- &quot;&quot;&quot;
- try:
- tokens = self.lex()
- except IOError:
- print &quot;INFO: Pygments lexer not found, using fallback&quot;
- # TODO: write message to INFO
- yield ('', self.code)
- return
-
- for ttype, value in self.join(tokens):
- yield (_get_ttype_class(ttype), value)
-
-
-
-</pre>
-</div>
-</div>
-<div class="section">
-<h1><a id="code-block-directive" name="code-block-directive">code_block_directive</a></h1>
-<div class="system-message">
-<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">/usr/src/docutils-svn/sandbox/code-block-directive/pygments_code_block_directive.py.txt</tt>, line 127)</p>
-<p>Unknown directive type &quot;code-block&quot;.</p>
-<pre class="literal-block">
-.. code-block::
-
- def code_block_directive(name, arguments, options, content, lineno,
- content_offset, block_text, state, state_machine):
- &quot;&quot;&quot;parse and classify content of a code_block
- &quot;&quot;&quot;
- language = arguments[0]
- # create a literal block element and set class argument
- code_block = nodes.literal_block(classes=[&quot;code-block&quot;, language])
-
- # parse content with pygments and add to code_block element
- for cls, value in DocutilsInterface(u'\n'.join(content), language):
- if cls in unstyled_tokens:
- # insert as Text to decrease the verbosity of the output.
- code_block += nodes.Text(value, value)
- else:
- code_block += nodes.inline(value, value, classes=[cls])
-
- return [code_block]
-
-
-</pre>
-</div>
-</div>
-<div class="section">
-<h1><a id="register-directive" name="register-directive">Register Directive</a></h1>
-<div class="system-message">
-<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">/usr/src/docutils-svn/sandbox/code-block-directive/pygments_code_block_directive.py.txt</tt>, line 151)</p>
-<p>Unknown directive type &quot;code-block&quot;.</p>
-<pre class="literal-block">
-.. code-block::
-
- code_block_directive.arguments = (1, 0, 1)
- code_block_directive.content = 1
- directives.register_directive('code-block', code_block_directive)
-
-</pre>
-</div>
-</div>
-<div class="section">
-<h1><a id="test-output" name="test-output">Test output</a></h1>
-<p>If called from the command line, call the docutils publisher to render the
-input</p>
-<div class="system-message">
-<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">/usr/src/docutils-svn/sandbox/code-block-directive/pygments_code_block_directive.py.txt</tt>, line 169)</p>
-<p>Unknown directive type &quot;code-block&quot;.</p>
-<pre class="literal-block">
-.. code-block::
-
- if __name__ == '__main__':
- from docutils.core import publish_cmdline, default_description
- description = &quot;code-block directive test output&quot; + default_description
- try:
- import locale
- locale.setlocale(locale.LC_ALL, '')
- except:
- pass
- # Uncomment the desired output format:
- publish_cmdline(writer_name='pseudoxml', description=description)
- # publish_cmdline(writer_name='xml', description=description)
- # publish_cmdline(writer_name='html', description=description)
- # publish_cmdline(writer_name='latex', description=description)
- # publish_cmdline(writer_name='newlatex2e', description=description)
-
-
-
-</pre>
-</div>
-</div>
-</div>
-<div class="footer">
-<hr class="footer" />
-<a class="reference" href="pygments_code_block_directive.py.txt">View document source</a>.
-Generated on: 2007-06-13.
-
-</div>
-</body>
-</html>
diff --git a/sandbox/code-block-directive/docs/syntax-highlight.txt b/sandbox/code-block-directive/docs/syntax-highlight.txt
index a5d6ffc34..a71cc5b77 100644
--- a/sandbox/code-block-directive/docs/syntax-highlight.txt
+++ b/sandbox/code-block-directive/docs/syntax-highlight.txt
@@ -3,11 +3,15 @@
Syntax Highlight
================
-:Author: Günter Milde
-:Contact: milde@users.berlios.de
-:Date: $Date$
-:Abstract: Proposal to add syntax highlight of code blocks to the
- capabilities of Docutils_.
+:Author: Günter Milde
+:Contact: milde@users.berlios.de
+:Date: $Date$
+:Copyright: © 2007, 2009 G. Milde,
+ Released without warranties or conditions of any kind
+ under the terms of the Apache License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0
+:Abstract: Proposal to add syntax highlight of code blocks to the
+ capabilities of Docutils_.
.. sectnum::
.. contents::
@@ -47,10 +51,11 @@ __ http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252170
a LaTeX package providing highly customisable and advanced syntax
highlight, though only for LaTeX (and LaTeX derived PS|PDF).
- Since Docutils 0.5, the "latex2e" writer supports
- syntax highlight of literal blocks by `listings` with the
- ``--literal-block-env=lstlistings`` option. You need to provide a
- stylesheet (see also `PyLit Examples`_).
+ Since Docutils 0.5, the "latex2e" writer supports syntax highlight of
+ literal blocks by `listings` with the ``--literal-block-env=lstlistings``
+ option. You need to provide a custom style sheet. The stylesheets_
+ repository provides two LaTeX style sheets for highlighting literal-blocks
+ with "listings".
Trac_
has `reStructuredText support`__ and offers syntax highlighting with
@@ -67,12 +72,12 @@ __ http://www.voidspace.org.uk/python/rest2web/macros.html#colorize
Sphinx_
features automatic highlighting using the Pygments_ highlighter.
- It introduces the custom directives
-
+ It introduces the custom directives
+
:code-block: similar to the proposal below,
:sourcecode: an alias to "code-block", and
:highlight: configre highlight of "literal blocks".
-
+
(see http://sphinx.pocoo.org/markup/code.html).
Pygments_
@@ -93,8 +98,13 @@ Pygments_
Odtwriter_, experimental writer for Docutils OpenOffice export supports syntax
colours using Pygments_. (See the (outdated) section `Odtwriter syntax`_.)
-Pygments_ seems to be the most promising docutils highlighter. For printed
-output, the listings_ package has its advantages too.
+Summary
+"""""""
+
+Pygments_ seems to be the most promising Docutils highlighter.
+
+For printed output and PDFs via LaTeX, the listings_ package is a viable
+alternative.
Pygments enhanced docutils front-ends
@@ -199,9 +209,6 @@ directive.
* The ``code_block_directive`` function inserts the tokens in a "rich"
<literal_block> element with "classified" <inline> nodes.
-The XML rendering of the small example file `<myfunction.py.txt>`_ looks like
-`<myfunction.py.xml>`_.
-
Writing
'''''''
@@ -209,53 +216,51 @@ The writers can use the class information in the <inline> elements to render
the tokens. They should ignore the class information if they are unable to
use it or to pass it on.
+Running the test script `<../tools/test_pygments_code_block_directive.py>`_
+produces example output for a set of writers.
+
HTML
The "html" writer works out of the box.
* The rst2html-highlight_ front end registers the "code-block" directive and
converts an input file to html.
+
* Styling is done with the adapted CSS style sheet `pygments-default.css`_
based on docutils' default stylesheet and the output of
``pygmentize -S default -f html``.
-
+
The conversion of `myfunction.py.txt`_ looks like
`<myfunction.py.htm>`_.
The "s5" and "pep" writers are not tested yet.
XML
- "xml" and "pseudoxml" work out of the box.
-
+ "xml" and "pseudoxml" work out of the box.
+
The conversion of `myfunction.py.txt`_ looks like
- `<myfunction.py.xml>`_ and `<myfunction.py.pseudoxml>`_
+ `<myfunction.py.xml>`_ respective `<myfunction.py.pseudoxml>`_
LaTeX
- "latex2e" (SVN version) works out of the box.
-
- * A style file is required to actually highlight the code in the
- output. (As with HTML, the pygments-produced style file will not work
- with docutils' output.)
-
+ "latex2e" (SVN version) works out of the box.
+
+ * A style file, e.g. `pygments-docutilsroles.sty`_, is required to actually
+ highlight the code in the output. (As with HTML, the pygments-produced
+ style file will not work with docutils' output.)
+
* Alternatively, the latex writer could reconstruct the original
- content and pass it to a ``lstlistings`` environment.
-
+ content and pass it to a ``lstlistings`` environment.
+
TODO: This should be the default behaviour with
``--literal-block-env=lstlistings``.
-
- The conversion of `myfunction.py.txt`_ looks like
- `<myfunction.py.tex>`_ and converted with pdflatex (without style
- sheet) like `<myfunction.py.pdf>`_
- "newlatex2e" produces a valid LaTeX document
- (`<myfunction.py.newlatex2e.tex>`_). There is some garbage in the
- pdflatex output (`<myfunction.py.newlatex2e.pdf>`_) but this might be
- unrelated to the code-block directive.
+ The LaTeX output of `myfunction.py.txt`_ looks like `<myfunction.py.tex>`_
+ and corresponding PDF like `<myfunction.py.pdf>`_.
OpenOffice
The sandbox project `odtwriter` provided syntax highlight with
pygments but used a different syntax and implementation.
-
- (What is the status of the official `odtwriter` now included in the
+
+ (What is the status of the `odtwriter` now included in the
standard distribution?)
@@ -268,7 +273,7 @@ TODO
place".
* add the CSS rules to the default style-sheet (see pygments-default.css_)
-
+
* provide a LaTeX style.
2. Write functional test case and sample.
@@ -354,10 +359,10 @@ Odtwriter syntax
----------------
.. attention::
- The content of this section relates to an old version of the
+ The content of this section relates to an old version of the
`odtwriter`. Things changed with the inclusion of the `odtwriter` into
standard Docutils.
-
+
This is only kept for historical reasons.
Dave Kuhlman's odtwriter_ extension can add syntax highlighting
@@ -438,4 +443,4 @@ I.e. the odtwriter implements a `configurable literal block directive`_
.. _pygments_code_block_directive: pygments_code_block_directive-bunt.py.htm
.. _rst2html-highlight: ../rst2html-highlight
.. _pygments-long.css: ../data/pygments-long.css
-
+.. _stylesheets: ../../stylesheets/