%PDF- %PDF-
Direktori : /lib/python3/dist-packages/reportlab/lib/__pycache__/ |
Current File : //lib/python3/dist-packages/reportlab/lib/__pycache__/pygments2xpre.cpython-312.pyc |
� ��d� � � � d Z dZddlZddlmZ d� Zdd�Zd� Zedk( r8ddl Z e j d d Zes ed � e j d� ee� yy)a� Helps you output colourised code snippets in ReportLab documents. Platypus has an 'XPreformatted' flowable for handling preformatted text, with variations in fonts and colors. If Pygments is installed, calling 'pygments2xpre' will return content suitable for display in an XPreformatted object. If it's not installed, you won't get colours. For a list of available lexers see http://pygments.org/docs/ )� pygments2xpre� N)�StringIOc �L � | j dd� } | j dd� } | j dd� } | j dd� } |g d�z D ]: \ }}| j d|z d|z � } t j d |z d|z | � } �< t j d d| � } | S )z<Helper to transform Pygments HTML output to ReportLab markupz<div class="highlight">� z</div>z<pre>z</pre>))�p�#000000)�nr )�errr z<span class="%s">z<span color="%s">z<span class="%s\s+.*">z<span class=".*">z<span color="#0f0f0f">)�replace�re�sub)�s�styles�k�cs �=/usr/lib/python3/dist-packages/reportlab/lib/pygments2xpre.py�_2xprer s� � � � � �+�B�/�A� � � �(�2��A� � � �'�"��A� � � �(�2��A��I�I� K���!� �I�I�)�A�-�.A�A�.E�F���F�F�,�a�/�0C�a�0G��J��K� ���#�$<�Q�?�A��H� c �� � ddl m} ddlm} ddlm} d� }t � } ||� } |� } || |||� |j j � D � � ��cg c]T \ } \ } }}| rI| rG| j d� r6| | j d� d j d� d j � f��V } }} } } |t |j � | � � S # t $ r | cY S w xY wc c}}} } w ) z(Return markup suitable for XPreformattedr )� highlight)� HtmlFormatter)�get_lexer_by_namec � � | S )N� )�xs r �<lambda>zpygments2xpre.<locals>.<lambda>$ s � �a� r zcolor:�;�:� )�pygmentsr �pygments.formattersr �ImportError�pygments.lexersr r �class2style�items� startswith�split�stripr �getvalue)r �languager r r �rconv�out�l�h�cls�style�ttype�levelr s r r r s� � ��&�5� 2��E� �*�C��(�#�A���A� �a��!�C��23�-�-�2E�2E�2G�A� A�.�C�.�%����5�U�%5�%5�h�%?� �E�K�K��$�Q�'�-�-�c�2�1�5�;�;�=�>� A�F� A� ������v�.�/�/�� � �����As �C �AC) �C&�%C&c �X � ddl m}m}m} ddlm} |� d } |� d } |d� }g j }| D ]G } | || |�� � t | d� j � } t | � } | |||�� � �I |j |j � t d � y )z,Helper function - makes minimal PDF documentr )� Paragraph�SimpleDocTemplate� XPreformatted)�getSampleStyleSheet�Title�Codezpygments2xpre.pdf)r0 �rzsaved pygments2xpre.pdfN) �reportlab.platypusr4 r5 r6 �reportlab.lib.stylesr7 �append�open�readr �build�__self__�print)� filenamesr4 r5 r6 r7 �styT�styC�doc�S�filename�src�fmts r �convertSourceFilesrK 0 s� � � O�N�8� � �w� '�D� � �v� &�D� �/� 0�C� � � �A�� *�� �)�H�4� (�)��8�S�!�&�&�(���C� �� �-��4� (�)� *� �I�I�a�j�j�� � #�$r �__main__r z2usage: pygments2xpre.py file1.py [file2.py] [...])�python)�__doc__�__all__r �ior r r rK �__name__�sys�argvrC rB �exitr r r �<module>rU sh �� � �� � � �0�*%�"