/ lib / pygments / formatters / html.pyc
html.pyc
  1  o

  2   ��c��
  3  @sdZddlZddlZddlZddlZddlmZddlmZddl	m
  4  Z
  5  mZmZddl
mZmZmZzddlZWneyCdZYnwdgZed�d	ed
  6  �ded�d
ed�ded�diZefdd�Zdd�Zdd�ZdZdedZdZdZGdd�de�ZdS)z�
  7      pygments.formatters.html
  8      ~~~~~~~~~~~~~~~~~~~~~~~~
  9  
 10      Formatter for HTML output.
 11  
 12      :copyright: Copyright 2006-2022 by the Pygments team, see AUTHORS.
 13      :license: BSD, see LICENSE for details.
 14  �N)�StringIO)�	Formatter)�Token�Text�STANDARD_TYPES)�get_bool_opt�get_int_opt�get_list_opt�
HtmlFormatter�&z&amp;�<z&lt;�>z&gt;�"z&quot;�'z&#39;cCs
 15  |�|�S)z<Escape &, <, > as well as single and double quotes for HTML.)�	translate)�text�table�r��C:\Users\Jacks.GUTTSPC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pygments\formatters\html.py�escape_html&s
 16  rcCs |�d�s
 17  |�d�r|Sd|S)N�calc�var�#)�
 18  startswith)�colorrrr�webify+srcCsNt�|�}|r	|Sd}|dur#d|d|}|j}t�|�}|dus||S)N��-�����)r�get�parent)�ttype�fname�anamerrr�_get_ttype_class2s
 19  
 20  �r$z�/*
 21  generated by Pygments <https://pygments.org/>
 22  Copyright 2006-2022 by the Pygments team.
 23  Licensed under the BSD license, see LICENSE for details.
 24  */
 25  %(styledefs)s
 26  a�<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
 27     "http://www.w3.org/TR/html4/strict.dtd">
 28  <!--
 29  generated by Pygments <https://pygments.org/>
 30  Copyright 2006-2022 by the Pygments team.
 31  Licensed under the BSD license, see LICENSE for details.
 32  -->
 33  <html>
 34  <head>
 35    <title>%(title)s</title>
 36    <meta http-equiv="content-type" content="text/html; charset=%(encoding)s">
 37    <style type="text/css">
 38  z/
 39    </style>
 40  </head>
 41  <body>
 42  <h2>%(title)s</h2>
 43  
 44  a5<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
 45     "http://www.w3.org/TR/html4/strict.dtd">
 46  
 47  <html>
 48  <head>
 49    <title>%(title)s</title>
 50    <meta http-equiv="content-type" content="text/html; charset=%(encoding)s">
 51    <link rel="stylesheet" href="%(cssfile)s" type="text/css">
 52  </head>
 53  <body>
 54  <h2>%(title)s</h2>
 55  
 56  z</body>
 57  </html>
 58  c@s eZdZdZdZdgZddgZdd�Zdd	�Zd
 59  d�Z	dd
�Z
 60  dd�ZdAdd�ZdAdd�Z
dAdd�Zdd�Zdd�Zedd��Zedd��Zedd ��Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zejd3d4�d5d6��Z d7d8�Z!d9d:�Z"d;d<�Z#d=d>�Z$d?d@�Z%dS)Br
 61  aZ,
 62      Format tokens as HTML 4 ``<span>`` tags within a ``<pre>`` tag, wrapped
 63      in a ``<div>`` tag. The ``<div>``'s CSS class can be set by the `cssclass`
 64      option.
 65  
 66      If the `linenos` option is set to ``"table"``, the ``<pre>`` is
 67      additionally wrapped inside a ``<table>`` which has one row and two
 68      cells: one containing the line numbers and one containing the code.
 69      Example:
 70  
 71      .. sourcecode:: html
 72  
 73          <div class="highlight" >
 74          <table><tr>
 75            <td class="linenos" title="click to toggle"
 76              onclick="with (this.firstChild.style)
 77                       { display = (display == '') ? 'none' : '' }">
 78              <pre>1
 79              2</pre>
 80            </td>
 81            <td class="code">
 82              <pre><span class="Ke">def </span><span class="NaFu">foo</span>(bar):
 83                <span class="Ke">pass</span>
 84              </pre>
 85            </td>
 86          </tr></table></div>
 87  
 88      (whitespace added to improve clarity).
 89  
 90      Wrapping can be disabled using the `nowrap` option.
 91  
 92      A list of lines can be specified using the `hl_lines` option to make these
 93      lines highlighted (as of Pygments 0.11).
 94  
 95      With the `full` option, a complete HTML 4 document is output, including
 96      the style definitions inside a ``<style>`` tag, or in a separate file if
 97      the `cssfile` option is given.
 98  
 99      When `tagsfile` is set to the path of a ctags index file, it is used to
