
    oheA                         d Z dZddlZddlZddlmZ ddlZddlmZm	Z	 ddl
mZ  G d dej                        Z G d	 d
ej                        Zy)z
Plain HyperText Markup Language document tree Writer.

The output conforms to the `HTML 5` specification.

The cascading style sheet "minimal.css" is required for proper viewing,
the style sheet "plain.css" improves reading experience.
reStructuredText    N)Path)frontendnodes)
_html_basec                      e Zd ZdZ	 ddgZd ej                  ej                  j                  e
            gZ e ej                  ej                  j                  e
                  dz  Z ej                  ej"                  j$                  de ddged	d
fddj'                  e      z  dgddej(                  edfddj'                  e      z  dgdej(                  edfddgdj+                         dddfddgdddf       Zed!d"ej,                  d#gd$ej.                  d%fej,                  d&gd'ddfd(d)gd*d+ifd,d-gd.d$d/fd0d1gd2ddfffz   Zd3Zd4 Zy5)6Writer)html5xhtmlhtmlzminimal.cssz	plain.css.ztemplate.txtz)Template file. (UTF-8 encoded, default: "z")z
--templatez<file>)defaultmetavarzComma separated list of stylesheet paths. Relative paths are expanded if a matching file is found in the --stylesheet-dirs. With --link-stylesheet, the path is rewritten relative to the output HTML file. (default: "%s"),z--stylesheet-pathz<file[,file,...]>
stylesheet)r   	overrides	validatorr   zComma-separated list of directories where stylesheets are found. Used by --stylesheet-path when expanding relative path arguments. (default: "%s")z--stylesheet-dirsz<dir[,dir,...]>)r   r   r   zySpecify the initial header level. Does not affect document title & subtitle (see --no-doc-title). (default: 2 for "<h2>")z--initial-header-levelz1 2 3 4 5 62z<level>)choicesr   r   zOmit the XML declaration.z--no-xml-declarationxml_declarationstore_false)destaction)templatestylesheet_pathstylesheet_dirsinitial_header_levelno_xml_declarationzHTML5 Writer Options z--embed-images
store_true)r   r   z--link-imagesembed_imageszUSuggest at which point images should be loaded: "embed", "link" (default), or "lazy".z--image-loadingr   )embedlinklazyz'Append a self-link to section headings.z--section-self-linkr   )r   r   z8Do not append a self-link to section headings. (default)z--no-section-self-linksection_self_linkzhtml5 writerc                 (    i | _         t        | _        y N)partsHTMLTranslatortranslator_class)selfs    J/usr/lib/python3/dist-packages/docutils/writers/html5_polyglot/__init__.py__init__zWriter.__init__n   s    
 .    N)__name__
__module____qualname__	supporteddefault_stylesheetsdocutils_datadirospathabspath__file__default_stylesheet_dirsr   default_templater   filter_settings_specr   r	   settings_specjoinvalidate_comma_separated_listsplitSUPPRESS_HELPvalidate_booleanconfig_sectionr-    r.   r,   r	   r	   &   s   *I'(+6"$5H$5$5bggooh6O$PQ-H--bggooh.GHINZ 2H11''78H7ILN(X>@
 !$)< =	>
 !!+,"@@+-	.)+.884K+LM !!)"@@/12M%&%++-#!#	$ (#$&-@B="MF "


 
 
! 113
4 
 
 
!]
;
=2
/ 
 4 
!<
0
2 E#
$&-
@
B!	%
 
M2 $N/r.   r	   c                   $    e Zd ZdZddiZ fdZd Zd Zd Zd Z	d	 Z
d
 ZddhZd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdZ fdZd Zh dZd Zd Zd Zd  Z d! Z!d" Z"d# Z#d$ Z$d% Z%d& Z&d' Z'd( Z(d) Z)d* Z*d+ Z+d, Z, fd-Z- xZ.S ).r)   a>  
    This writer generates `polyglot markup`: HTML5 that is also valid XML.

    Safe subclassing: when overriding, treat ``visit_*`` and ``depart_*``
    methods as a unit to prevent breaks due to internal changes. See the
    docstring of docutils.writers._html_base.HTMLTranslator for details
    and examples.
    tagnamemainc                 Z    t         |   |       | j                  j                  d       y )NzG<meta name="viewport" content="width=device-width, initial-scale=1" />
)superr-   metaappend)r+   document	__class__s     r,   r-   zHTMLTranslator.__init__   s)    "		 N 	Or.   c                 \    | j                   j                  | j                  |dd             y )Nabbrr   )bodyrK   starttagr+   nodes     r,   visit_acronymzHTMLTranslator.visit_acronym   s!    		tVR89r.   c                 :    | j                   j                  d       y )Nz</abbr>rP   rK   rR   s     r,   depart_acronymzHTMLTranslator.depart_acronym   s    		#r.   c                     | j                  |dd       |D ]>  }| j                  j                  d| j                  |j	                                d       @ y )NauthorsFrJ   z<meta name="author" content="" />
visit_docinfo_itemrJ   rK   attvalastext)r+   rS   subnodes      r,   visit_authorszHTMLTranslator.visit_authors   s^    ie< 	HGII !!%W^^-=!> ?vG H	Hr.   c                 $    | j                          y r'   depart_docinfo_itemrR   s     r,   depart_authorszHTMLTranslator.depart_authors         "r.   c                     t        |j                  t        j                        r| j                  j                  d       | j                  j                  | j                  |dd             y )N<figcaption>
pr   )
isinstanceparentr   figurerP   rK   rQ   rR   s     r,   visit_captionzHTMLTranslator.visit_caption   sF    dkk5<<0II-.		tS"56r.   c                 :    | j                   j                  d       y )Nz</p>
rV   rR   s     r,   depart_captionzHTMLTranslator.depart_caption   s    		"r.   insdelc                 (   |d   }|D cg c]  }|| j                   v r| }}t        |      dk(  r|d   |_        |j                  |d          nd|_        | j                  j                  | j                  ||j                  d             y c c}w )Nclasses   r   divzdocutils containerCLASS)supported_block_tagslenhtml5tagnameremoverP   rK   rQ   r+   rS   rs   clstagss        r,   visit_containerzHTMLTranslator.visit_container   s     y/& 5$333  5 5t9> $QDNN47# %D		tT->->-A ' C 	D5s   Bc                 V    | j                   j                  d|j                   d       y N</z>
)rP   rK   rz   rR   s     r,   depart_containerzHTMLTranslator.depart_container   s$    		2d//045r.   c                     | j                  |dd       | j                  j                  d| j                  |j	                                d       y )N	copyrightFrZ   z%<meta name="dcterms.rights" content="r[   r\   rR   s     r,   visit_copyrightzHTMLTranslator.visit_copyright   sL    k>		 %%)[[%?$@H 	Ir.   c                 $    | j                          y r'   rc   rR   s     r,   depart_copyrightzHTMLTranslator.depart_copyright   rf   r.   c                     | j                  |dd       | j                  j                  d| j                  |j	                                d       y )NdateFrZ   z#<meta name="dcterms.date" content="r[   r\   rR   s     r,   
visit_datezHTMLTranslator.visit_date   sL    f59		 %%)[[%?$@H 	Ir.   c                 $    | j                          y r'   rc   rR   s     r,   depart_datezHTMLTranslator.depart_date   rf   r.   c                     i }|j                  d      rd|d    |d<   |j                  d      rd|d    |d<   | j                  j                   | j                  |dfi |       y )Nwidthzwidth: stylealignalign-classrl   )getrP   rK   rQ   r+   rS   attss      r,   visit_figurezHTMLTranslator.visit_figure   sk    88G%d7m_5DM88G$T']O4DM		tX>>?r.   c                     t        |      dkD  r| j                  j                  d       | j                  j                  d       y )Nrt   z</figcaption>
z
</figure>
)ry   rP   rK   rR   s     r,   depart_figurezHTMLTranslator.depart_figure   s2    t9q=II./		'r.   c                 `    | j                   j                  t        | j                               y r'   contextrK   ry   rP   rR   s     r,   visit_footerzHTMLTranslator.visit_footer       C		N+r.   c                 .   | j                   j                         }| j                  |d      g}|j                  | j                  |d         |j                  d       | j                  j                  |       || j                  d d | j                  |d = y )Nfooterz
</footer>
r   )r   poprQ   extendrP   rK   r   body_suffix)r+   rS   startr   s       r,   depart_footerzHTMLTranslator.depart_footer   s|      "--h/0dii'(m$6"%!IIefr.   c                 `    | j                   j                  t        | j                               y r'   r   rR   s     r,   visit_headerzHTMLTranslator.visit_header   r   r.   c                 F   | j                   j                         }| j                  |d      g}|j                  | j                  |d         |j                  d       | j                  j                  |       | j                  j                  |       | j                  |d = y )Nheaderz
</header>
)r   r   rQ   r   rP   rK   body_prefixr   )r+   rS   r   r   s       r,   depart_headerzHTMLTranslator.depart_header   s~      "--h/0dii'(m$'6"IIefr.   )z	video/mp4z
video/webmz	video/oggc                 L   i }|d   }t        j                  |      d   }|| j                  vrt        |   |      S d|v r|d   j                  dd      |d<   d|v r|d   j                  dd      |d<   d|v rd|d    |d	<   d
|d   v rd
|d
<   |d   j                  d
       |j                  d|      |d<   t        | j                  dd       dk(  rd|d<   t        |j                  t        j                        sRt        |j                  t        j                        r1t        |j                  j                  t        j                        sd}nd}|j                  d|      }| j                  j!                   | j"                  |d|fd|i|d| d| d| d| z          y )Nurir   r   pxr   heightr   r   r   controlsrs   alttitleimage_loadingr$   loading
videosrcz	<a href="">z</a>z</video>)	mimetypes
guess_type
videotypesrI   visit_imagereplacer{   r   getattrsettingsrj   rk   r   TextElement	referencerP   rK   rQ   )r+   rS   r   r   mimetypesuffixfallbackrM   s          r,   r   zHTMLTranslator.visit_image   s   5k'',Q/4??*7&t,,d? M11$;DMt!(^33D"=DNd?$T']O4DMi()DO"":.,W4==/48FB$DOt{{E$5$564;;8"4;;#5#5u7H7HIFF88E3'		DMM$ASADA#b
$vhhvhGH	Ir.   c                      y r'   rD   rR   s     r,   depart_imagezHTMLTranslator.depart_image      r.   >   biqsubdirq   dfnrp   kbdvarcodemarksampsmallc                 4   |d   }| j                   D cg c]  }||v r|
 }}t        |      r|d   |_        |j                  |d          n|dgk(  rt	        |j
                  t        j                        r`d|j
                  j                  d      v rC| j                  d   dk(  r| j                  d= n| j                  j                  d       d|_        nd	|_        | j                  j                  | j                  ||j                  d
             y c c}w )Nrs   r   lnr   z<code></code>r   spanr   )supported_inline_tagsry   rz   r{   rj   rk   r   literal_blockr   rP   rK   rQ   r|   s        r,   visit_inlinezHTMLTranslator.visit_inline  s    y/#99 #'>  # #t9 $QDNN47#$T[[%*=*=>DKKOOI66yy}(IIbM		  + 'D &D		tT->->CD#s   Dc                 D   | j                   j                  d|j                   d       |j                  dk(  rf|j                  d      dgk(  rQt	        |j
                  t        j                        r-| j                   j                  d|j                          d       |`y )Nr   >r   rs   r   z<code data-lineno="r   )	rP   rK   rz   r   rj   rk   r   r   r_   rR   s     r,   depart_inlinezHTMLTranslator.depart_inline0  s    		2d//023(TXXi-@TF-J4;;(;(;<II24;;=/DEr.   c                     t        |j                  d   t        j                        s| j                  j                  d       | j                  j                  | j                  |dd             y )Nrt   rh   ru   legendrv   )rj   rk   r   captionrP   rK   rQ   rR   s     r,   visit_legendzHTMLTranslator.visit_legend8  sL    $++a.%--8II-.		tU(CDr.   c                 :    | j                   j                  d       y )Nz</div>
rV   rR   s     r,   depart_legendzHTMLTranslator.depart_legend=  s    		$r.   c                    |d   }| j                   D cg c]  }||v r|
 }}t        |      r|d   }|j                  |d          nd}|dk(  r-| j                  j	                  | j                  |dd             y | j                  j	                  | j                  ||dd             |j                         }t        |j                  t        j                        s|j                  dd	      }| j                  j                  |      D ]  }|j                         rJ| j                  j!                  |      r/| j                  j	                  d
| j#                  |       d       ]| j                  j	                  | j#                  |              | j                  j	                  d| d       t        j$                  c c}w )Nrs   r   r   r   r   zdocutils literalrv   r    z<span class="pre">z</span>r   r   )r   ry   r{   rP   rK   rQ   r_   rj   rk   r   r   r   words_and_spacesfindallstripin_word_wrap_pointsearchencodeSkipNode)r+   rS   rs   r}   r~   rF   texttokens           r,   visit_literalzHTMLTranslator.visit_literalB  s   y/#99 #'>  # #t91gGNN47#GfIIT]]4<=		MM$3EMF	H{{}$++u':':;<<c*D **2248 	5E{{}!8!8!?!?!F		  (U);(<GDF 		  U!34	5 			2gYa)nn5#s   Gc                 :    | j                   j                  d       y )Nr   rV   rR   s     r,   depart_literalzHTMLTranslator.depart_literal`  s    		#r.   c                     |j                  d      r|d   |d<   | j                  j                   | j                  |dfi |j	                                y )Nlangzxml:langrJ   )hasattrrJ   rK   emptytagnon_default_attributesrR   s     r,   
visit_metazHTMLTranslator.visit_metaf  sS    <<#F|D		tV H)-)D)D)FH 	Ir.   c                      y r'   rD   rR   s     r,   depart_metazHTMLTranslator.depart_metal  r   r.   c                 ,    | j                  |dd       y )NorganizationFrZ   )r]   rR   s     r,   visit_organizationz!HTMLTranslator.visit_organizationp  s    n5Ar.   c                 $    | j                          y r'   rc   rR   s     r,   depart_organizationz"HTMLTranslator.depart_organizations  rf   r.   c                     | xj                   dz  c_         | j                  j                  | j                  |d             y )Nrt   section)section_levelrP   rK   rQ   rR   s     r,   visit_sectionzHTMLTranslator.visit_sectionw  s3    a		MM$	*	,r.   c                 d    | xj                   dz  c_         | j                  j                  d       y )Nrt   z</section>
)r  rP   rK   rR   s     r,   depart_sectionzHTMLTranslator.depart_section|  s%    a		(r.   c                 l    | j                   j                  | j                  |dd             d| _        y )Nasidesidebarrv   T)rP   rK   rQ   
in_sidebarrR   s     r,   visit_sidebarzHTMLTranslator.visit_sidebar  s-    		MM$yM9	;r.   c                 H    | j                   j                  d       d| _        y )Nz	</aside>
F)rP   rK   r
  rR   s     r,   depart_sidebarzHTMLTranslator.depart_sidebar  s    		&r.   c                 n   ddgi}d|d   v rCd|_         |d= t        |j                  t        j                        rDd|d<   d| j
                  d<   n/d	|d   v rd
