o
    !5p`   ã                   @   sŠ   d Z dZddlZddlZddlZddlZddlmZmZmZm	Z	m
Z
 ddlmZ G dd„ dejƒZG dd	„ d	ejƒZG d
d„ dejƒZdS )z³
XeLaTeX document tree Writer.

A variant of Docutils' standard 'latex2e' writer producing LaTeX output
suited for processing with the Unicode-aware TeX engines
LuaTeX and XeTeX.
ÚreStructuredTexté    N)ÚfrontendÚnodesÚutilsÚwritersÚ	languages)Úlatex2ec                   @   sl   e Zd ZdZdZ	 dZd g d¢¡ZdZdZ	e
jejjdd	e d
geddœfddgdeifd�Zdd„ ZdS )ÚWriterz9A writer for Unicode-aware LaTeX variants (XeTeX, LuaTeX))ÚlxtexÚxetexÚxelatexÚluatexÚlualatexzxelatex.texÚ
)z;% Linux Libertine (free, wide coverage, not only for Linux)z\setmainfont{Linux Libertine O}z\setsansfont{Linux Biolinum O}zD\setmonofont[HyphenChar=None,Scale=MatchLowercase]{DejaVu Sans Mono}zxetex writer)r   zlatex writerszlatex2e writerÚfont_encodingzTemplate file. Default: "%s".z
--templatez<file>)ÚdefaultÚmetavarzUCustomization by LaTeX code in the preamble. Default: select "Linux Libertine" fonts.z--latex-preambler   )ÚtemplateÚlatex_preamblec                 C   s&   t j | ¡ | j ddi¡ t| _d S )NÚfontencodingÚ )r   r	   Ú__init__Úsettings_defaultsÚupdateÚXeLaTeXTranslatorÚtranslator_class)Úself© r   úA/usr/lib/python3/dist-packages/docutils/writers/xetex/__init__.pyr   @   s   
zWriter.__init__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	supportedÚdefault_templateÚjoinÚdefault_preambleÚconfig_sectionÚconfig_section_dependenciesr   Úfilter_settings_specr   r	   Úsettings_specr   r   r   r   r   r	   #   s(    ÿýûr	   c                   @   s€   e Zd ZdZejj ¡ Ze dddddddd	d
dddddddœ¡ e	dd„ e 
¡ D ƒƒZdD ]Zee ¡ = q.dd„ Zdd„ ZdS )ÚBabelz`Language specifics for XeTeX.

    Use `polyglossia` instead of `babel` and adapt settings.
    ÚcopticÚgermanÚogermanÚdivehiÚlsorbianÚ	polygreekÚfarsiÚancientgreekÚusorbianÚserbianÚcroatianÚalbanianÚthaiÚ
vietnamese)ÚcopÚdezde-1901ÚdvÚdsbz
el-polytonÚfaÚgrcÚhsbzsh-Cyrlzsh-LatnÚsqÚsrÚthÚvic                 C   s   g | ]
\}}|  ¡ |f‘qS r   )Úlower)Ú.0ÚkÚvr   r   r   Ú
<listcomp>a   s    zBabel.<listcomp>)
Úafzde-ATz
de-AT-1901zen-CAzen-GBzen-NZzen-USzfr-CAz
grc-ibycuszsr-Latnc                 C   s:   || _ || _|  |¡| _i | _d| _d| _d| _d| _d S )Nz+Language "%s" not supported by Polyglossia.r   )ú"rK   rK   )	Úlanguage_codeÚreporterÚlanguage_nameÚlanguageÚotherlanguagesÚwarn_msgÚquote_indexÚquotesÚliteral_double_quote)r   rL   rM   r   r   r   r   r   s   
zBabel.__init__c                 C   s<   dd| j  g}| jr| dd t| j ¡ ƒ¡ ¡ d |¡S )Nz\usepackage{polyglossia}z\setdefaultlanguage{%s}z\setotherlanguages{%s}ú,r   )rO   rP   Úappendr%   ÚsortedÚkeys)r   Úsetupr   r   r   Ú__call__~   s   ÿÿ
zBabel.__call__N)r   r    r!   r"   r   r+   Úlanguage_codesÚcopyr   ÚdictÚitemsÚkeyrE   r   rZ   r   r   r   r   r+   F   s2    ðr+   c                   @   s   e Zd ZdZdd„ ZdS )r   zÄ
    Generate code for LaTeX using Unicode fonts (XeLaTex or LuaLaTeX).

    See the docstring of docutils.writers._html_base.HTMLTranslator for
    notes on and examples of safe subclassing.
    c                 C   sF   d| _ tj | |t¡ | jdkr| j dd ¡ d S d| j | jd< d S )NTÚutf8Ú	_inputencz\XeTeXinputencoding %s )Úis_xetexr   ÚLaTeXTranslatorr   r+   Úlatex_encodingÚrequirementsÚpop)r   Údocumentr   r   r   r   �   s   
ÿzXeLaTeXTranslator.__init__N)r   r    r!   r"   r   r   r   r   r   r   ‡   s    r   )r"   Ú__docformat__ÚosÚos.pathÚreÚdocutilsr   r   r   r   r   Údocutils.writersr   r	   r+   rc   r   r   r   r   r   Ú<module>   s   #A