o
    °-$`3  ã                   @   sl   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 ddlm	Z	m
Z
 ddlmZmZ G dd„ deƒZdS )	z(
Docutils component-related transforms.
ÚreStructuredTexté    N)ÚnodesÚutils)ÚApplicationErrorÚ	DataError)Ú	TransformÚTransformErrorc                   @   s   e Zd ZdZdZdd„ ZdS )ÚFilterab  
    Include or exclude elements which depend on a specific Docutils component.

    For use with `nodes.pending` elements.  A "pending" element's dictionary
    attribute ``details`` must contain the keys "component" and "format".  The
    value of ``details['component']`` must match the type name of the
    component the elements depend on (e.g. "writer").  The value of
    ``details['format']`` is the name of a specific format or context of that
    component (e.g. "html").  If the matching Docutils component supports that
    format or context, the "pending" element is replaced by the contents of
    ``details['nodes']`` (a list of nodes); otherwise, the "pending" element
    is removed.

    For example, the reStructuredText "meta" directive creates a "pending"
    element containing a "meta" element (in ``pending.details['nodes']``).
    Only writers (``pending.details['component'] == 'writer'``) supporting the
    "html", latex, or "odf" formats 
    (``pending.details['format'] == 'html,latex,odf'``) will include the
    "meta" element; it will be deleted from the output of all other writers.
    i  c                 C   sh   | j }|jd }|jd  d¡}| jjj| }|D ]}| |¡r+| |jd ¡  d S q|j 	|¡ d S )NÚ	componentÚformatú,r   )
Ú	startnodeÚdetailsÚsplitÚdocumentÚtransformerÚ
componentsÚsupportsÚreplace_selfÚparentÚremove)ÚselfÚpendingÚcomponent_typeÚformatsr
   r   © r   ú@/usr/lib/python3/dist-packages/docutils/transforms/components.pyÚapply-   s   

þzFilter.applyN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Údefault_priorityr   r   r   r   r   r	      s    r	   )r!   Ú__docformat__ÚsysÚosÚreÚtimeÚdocutilsr   r   r   r   Údocutils.transformsr   r   r	   r   r   r   r   Ú<module>   s   