|_         d|d<   nd|d   v rd
|_         d|d<   nd|_         | j                  j                   | j                  ||j                   fi |       y )Nrs   topiccontentsnavzdoc-tocrolez </head>
<body class="with-toc">
r   abstractru   zdoc-abstract
dedicationzdoc-dedicationr  )	html_tagnamerj   rk   r   rL   r   rP   rK   rQ   r   s      r,   visit_topiczHTMLTranslator.visit_topic  s    G9%i( %DY$++u~~6(V&J  #4	?* %D)DLT)_, %D+DL 'D		tT->->G$GHr.   c                 Z    | j                   j                  d|j                   d       |`y r   )rP   rK   r  rR   s     r,   depart_topiczHTMLTranslator.depart_topic  s*    		2d//045r.   c                    t         |   |      \  }}|j                  d   }|rYt        | j                  dd       rBt        |j                  t        j                        sd|d    d}|j                  d|dz         }||fS )Nidsr%   z9<a class="self-link" title="link to this section" href="#r   z"></a>z</h)	rI   section_title_tagsrk   r   r   rj   r   rL   r   )r+   rS   	start_tag	close_tagr  	self_linkrM   s         r,   r  z!HTMLTranslator.section_title_tags  s    $w9$?	9kk% GDMM+>Et{{ENN;$$'F863I!))%U1BCI)##r.   )/r/   r0   r1   __doc__documenttag_argsr-   rT   rW   ra   re   rm   ro   rx   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  __classcell__)rM   s   @r,   r)   r)   s   s     "6*O:$
H#7
#
 "5>D6
I
#I
#@(,, :JI>6
E&E
%
<$IB#,
)

 I$
$ $r.   r)   )r  __docformat__r   os.pathr6   pathlibr   r4   r   r   docutils.writersr   r	   r)   rD   r.   r,   <module>r&     sL   & #     $ 'J/Z J/Zy$Z.. y$r.   