o
    ‡ÎÖaæ  ã                   @   sz   d Z ddlmZmZmZ ddlmZ ddlmZm	Z	m
Z
mZmZmZ ddlmZ dgZG dd„ deƒZG d	d„ deƒZd
S )zÈ
    pygments.lexers.email
    ~~~~~~~~~~~~~~~~~~~~~

    Lexer for the raw E-mail.

    :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
é    )Ú
RegexLexerÚDelegatingLexerÚbygroups)Ú	MIMELexer)ÚTextÚKeywordÚNameÚStringÚNumberÚComment)Úget_bool_optÚ
EmailLexerc                       s  e Zd ZdZ‡ fdd„Zdd„ Zdejdfdefgd	ej	fd
ej	dfde
fde
fdejfdejfdejfdejfdejfdejfdejfdejfdejfdejfdejfdejfdejfdejfdejfdejfdejfdeejejeje
jejejejƒfd ej	fd!efgd"œZ‡  ZS )#ÚEmailHeaderLexerzm
    Sub-lexer for raw E-mail. This lexer only process header part of e-mail.

    .. versionadded:: 2.5
    c                    s$   t ƒ jdi |¤Ž t|ddƒ| _d S )Nzhighlight-X-headerF© )ÚsuperÚ__init__r   Úhighlight_x©ÚselfÚoptions©Ú	__class__r   ú7/usr/lib/python3/dist-packages/pygments/lexers/email.pyr      s   zEmailHeaderLexer.__init__c                 c   s|   � | j r"| d¡tj| d¡fV  | j| d¡dd�}|E d H  d S | d¡tj| d¡fV  | d¡tj| d¡fV  d S )Né   é   ©ÚrootÚheader)Ústack)	r   Ústartr   ÚTagÚgroupÚget_tokens_unprocessedr   ÚSpecialÚ	Multiline)r   ÚmatchÚdefault_actionsr   r   r   Úget_x_header_tokens   s   €
ÿz$EmailHeaderLexer.get_x_header_tokensz^(?:[A-WYZ]|X400)[\w\-]*:r   z(^(X-(?:\w[\w\-]*:))([\s\S]*?\n)(?![ \t])z\n[ \t]z\n(?![ \t])z#popz\bE?SMTPS?\bz\b(?:HE|EH)LO\bz[\w\.\-\+=]+@[\w\.\-]+z<[\w\.\-\+=]+@[\w\.\-]+>z%\b(\w[\w\.-]*\.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9][0-9]{3})\s+(2[0-3]|[0-1][0-9]):([0-5][0-9])(?::(60|[0-5][0-9]))?(?:\.\d{1,5})?\s+([-\+][0-9]{2}[0-5][0-9]|\(?(?:UTC?|GMT|(?:E|C|M|P)(?:ST|ET|DT)|[A-IK-Z])\)?)zN(=\?)([\w-]+)(\?)([BbQq])(\?)([\[\w!\"#$%&\'()*+,-./:;<=>@[\\\]^_`{|}~]+)(\?=)z[\s]+z[\S]r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r'   r   r    r   Ú
Whitespacer   ÚLabelÚFunctionr
   ÚIntegerÚHexÚ	Decoratorr   r	   ÚAffixÚConstantÚtokensÚ__classcell__r   r   r   r   r      sr    
þ
ýÿÿÿüü	úùý³ûr   c                       s8   e Zd ZdZdZddgZdgZdgZ‡ fdd„Z‡  Z	S )	r   zÖ
    Lexer for raw E-mail.

    Additional options accepted:

    `highlight-X-header`
        Highlight the fields of ``X-`` user-defined email header. (default:
        ``False``).

    .. versionadded:: 2.5
    zE-mailÚemailÚemlz*.emlzmessage/rfc822c                    s   t ƒ jtttfi |¤Ž d S )N)r   r   r   r   r   r   r   r   r   r   •   s   zEmailLexer.__init__)
r(   r)   r*   r+   ÚnameÚaliasesÚ	filenamesÚ	mimetypesr   r5   r   r   r   r   r   ƒ   s    N)r+   Úpygments.lexerr   r   r   Úpygments.lexers.mimer   Úpygments.tokenr   r   r   r	   r
   r   Úpygments.utilr   Ú__all__r   r   r   r   r   r   Ú<module>   s    
 p