100      generate hyperlinks from names to their definition.  You must enable
101      `lineanchors` and run ctags with the `-n` option for this to work.  The
102      `python-ctags` module from PyPI must be installed to use this feature;
103      otherwise a `RuntimeError` will be raised.
104  
105      The `get_style_defs(arg='')` method of a `HtmlFormatter` returns a string
106      containing CSS rules for the CSS classes used by the formatter. The
107      argument `arg` can be used to specify additional CSS selectors that
108      are prepended to the classes. A call `fmter.get_style_defs('td .code')`
109      would result in the following CSS classes:
110  
111      .. sourcecode:: css
112  
113          td .code .kw { font-weight: bold; color: #00FF00 }
114          td .code .cm { color: #999999 }
115          ...
116  
117      If you have Pygments 0.6 or higher, you can also pass a list or tuple to the
118      `get_style_defs()` method to request multiple prefixes for the tokens:
119  
120      .. sourcecode:: python
121  
122          formatter.get_style_defs(['div.syntax pre', 'pre.syntax'])
123  
124      The output would then look like this:
125  
126      .. sourcecode:: css
127  
128          div.syntax pre .kw,
129          pre.syntax .kw { font-weight: bold; color: #00FF00 }
130          div.syntax pre .cm,
131          pre.syntax .cm { color: #999999 }
132          ...
133  
134      Additional options accepted:
135  
136      `nowrap`
137          If set to ``True``, don't wrap the tokens at all, not even inside a ``<pre>``
138          tag. This disables most other options (default: ``False``).
139  
140      `full`
141          Tells the formatter to output a "full" document, i.e. a complete
142          self-contained document (default: ``False``).
143  
144      `title`
145          If `full` is true, the title that should be used to caption the
146          document (default: ``''``).
147  
148      `style`
149          The style to use, can be a string or a Style subclass (default:
150          ``'default'``). This option has no effect if the `cssfile`
151          and `noclobber_cssfile` option are given and the file specified in
152          `cssfile` exists.
153  
154      `noclasses`
155          If set to true, token ``<span>`` tags (as well as line number elements)
156          will not use CSS classes, but inline styles. This is not recommended
157          for larger pieces of code since it increases output size by quite a bit
158          (default: ``False``).
159  
160      `classprefix`
161          Since the token types use relatively short class names, they may clash
162          with some of your own class names. In this case you can use the
163          `classprefix` option to give a string to prepend to all Pygments-generated
164          CSS class names for token types.
165          Note that this option also affects the output of `get_style_defs()`.
166  
167      `cssclass`
168          CSS class for the wrapping ``<div>`` tag (default: ``'highlight'``).
169          If you set this option, the default selector for `get_style_defs()`
170          will be this class.
171  
172          .. versionadded:: 0.9
173             If you select the ``'table'`` line numbers, the wrapping table will
174             have a CSS class of this string plus ``'table'``, the default is
175             accordingly ``'highlighttable'``.
176  
177      `cssstyles`
178          Inline CSS styles for the wrapping ``<div>`` tag (default: ``''``).
179  
180      `prestyles`
181          Inline CSS styles for the ``<pre>`` tag (default: ``''``).
182  
183          .. versionadded:: 0.11
184  
185      `cssfile`
186          If the `full` option is true and this option is given, it must be the
187          name of an external file. If the filename does not include an absolute
188          path, the file's path will be assumed to be relative to the main output
189          file's path, if the latter can be found. The stylesheet is then written
190          to this file instead of the HTML file.
191  
192          .. versionadded:: 0.6
193  
194      `noclobber_cssfile`
195          If `cssfile` is given and the specified file exists, the css file will
196          not be overwritten. This allows the use of the `full` option in
197          combination with a user specified css file. Default is ``False``.
198  
199          .. versionadded:: 1.1
200  
201      `linenos`
202          If set to ``'table'``, output line numbers as a table with two cells,
203          one containing the line numbers, the other the whole code.  This is
204          copy-and-paste-friendly, but may cause alignment problems with some
205          browsers or fonts.  If set to ``'inline'``, the line numbers will be
206          integrated in the ``<pre>`` tag that contains the code (that setting
207          is *new in Pygments 0.8*).
208  
209          For compatibility with Pygments 0.7 and earlier, every true value
210          except ``'inline'`` means the same as ``'table'`` (in particular, that
211          means also ``True``).
212  
213          The default value is ``False``, which means no line numbers at all.
214  
215          **Note:** with the default ("table") line number mechanism, the line
216          numbers and code can have different line heights in Internet Explorer
217          unless you give the enclosing ``<pre>`` tags an explicit ``line-height``
218          CSS property (you get the default line spacing with ``line-height:
219          125%``).
220  
221      `hl_lines`
222          Specify a list of lines to be highlighted. The line numbers are always
223          relative to the input (i.e. the first line is line 1) and are
224          independent of `linenostart`.
225  
226          .. versionadded:: 0.11
227  
228      `linenostart`
229          The line number for the first line (default: ``1``).
230  
231      `linenostep`
232          If set to a number n > 1, only every nth line number is printed.
233  
234      `linenospecial`
235          If set to a number n > 0, every nth line number is given the CSS
236          class ``"special"`` (default: ``0``).
237  
238      `nobackground`
239          If set to ``True``, the formatter won't output the background color
240          for the wrapping element (this automatically defaults to ``False``
241          when there is no wrapping element [eg: no argument for the
242          `get_syntax_defs` method given]) (default: ``False``).
243  
244          .. versionadded:: 0.6
245  
246      `lineseparator`
247          This string is output between lines of code. It defaults to ``"\n"``,
248          which is enough to break a line inside ``<pre>`` tags, but you can
249          e.g. set it to ``"<br>"`` to get HTML line breaks.
250  
251          .. versionadded:: 0.7
252  
253      `lineanchors`
254          If set to a nonempty string, e.g. ``foo``, the formatter will wrap each
255          output line in an anchor tag with an ``id`` (and `name`) of ``foo-linenumber``.
256          This allows easy linking to certain lines.
257  
258          .. versionadded:: 0.9
259  
260      `linespans`
261          If set to a nonempty string, e.g. ``foo``, the formatter will wrap each
262          output line in a span tag with an ``id`` of ``foo-linenumber``.
263          This allows easy access to lines via javascript.
264  
265          .. versionadded:: 1.6
266  
267      `anchorlinenos`
268          If set to `True`, will wrap line numbers in <a> tags. Used in
269          combination with `linenos` and `lineanchors`.
270  
271      `tagsfile`
272          If set to the path of a ctags file, wrap names in anchor tags that
273          link to their definitions. `lineanchors` should be used, and the
274          tags file should specify line numbers (see the `-n` option to ctags).
275  
276          .. versionadded:: 1.6
277  
278      `tagurlformat`
279          A string formatting pattern used to generate links to ctags definitions.
280          Available variables are `%(path)s`, `%(fname)s` and `%(fext)s`.
281          Defaults to an empty string, resulting in just `#prefix-number` links.
282  
283          .. versionadded:: 1.6
284  
285      `filename`
286          A string used to generate a filename when rendering ``<pre>`` blocks,
287          for example if displaying source code. If `linenos` is set to
288          ``'table'`` then the filename will be rendered in an initial row
289          containing a single `<th>` which spans both columns.
290  
291          .. versionadded:: 2.1
292  
293      `wrapcode`
294          Wrap the code inside ``<pre>`` blocks using ``<code>``, as recommended
295          by the HTML5 specification.
296  
297          .. versionadded:: 2.4
298  
299      `debug_token_types`
300          Add ``title`` attributes to all token ``<span>`` tags that show the
301          name of the token.
302  
303          .. versionadded:: 2.10
304  
305  
306      **Subclassing the HTML formatter**
307  
308      .. versionadded:: 0.7
309  
310      The HTML formatter is now built in a way that allows easy subclassing, thus
311      customizing the output HTML code. The `format()` method calls
312      `self._format_lines()` which returns a generator that yields tuples of ``(1,
313      line)``, where the ``1`` indicates that the ``line`` is a line of the
314      formatted source code.
315  
316      If the `nowrap` option is set, the generator is the iterated over and the
317      resulting HTML is output.
318  
319      Otherwise, `format()` calls `self.wrap()`, which wraps the generator with
320      other generators. These may add some HTML code to the one generated by
321      `_format_lines()`, either by modifying the lines generated by the latter,
322      then yielding them again with ``(1, line)``, and/or by yielding other HTML
323      code before or after the lines, with ``(0, html)``. The distinction between
324      source lines and other code makes it possible to wrap the generator multiple
325      times.
326  
327      The default `wrap()` implementation adds a ``<div>`` and a ``<pre>`` tag.
328  
329      A custom `HtmlFormatter` subclass could look like this:
330  
331      .. sourcecode:: python
332  
333          class CodeHtmlFormatter(HtmlFormatter):
334  
335              def wrap(self, source, *, include_div):
336                  return self._wrap_code(source)
337  
338              def _wrap_code(self, source):
339                  yield 0, '<code>'
340                  for i, t in source:
341                      if i == 1:
342                          # it's a line of formatted code
343                          t += '<br>'
344                      yield i, t
345                  yield 0, '</code>'
346  
347      This results in wrapping the formatted lines with a ``<code>`` tag, where the
348      source lines are broken using ``<br>`` tags.
349  
350      After calling `wrap()`, the `format()` method also adds the "line numbers"
351      and/or "full document" wrappers if the respective options are set. Then, all
352      HTML yielded by the wrapped generator is output.
353      �HTML�htmlz*.htmlz*.htmc	Kstj|fi|��|�|j�|_t|dd�|_t|dd�|_|�dd�|_|�|�dd��|_	|�|�dd��|_
354  |�|�d	d��|_|�|�d
355  d��|_t|dd�|_
|�|�dd��|_|�|�d
d��|_|�|�dd��|_t|dd�|_i|_t|dd�|_|jr�ts�td��t�|j�|_|�dd�}|dkr�d|_n	|r�d|_nd|_tt|dd��|_tt|dd��|_tt|dd��|_t|dd�|_|�dd�|_|�dd�|_ |�dd�|_!t|dd�|_"t#�|_$t%|d g�D]}z
356  |j$�&t'|��Wq�t(�yYq�w|�)�dS)!N�nowrapF�	noclasses�classprefixr�cssclass�	highlight�	cssstyles�	prestyles�cssfile�noclobber_cssfile�tagsfile�tagurlformat�filename�wrapcode�debug_token_typeszRThe "ctags" package must to be installed to be able to use the "tagsfile" feature.�linenos�inline��r�linenostart�
357  linenostep�
linenospecial�nobackground�
lineseparator�
358  �lineanchors�	linespans�
anchorlinenos�hl_lines)*r�__init__�_decodeifneeded�titlerr'r(rr)r*r,r-r.r/r0r1r2r3�span_element_openersr4�ctags�RuntimeErrorZCTags�_ctagsr5�absrr9r:r;r<r=r?r@rA�setrBr	�add�int�
359  ValueError�_create_stylesheet)�self�optionsr5�linenorrrrC�sT�zHtmlFormatter.__init__cCst|�}|r|j|SdS)zUReturn the css class of this token type prefixed with
360          the classprefix option.r)r$r))rPr!Z
361  ttypeclassrrr�_get_css_class�s
362  zHtmlFormatter._get_css_classcCs:|�|�}|tvr|j}|�|�d|}|tvs	|pdS)zOReturn the CSS classes of this token type prefixed with the classprefix option.� r)rSrr )rPr!�clsrrr�_get_css_classes�s
363  �zHtmlFormatter._get_css_classescCs6|j�|�}|dur|j}|j�|�}|dus
364  |pdS)z1Return the inline CSS styles for this token type.Nr)�ttype2classrr )rPr!�cclassrrr�_get_css_inline_styles�s�z$HtmlFormatter._get_css_inline_stylescCs�tdi}|_i}|_|jD]`\}}|�|�}d}|dr(|dt|d�7}|dr0|d7}|dr8|d7}|dr@|d	7}|d
365  rN|dt|d
366  �7}|dr\|d
t|d�7}|ro|||<|dd�|t|�f||<qdS)Nrrzcolor: %s; �boldzfont-weight: bold; �italiczfont-style: italic; �	underlineztext-decoration: underline; �bgcolorzbackground-color: %s; �borderzborder: 1px solid %s; �����)rrW�class2style�stylerSr�len)rPZt2cZc2sr!�ndef�namerarrrrO�s,
367  
368  ��z HtmlFormatter._create_stylesheetNcCs<g}|�|���|�|�|��|�|�|��d�|�S)z�
369          Return CSS style definitions for the classes produced by the current
370          highlighting style. ``arg`` can be a string or list of selectors to
371          insert before the token type classes.
372          r>)�extend�get_linenos_style_defs�get_background_style_defs�get_token_style_defs�join)rP�argZstyle_linesrrr�get_style_defs�s
373  
374  zHtmlFormatter.get_style_defscs<|�|��dd�|j��D�}|���fdd�|D�}|S)NcSs*g|]\}\}}}|r|r||||f�qSrr)�.0rUrar!�levelrrr�
375  <listcomp>s��
376  �z6HtmlFormatter.get_token_style_defs.<locals>.<listcomp>cs2g|]\}}}}d�|�|t|�dd�f�qS)z%s { %s } /* %s */�N)�repr)rlrmr!rUra��prefixrrrns
377  ��)�get_css_prefixr`�items�sort)rPrj�styles�linesrrqrrhs
378  �
379  �z"HtmlFormatter.get_token_style_defscCs�|�|�}|jj}|jj}g}|r8|js8|dur8d}t|jvr+d|j|jtd}|�dd|d�||f�|durH|�dd|d�|f�|S)NrrTrz%s{ background: %s;%s }z%s { background-color: %s }Zhll)	rsra�background_color�highlight_colorr<rrWr`�insert)rPrjrr�bg_color�hl_colorrwZ
380  text_stylerrrrgs$
381  
382  
383  ���z'HtmlFormatter.get_background_style_defscCs0d|jd|jd|jd|jd|jg}|S)Nz
384  pre { %s }ztd.linenos .normal { %s }zspan.linenos { %s }ztd.linenos .special { %s }zspan.linenos.special { %s })�
385  _pre_style�_linenos_style�_linenos_special_style)rPrwrrrrf3s�z$HtmlFormatter.get_linenos_style_defscsJ|durd|jvrd|jpd}t|t�r|g�nt|���fdd�}|S)Nr*�.rcs>|rd|}g}�D]}|�|r|dpd|�q
386  d�|�S)Nr�rTrz, )�appendri)rU�tmprj��argsrrrrFs
387  z,HtmlFormatter.get_css_prefix.<locals>.prefix)rQr*�
388  isinstance�str�list)rPrjrrrr�rrs>s
389  zHtmlFormatter.get_css_prefixcCsdS)Nzline-height: 125%;r�rPrrrr}PszHtmlFormatter._pre_stylecC�d|jj|jjfS�NzGcolor: %s; background-color: %s; padding-left: 5px; padding-right: 5px;)ra�line_number_color�line_number_background_colorr�rrrr~T��zHtmlFormatter._linenos_stylecCr�r�)ra�line_number_special_color�$line_number_special_background_colorr�rrrr[r�z$HtmlFormatter._linenos_special_stylecCs(t|t�r|jr|�|j�S|��S|S�N)r��bytes�encoding�decode�rP�valuerrrrDbs
390  
391  zHtmlFormatter._decodeifneededc
392  csV�|jr�tj�|j�r|j}n/z|j}|r|ddkrt�tj�tj�|�|j�}Wnty=tdt	j
393  d�|j}Ynwz,tj�|�rH|jsit
|d��}|�td|�d�i�Wd�n1sdwYWnty}}zd|j|_�d}~wwdtt|j|j|jd	�fVndtt|j|�d�|jd
394  �fV|EdHdtfVdS)Nrrz^Note: Cannot determine output file name, using current directory as base for the CSS file name)�file�w�	styledefs�bodyzError writing CSS file: )rEr.r�)rEr�r�)r.�os�path�isabsrd�AttributeErrorri�dirname�print�sys�stderr�existsr/�open�write�CSSFILE_TEMPLATErk�OSError�strerror�DOC_HEADER_EXTERNALCSS�dictrEr��
395  DOC_HEADER�
396  DOC_FOOTER)rP�inner�outfileZcssfilenamer2�cf�errrrr�
397  _wrap_fullisX���
398  �������
399  ���
400  zHtmlFormatter._wrap_fullccs��t�}d}|D]\}}|r|d7}|�|�q|j}tt||d��}|j}|j}	|jp0|j}
401  |j	}|j
402  }g}
t|||�D]J}||	dk}|oO||dk}|rbd||f}|rad|
403  ||f}nd|}|rv|rpd|j}n
d|j
}n|r{d}nd}|r�d	||f}|
�|�q@d
404  �|
�}d}|jr�d|jd
}dd|j�d�|d|dfVdVd|��fVdVdVdS)Nrr8�%*d�<a href="#%s-%d">%s</a>rT� style="%s"z class="special"z class="normal"�<span%s>%s</span>r>rz<<tr><th colspan="2" class="filename"><span class="filename">z</span></th></tr>z<table class="ztable">z4<tr><td class="linenos"><div class="linenodiv"><pre>z"</pre></div></td><td class="code">)rz<div>)rz</div>)rz</td></tr></table>)rr�r9rbr�r;r:r?r@rAr(�rangerr~r�rir2r*�getvalue)rPr�ZdummyoutfileZlncount�t�line�fl�mw�sp�st�anchor_name�aln�noclsrw�i�
405  print_line�special_linera�lsZfilename_trrrr�_wrap_tablelinenos�sl��
406  ������
407  z HtmlFormatter._wrap_tablelinenosccs�t|�}|j}|j}|j}ttt|�|d��}|jp|j}|j}|j	}	|D][\}
408  }||dk}|o9||dk}
|rCd||f}nd|}|	rW|
rQd|j
409  }n
d|j}n|
r\d}nd}|rgd||f}n|}|rxdd	|||f|fVnd||fV|d7}q(dS)
410  Nr8rr�rTr�z class="linenos special"z class="linenos"r�r�)r�r;r:r9rbr�r?r@rAr(rr~)rPr�Zinner_linesr�r��numr�r�r�r��_Z
411  inner_liner�r�r�rar5rrr�_wrap_inlinelinenos�s@�
412  �
413  �z!HtmlFormatter._wrap_inlinelinenosccsn�|j}|jd}|D])\}}|r/|d7}|jrdnd||f}dd|||||f|fVqd|fVqdS)Nr8rz href="#%s-%d"z!<a id="%s-%d" name="%s-%d"%s></a>r)r?r9r5)rPr��sr�r�r��hrefrrr�_wrap_lineanchorss�
414  �zHtmlFormatter._wrap_lineanchorsccsP�|j}|jd}|D]\}}|r |d7}dd|||ffVqd|fVqdS)Nr8z<span id="%s-%d">%s</span>r)r@r9)rPr�r�r�r�r�rrr�_wrap_linespans
s�
415  �zHtmlFormatter._wrap_linespansccs��g}|jr|js|jjdur|�d|jjf�|jr"|�|j�d�|�}dd|jo0d|j|o6d|dfV|EdHdVdS)	Nzbackground: %s�; rz<divz class="%s"r�r
)rz</div>
416  )r(r<rarxr�r,rir*�rPr�rarrr�	_wrap_divs�
417  
418  ��
419  
420  zHtmlFormatter._wrap_divccs��g}|jr|�|j�|jr|�|j�d�|�}|jr,|jdkr,dd|jdfVdd|o3d|dfV|EdHd	VdS)
421  Nr�r8rz<span class="filename">�</span>z<prer�z><span></span>)rz</pre>)r-r�r(r}rir2r5r�rrr�	_wrap_pre%s�
422  
423  
424  zHtmlFormatter._wrap_preccs�dV|EdHdVdS)N)rz<code>)rz</code>r)rPr�rrr�
425  _wrap_code6s�
426  
427  zHtmlFormatter._wrap_code�d)�maxsizecCs|�t��d�S)z-HTML-escape a value and split it by newlines.r>)r�_escape_html_table�splitr�rrr�_translate_parts;szHtmlFormatter._translate_partsc	cs��|j}|j}|j}d}g}|D�]\}}z|j|}	WnDty`|jr-dd�|�nd}
428  |rI|�|�}|rF|j|d}d||
429  f}	nd}	n|�	|�}|rWd||
430  f}	nd}	|	|j|<Ynw|�
431  |�}
|r�|tjvr�|�
|�\}}|r�tj�|�\}}|r�|d7}tj�|�\}}|j|||d�}d	||j||
df|
d<|
d
432  d|
d
433  <|
dd
434  �D]D}|r�||	kr�|r�|�|o�d
|	||	o�d
|f�n
435  |�||o�d
|f�dd�|�fVg}q�|r�dd�|	||	o�d
|f�fVq�d|fVq�|�r|
d
436  �r||	k�r|�|�od
|	|
d
437  f�|	}q|�|
d
438  �q|
d
439  �r'|	|
d
440  g}|	}q|�r?|�|�o1d
|f�dd�|�fVdSdS)zd
441          Just format the tokens, without any wrapping tags.
442          Yield individual lines.
443          rz title="%s"r�rz<span style="%s"%s>z<span class="%s"%s>�/)r�r"�fextz<a href="%s#%s-%d">%srz</a>Nr�r8)r(r=r0rF�KeyErrorr4rirYr`rVr�r�Name�_lookup_ctagr�r�r��splitextr1r?rer�)rP�tokensourcer�Zlsepr0Zlspanr�r!r�ZcspanrEZ	css_style�	css_class�partsr2�
444  linenumber�base�	extension�url�partrrr�
_format_lines@s~�
445  
446  �
447  ���
448  
449  ��zHtmlFormatter._format_linescCs0t��}|j�||��d�r|d|dfSdS)Nrr��
450  lineNumber)NN)rGZTagEntryrI�find�encode)rP�token�entryrrrr��szHtmlFormatter._lookup_ctagccs��|j}t|�D]>\}\}}|dkr||fV|d|vrA|jr9d}|jjdur/d|jjf}dd||ffVqdd|fVqd|fVqdS)z�
451          Highlighted the lines specified in the `hl_lines` option by
452          post-processing the token stream coming from `_format_lines`.
453          r8rNz style="background-color: %s"r�z<span class="hll">%s</span>)rB�	enumerater(rary)rPr��hlsr�r�r�rarrr�_highlight_lines�s �
454  ��zHtmlFormatter._highlight_linescCs"|}|jr
455  |�|�}|�|�}|S)z�
456          Wrap the ``source``, which is a generator yielding
457          individual lines, in custom generators. See docstring
458          for `format`. Can be overridden.
459          )r3r�r�)rP�source�outputrrr�wrap�s
460  
461  
462  zHtmlFormatter.wrapcCs�|�|�}|js|jdkr|�|�}|jr|�|�}|jsJ|jr%|�|�}|jr-|�	|�}|�
463  |�}|jdkr<|�|�}|�|�}|j
rJ|�||�}|D]	\}}|�|�qLdS)aW
464          The formatting process uses several nested generators; which of
465          them are used is determined by the user's options.
466  
467          Each generator should take at least one argument, ``inner``,
468          and wrap the pieces of text generated by this.
469  
470          Always yield 2-tuples: (code, text). If "code" is 1, the text
471          is part of the original tokensource being highlighted, if it's
472          0, the text is some piece of wrapping. This makes it possible to
473          use several different wrappers that process the original source
474          linewise, e.g. line number generators.
475          r7r8N)r�r'r5r�rBr�r?r�r@r�r�r�r��fullr�r�)rPr�r�r�r��piecerrr�format_unencoded�s&
476  
477  
478  
479  
480  
481  
482  
483  
484  �zHtmlFormatter.format_unencodedr�)&�__name__�
485  __module__�__qualname__�__doc__rd�aliases�	filenamesrCrSrVrYrOrkrhrgrfrs�propertyr}r~rrDr�r�r�r�r�r�r�r��	functools�	lru_cacher�r�r�r�r�r�rrrrr
486  qsN(1
487  
488  
489  
490  
491  
492  )D+
493  
494  
495  N)r�r�r�r��os.path�ior�pygments.formatterr�pygments.tokenrrr�
pygments.utilrrr	rG�ImportError�__all__�ordr�rrr$r�r�r�r�r
496  rrrr�<module>sB
497  ��		
�
