/usr/share/doc/python-latexcodec-doc/html/quickstart.html is in python-latexcodec-doc 1.0.5-1.
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 | <!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>Getting Started — latexcodec 1.0.5 documentation</title>
<link rel="stylesheet" href="_static/classic.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '1.0.5',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</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="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="API" href="api.html" />
<link rel="prev" title="Welcome to latexcodec’s documentation!" href="index.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<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="api.html" title="API"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="index.html" title="Welcome to latexcodec’s documentation!"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">latexcodec 1.0.5 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="getting-started">
<h1>Getting Started<a class="headerlink" href="#getting-started" title="Permalink to this headline">¶</a></h1>
<div class="section" id="overview">
<h2>Overview<a class="headerlink" href="#overview" title="Permalink to this headline">¶</a></h2>
<p>A lexer and codec to work with LaTeX code in Python.</p>
<ul class="simple">
<li>Download: <a class="reference external" href="http://pypi.python.org/pypi/latexcodec/#downloads">http://pypi.python.org/pypi/latexcodec/#downloads</a></li>
<li>Documentation: <a class="reference external" href="http://latexcodec.readthedocs.org/">http://latexcodec.readthedocs.org/</a></li>
<li>Development: <a class="reference external" href="http://github.com/mcmtroffaes/latexcodec/">http://github.com/mcmtroffaes/latexcodec/</a></li>
</ul>
</div>
<div class="section" id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline">¶</a></h2>
<p>Install the module with <code class="docutils literal"><span class="pre">pip</span> <span class="pre">install</span> <span class="pre">latexcodec</span></code>, or from
source using <code class="docutils literal"><span class="pre">python</span> <span class="pre">setup.py</span> <span class="pre">install</span></code>.</p>
</div>
<div class="section" id="minimal-example">
<h2>Minimal Example<a class="headerlink" href="#minimal-example" title="Permalink to this headline">¶</a></h2>
<p>Simply import the <code class="xref py py-mod docutils literal"><span class="pre">latexcodec</span></code> module to enable <code class="docutils literal"><span class="pre">"latex"</span></code>
to be used as an encoding:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">latexcodec</span>
<span class="n">text_latex</span> <span class="o">=</span> <span class="sa">b</span><span class="s2">"</span><span class="se">\\</span><span class="s2">'el</span><span class="se">\\</span><span class="s2">`eve"</span>
<span class="k">assert</span> <span class="n">text_latex</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s2">"latex"</span><span class="p">)</span> <span class="o">==</span> <span class="sa">u</span><span class="s2">"élève"</span>
<span class="n">text_unicode</span> <span class="o">=</span> <span class="sa">u</span><span class="s2">"ångström"</span>
<span class="k">assert</span> <span class="n">text_unicode</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s2">"latex"</span><span class="p">)</span> <span class="o">==</span> <span class="sa">b</span><span class="s1">'</span><span class="se">\\</span><span class="s1">aa ngstr</span><span class="se">\\</span><span class="s1">"om'</span>
</pre></div>
</div>
<p>There are also a <code class="docutils literal"><span class="pre">ulatex</span></code> encoding for text transforms.
The simplest way to use this codec goes through the codecs module
(as for all text transform codecs on Python):</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">codecs</span>
<span class="kn">import</span> <span class="nn">latexcodec</span>
<span class="n">text_latex</span> <span class="o">=</span> <span class="sa">u</span><span class="s2">"</span><span class="se">\\</span><span class="s2">'el</span><span class="se">\\</span><span class="s2">`eve"</span>
<span class="k">assert</span> <span class="n">codecs</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="n">text_latex</span><span class="p">,</span> <span class="s2">"ulatex"</span><span class="p">)</span> <span class="o">==</span> <span class="sa">u</span><span class="s2">"élève"</span>
<span class="n">text_unicode</span> <span class="o">=</span> <span class="sa">u</span><span class="s2">"ångström"</span>
<span class="k">assert</span> <span class="n">codecs</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="n">text_unicode</span><span class="p">,</span> <span class="s2">"ulatex"</span><span class="p">)</span> <span class="o">==</span> <span class="sa">u</span><span class="s1">'</span><span class="se">\\</span><span class="s1">aa ngstr</span><span class="se">\\</span><span class="s1">"om'</span>
</pre></div>
</div>
<p>By default, the LaTeX input is assumed to be ascii, as per standard LaTeX.
However, you can also specify an extra codec
as <code class="docutils literal"><span class="pre">latex+<encoding></span></code> or <code class="docutils literal"><span class="pre">ulatex+<encoding></span></code>,
where <code class="docutils literal"><span class="pre"><encoding></span></code> describes another encoding.
In this case characters will be
translated to and from that encoding whenever possible.
The following code snippet demonstrates this behaviour:</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">latexcodec</span>
<span class="n">text_latex</span> <span class="o">=</span> <span class="sa">b</span><span class="s2">"</span><span class="se">\xfe</span><span class="s2">"</span>
<span class="k">assert</span> <span class="n">text_latex</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s2">"latex+latin1"</span><span class="p">)</span> <span class="o">==</span> <span class="sa">u</span><span class="s2">"þ"</span>
<span class="k">assert</span> <span class="n">text_latex</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s2">"latex+latin2"</span><span class="p">)</span> <span class="o">==</span> <span class="sa">u</span><span class="s2">"ţ"</span>
<span class="n">text_unicode</span> <span class="o">=</span> <span class="sa">u</span><span class="s2">"ţ"</span>
<span class="k">assert</span> <span class="n">text_unicode</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s2">"latex+latin1"</span><span class="p">)</span> <span class="o">==</span> <span class="sa">b</span><span class="s1">'</span><span class="se">\\</span><span class="s1">c t'</span> <span class="c1"># ţ is not latin1</span>
<span class="k">assert</span> <span class="n">text_unicode</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="s2">"latex+latin2"</span><span class="p">)</span> <span class="o">==</span> <span class="sa">b</span><span class="s1">'</span><span class="se">\xfe</span><span class="s1">'</span> <span class="c1"># but it is latin2</span>
</pre></div>
</div>
<p>When encoding using the <code class="docutils literal"><span class="pre">ulatex</span></code> codec, you have the option to pass
through characters that cannot be encoded in the desired encoding, by
using the <code class="docutils literal"><span class="pre">'keep'</span></code> error. This can be a useful fallback option if
you want to encode as much as possible, whilst still retaining as much
as possible of the original code when encoding fails. If instead you
want to translate to LaTeX but keep as much of the unicode as
possible, use the <code class="docutils literal"><span class="pre">ulatex+utf8</span></code> codec, which should never fail.</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">codecs</span>
<span class="kn">import</span> <span class="nn">latexcodec</span>
<span class="n">text_unicode</span> <span class="o">=</span> <span class="sa">u</span><span class="s1">'⌨'</span> <span class="c1"># \u2328 = keyboard symbol, currently not translated</span>
<span class="k">try</span><span class="p">:</span>
<span class="c1"># raises a value error as \u2328 cannot be encoded into latex</span>
<span class="n">codecs</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="n">text_unicode</span><span class="p">,</span> <span class="s2">"ulatex+ascii"</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
<span class="k">pass</span>
<span class="k">assert</span> <span class="n">codecs</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="n">text_unicode</span><span class="p">,</span> <span class="s2">"ulatex+ascii"</span><span class="p">,</span> <span class="s2">"keep"</span><span class="p">)</span> <span class="o">==</span> <span class="sa">u</span><span class="s1">'⌨'</span>
<span class="k">assert</span> <span class="n">codecs</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="n">text_unicode</span><span class="p">,</span> <span class="s2">"ulatex+utf8"</span><span class="p">)</span> <span class="o">==</span> <span class="sa">u</span><span class="s1">'⌨'</span>
</pre></div>
</div>
</div>
<div class="section" id="limitations">
<h2>Limitations<a class="headerlink" href="#limitations" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li>Not all unicode characters are registered. If you find any missing,
please report them on the tracker:
<a class="reference external" href="https://github.com/mcmtroffaes/latexcodec/issues">https://github.com/mcmtroffaes/latexcodec/issues</a></li>
<li>Unicode combining characters are currently not handled.</li>
<li>By design, the codec never removes curly brackets. This is because
it is very hard to guess whether brackets are part of a command or
not (this would require a full latex parser). Moreover, bibtex uses
curly brackets as a guard against case conversion, in which case
automatic removal of curly brackets may not be desired at all, even
if they are not part of a command. Also see:
<a class="reference external" href="http://stackoverflow.com/a/19754245/2863746">http://stackoverflow.com/a/19754245/2863746</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Getting Started</a><ul>
<li><a class="reference internal" href="#overview">Overview</a></li>
<li><a class="reference internal" href="#installation">Installation</a></li>
<li><a class="reference internal" href="#minimal-example">Minimal Example</a></li>
<li><a class="reference internal" href="#limitations">Limitations</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="index.html"
title="previous chapter">Welcome to latexcodec’s documentation!</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="api.html"
title="next chapter">API</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/quickstart.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<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="api.html" title="API"
>next</a> |</li>
<li class="right" >
<a href="index.html" title="Welcome to latexcodec’s documentation!"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">latexcodec 1.0.5 documentation</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2011-2017, Matthias C. M. Troffaes.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.5.6.
</div>
</body>
</html>
|