/usr/share/doc/python-pygments-doc/html/docs/styles.html is in python-pygments-doc 2.0.1+dfsg-1.1+deb8u1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | <!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Styles — Pygments 2.0.1 documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '2.0.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<link rel="top" title="Pygments 2.0.1 documentation" href="../index.html" />
<link rel="up" title="Pygments documentation" href="index.html" />
<link rel="next" title="Unicode and Encodings" href="unicode.html" />
<link rel="prev" title="Available formatters" href="formatters.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="unicode.html" title="Unicode and Encodings"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="formatters.html" title="Available formatters"
accesskey="P">previous</a> |</li>
<li><a href="../index.html">Pygments 2.0.1 documentation</a> »</li>
<li><a href="index.html" accesskey="U">Pygments documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="styles">
<h1>Styles<a class="headerlink" href="#styles" title="Permalink to this headline">¶</a></h1>
<p>Pygments comes with some builtin styles that work for both the HTML and
LaTeX formatter.</p>
<p>The builtin styles can be looked up with the <cite>get_style_by_name</cite> function:</p>
<div class="highlight-pycon"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">pygments.styles</span> <span class="kn">import</span> <span class="n">get_style_by_name</span>
<span class="gp">>>> </span><span class="n">get_style_by_name</span><span class="p">(</span><span class="s">'colorful'</span><span class="p">)</span>
<span class="go"><class 'pygments.styles.colorful.ColorfulStyle'></span>
</pre></div>
</div>
<p>You can pass a instance of a <cite>Style</cite> class to a formatter as the <cite>style</cite>
option in form of a string:</p>
<div class="highlight-pycon"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">pygments.styles</span> <span class="kn">import</span> <span class="n">get_style_by_name</span>
<span class="gp">>>> </span><span class="kn">from</span> <span class="nn">pygments.formatters</span> <span class="kn">import</span> <span class="n">HtmlFormatter</span>
<span class="gp">>>> </span><span class="n">HtmlFormatter</span><span class="p">(</span><span class="n">style</span><span class="o">=</span><span class="s">'colorful'</span><span class="p">)</span><span class="o">.</span><span class="n">style</span>
<span class="go"><class 'pygments.styles.colorful.ColorfulStyle'></span>
</pre></div>
</div>
<p>Or you can also import your own style (which must be a subclass of
<cite>pygments.style.Style</cite>) and pass it to the formatter:</p>
<div class="highlight-pycon"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">yourapp.yourmodule</span> <span class="kn">import</span> <span class="n">YourStyle</span>
<span class="gp">>>> </span><span class="kn">from</span> <span class="nn">pygments.formatters</span> <span class="kn">import</span> <span class="n">HtmlFormatter</span>
<span class="gp">>>> </span><span class="n">HtmlFormatter</span><span class="p">(</span><span class="n">style</span><span class="o">=</span><span class="n">YourStyle</span><span class="p">)</span><span class="o">.</span><span class="n">style</span>
<span class="go"><class 'yourapp.yourmodule.YourStyle'></span>
</pre></div>
</div>
<div class="section" id="creating-own-styles">
<h2>Creating Own Styles<a class="headerlink" href="#creating-own-styles" title="Permalink to this headline">¶</a></h2>
<p>So, how to create a style? All you have to do is to subclass <cite>Style</cite> and
define some styles:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">pygments.style</span> <span class="kn">import</span> <span class="n">Style</span>
<span class="kn">from</span> <span class="nn">pygments.token</span> <span class="kn">import</span> <span class="n">Keyword</span><span class="p">,</span> <span class="n">Name</span><span class="p">,</span> <span class="n">Comment</span><span class="p">,</span> <span class="n">String</span><span class="p">,</span> <span class="n">Error</span><span class="p">,</span> \
<span class="n">Number</span><span class="p">,</span> <span class="n">Operator</span><span class="p">,</span> <span class="n">Generic</span>
<span class="k">class</span> <span class="nc">YourStyle</span><span class="p">(</span><span class="n">Style</span><span class="p">):</span>
<span class="n">default_style</span> <span class="o">=</span> <span class="s">""</span>
<span class="n">styles</span> <span class="o">=</span> <span class="p">{</span>
<span class="n">Comment</span><span class="p">:</span> <span class="s">'italic #888'</span><span class="p">,</span>
<span class="n">Keyword</span><span class="p">:</span> <span class="s">'bold #005'</span><span class="p">,</span>
<span class="n">Name</span><span class="p">:</span> <span class="s">'#f00'</span><span class="p">,</span>
<span class="n">Name</span><span class="o">.</span><span class="n">Function</span><span class="p">:</span> <span class="s">'#0f0'</span><span class="p">,</span>
<span class="n">Name</span><span class="o">.</span><span class="n">Class</span><span class="p">:</span> <span class="s">'bold #0f0'</span><span class="p">,</span>
<span class="n">String</span><span class="p">:</span> <span class="s">'bg:#eee #111'</span>
<span class="p">}</span>
</pre></div>
</div>
<p>That’s it. There are just a few rules. When you define a style for <cite>Name</cite>
the style automatically also affects <cite>Name.Function</cite> and so on. If you
defined <tt class="docutils literal"><span class="pre">'bold'</span></tt> and you don’t want boldface for a subtoken use <tt class="docutils literal"><span class="pre">'nobold'</span></tt>.</p>
<p>(Philosophy: the styles aren’t written in CSS syntax since this way
they can be used for a variety of formatters.)</p>
<p><cite>default_style</cite> is the style inherited by all token types.</p>
<p>To make the style usable for Pygments, you must</p>
<ul class="simple">
<li>either register it as a plugin (see <a class="reference internal" href="plugins.html"><em>the plugin docs</em></a>)</li>
<li>or drop it into the <cite>styles</cite> subpackage of your Pygments distribution one style
class per style, where the file name is the style name and the class name is
<cite>StylenameClass</cite>. For example, if your style should be called
<tt class="docutils literal"><span class="pre">"mondrian"</span></tt>, name the class <cite>MondrianStyle</cite>, put it into the file
<tt class="docutils literal"><span class="pre">mondrian.py</span></tt> and this file into the <tt class="docutils literal"><span class="pre">pygments.styles</span></tt> subpackage
directory.</li>
</ul>
</div>
<div class="section" id="style-rules">
<h2>Style Rules<a class="headerlink" href="#style-rules" title="Permalink to this headline">¶</a></h2>
<p>Here a small overview of all allowed styles:</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">bold</span></tt></dt>
<dd>render text as bold</dd>
<dt><tt class="docutils literal"><span class="pre">nobold</span></tt></dt>
<dd>don’t render text as bold (to prevent subtokens being highlighted bold)</dd>
<dt><tt class="docutils literal"><span class="pre">italic</span></tt></dt>
<dd>render text italic</dd>
<dt><tt class="docutils literal"><span class="pre">noitalic</span></tt></dt>
<dd>don’t render text as italic</dd>
<dt><tt class="docutils literal"><span class="pre">underline</span></tt></dt>
<dd>render text underlined</dd>
<dt><tt class="docutils literal"><span class="pre">nounderline</span></tt></dt>
<dd>don’t render text underlined</dd>
<dt><tt class="docutils literal"><span class="pre">bg:</span></tt></dt>
<dd>transparent background</dd>
<dt><tt class="docutils literal"><span class="pre">bg:#000000</span></tt></dt>
<dd>background color (black)</dd>
<dt><tt class="docutils literal"><span class="pre">border:</span></tt></dt>
<dd>no border</dd>
<dt><tt class="docutils literal"><span class="pre">border:#ffffff</span></tt></dt>
<dd>border color (white)</dd>
<dt><tt class="docutils literal"><span class="pre">#ff0000</span></tt></dt>
<dd>text color (red)</dd>
<dt><tt class="docutils literal"><span class="pre">noinherit</span></tt></dt>
<dd>don’t inherit styles from supertoken</dd>
</dl>
<p>Note that there may not be a space between <tt class="docutils literal"><span class="pre">bg:</span></tt> and the color value
since the style definition string is split at whitespace.
Also, using named colors is not allowed since the supported color names
vary for different formatters.</p>
<p>Furthermore, not all lexers might support every style.</p>
</div>
<div class="section" id="builtin-styles">
<h2>Builtin Styles<a class="headerlink" href="#builtin-styles" title="Permalink to this headline">¶</a></h2>
<p>Pygments ships some builtin styles which are maintained by the Pygments team.</p>
<p>To get a list of known styles you can use this snippet:</p>
<div class="highlight-pycon"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">pygments.styles</span> <span class="kn">import</span> <span class="n">STYLE_MAP</span>
<span class="gp">>>> </span><span class="n">STYLE_MAP</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
<span class="go">['default', 'emacs', 'friendly', 'colorful']</span>
</pre></div>
</div>
</div>
<div class="section" id="getting-a-list-of-available-styles">
<h2>Getting a list of available styles<a class="headerlink" href="#getting-a-list-of-available-styles" title="Permalink to this headline">¶</a></h2>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
<p>Because it could be that a plugin registered a style, there is
a way to iterate over all styles:</p>
<div class="highlight-pycon"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">pygments.styles</span> <span class="kn">import</span> <span class="n">get_all_styles</span>
<span class="gp">>>> </span><span class="n">styles</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">get_all_styles</span><span class="p">())</span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Styles</a><ul>
<li><a class="reference internal" href="#creating-own-styles">Creating Own Styles</a></li>
<li><a class="reference internal" href="#style-rules">Style Rules</a></li>
<li><a class="reference internal" href="#builtin-styles">Builtin Styles</a></li>
<li><a class="reference internal" href="#getting-a-list-of-available-styles">Getting a list of available styles</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="formatters.html"
title="previous chapter">Available formatters</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="unicode.html"
title="next chapter">Unicode and Encodings</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/docs/styles.txt"
rel="nofollow">Show Source</a></li>
</ul>
<strong>« <a href="index.html">Back to docs index</a></strong>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="unicode.html" title="Unicode and Encodings"
>next</a> |</li>
<li class="right" >
<a href="formatters.html" title="Available formatters"
>previous</a> |</li>
<li><a href="../index.html">Pygments 2.0.1 documentation</a> »</li>
<li><a href="index.html" >Pygments documentation</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2014, Georg Brandl.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3.
</div>
</body>
</html>
|