
    c_                     .    d Z dZddlmZ  G d de      Zy)z$HTML formatting drivers for ureportszrestructuredtext en    )
HTMLWriterc                   j     e Zd ZdZ f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 xZS )DocbookWriterzformat layouts as HTMLc                     t         t        |   |       | j                  #| j	                  d       | j	                  d       yy)zbegin to format a layoutNz+<?xml version="1.0" encoding="ISO-8859-1"?>zC
<book xmlns:xi='http://www.w3.org/2001/XInclude'
      lang='fr'>
)superr   begin_formatsnippetwriteln)selflayout	__class__s     H/usr/lib/python3/dist-packages/logilab/common/ureports/docbook_writer.pyr   zDocbookWriter.begin_format   s?    j$,V4<<LLFGLL      c                 @    | j                   | j                  d       yy)zfinished to format a layoutNz</book>)r	   r
   r   r   s     r   
end_formatzDocbookWriter.end_format'   s    <<LL#  r   c           
      f   | j                   dk(  rd}nd}| xj                   dz  c_         | j                  | j                  dj                  || j	                  |                         | j                  |       | j                  | j                  d|z               | xj                   dz  c_         y)z:display a section (using <chapter> (level 0) or <section>)r   chaptersection   z<{}{}>z</%s>N)r   r
   _indentformathandle_attrsformat_children)r   r   tags      r   visit_sectionzDocbookWriter.visit_section,   s    <<1CCT\\(//#t7H7H7P"QRSV$T\\'C-01r   c                     | j                  | j                  d| j                  |      z               | j                  |       | j	                  d       y)zdisplay a title using <title>z  <title%s>z</title>N)writer   r   r   r
   r   s     r   visit_titlezDocbookWriter.visit_title8   sA    

4<<0A0A&0I IJKV$Z r   c           	      h   | j                  | j                  dj                  | j                  |      |j                                     | j                  | j                  d|j
                  z               t        |j
                        D ]%  }| j                  | j                  d|z               ' | j                  |      }|j                  rZ| j                  | j                  d             | j                  |d          | j                  | j                  d             |dd }ne|j                  rY| j                  | j                  d             | j                  |d	          | j                  | j                  d             |dd	 }| j                  | j                  d
             t        t        |            D ]  }||   }| j                  | j                  d             t        t        |            D ].  }||   xs d}| j                  | j                  d|z               0 | j                  | j                  d              | j                  | j                  d             | j                  | j                  d             | j                  | j                  d             y)zdisplay a table as htmlz  <table{}><title>{}</title>z    <tgroup cols="%s">z,      <colspec colname="c%s" colwidth="1*"/>z      <thead>r   z      </thead>r   Nz      <tbody>        <row>&#160;          <entry>%s</entry>        </row>z      </tbody>z    </tgroup>z
  </table>)r
   r   r   r   titlecolsrangeget_table_contentcheaders
_write_row	rcheaderslen)r   r   itable_contentrowjcells          r   visit_tablezDocbookWriter.visit_table>   s.   LL.55d6G6G6OQWQ]Q]^	

 	T\\":V[["HIJv{{# 	[ALL&TWX&XYZ	[ ..v6??LLo67OOM!,-LL&678)!"-MLLo67OOM"-.LL&678)#2.MT\\/23s=)* 	9A"CLLo673s8_ Q1v)T\\*G$*NOPQ LL&678	9 	T\\"234T\\/23T\\,/0r   c                     | j                  d       t        t        |            D ]  }||   xs d}| j                  d|z         ! | j                  | j                  d             y)z*write content of row (using <row> <entry>)r"   r#   r$   r%   N)r
   r(   r-   r   )r   r0   r1   r2   s       r   r+   zDocbookWriter._write_rowb   s]    _%s3x 	?Aq6%XDLL6=>	? 	T\\"234r   c                    | j                  | j                  d| j                  |      z               t        | j	                  |            D ]  }| j                  d|z          | j                  | j                  d             y)z%display a list (using <itemizedlist>)z  <itemizedlist%s>z(    <listitem><para>%s</para></listitem>z  </itemizedlist>N)r
   r   r   listcompute_content)r   r   r0   s      r   
visit_listzDocbookWriter.visit_listj   sq    T\\"9D<M<Mf<U"UVW,,V45 	KCLLCcIJ	KT\\"567r   c                     | j                  | j                  d             | j                  |       | j                  d       y)zdisplay links (using <para>)z  <para>z</para>N)r   r   r   r
   r   s     r   visit_paragraphzDocbookWriter.visit_paragraphq   s1    

4<<
+,V$Yr   c                     | j                  d| j                  |      z         | j                  |       | j                  d       y)zdisplay links (using <p>)z<literal %s>z
</literal>N)r   r   r   r   s     r   
visit_spanzDocbookWriter.visit_spanw   s:     	

>D$5$5f$==>V$

< r   c                     | j                  dj                  |j                  | j                  |      |j                               y)zdisplay links (using <ulink>)z<ulink url="{}"{}>{}</ulink>N)r   r   urlr   labelr   s     r   
visit_linkzDocbookWriter.visit_link~   s6    

*11

D--f5v||	
r   c                     | j                  | j                  d             | j                  |j                  j	                  dd      j	                  dd             | j                  | j                  d             y)z.display verbatim text (using <programlisting>)z  <programlisting>&&amp;<&lt;z  </programlisting>N)r
   r   r   datareplacer   s     r   visit_verbatimtextz DocbookWriter.visit_verbatimtext   sX    T\\"678

6;;&&sG4<<S&IJT\\"789r   c                 z    | j                  |j                  j                  dd      j                  dd             y)zadd some textrB   rC   rD   rE   N)r   rF   rG   r   s     r   
visit_textzDocbookWriter.visit_text   s,    

6;;&&sG4<<S&IJr   c                 &    d| j                   z  |z   S )z,correctly indent string according to sectionz  )r   )r   strings     r   r   zDocbookWriter._indent   s    $,,'&00r   )__name__
__module____qualname____doc__r   r   r   r   r3   r+   r8   r:   r<   r@   rH   rJ   r   __classcell__)r   s   @r   r   r      sI     
$

!"1H58 !
:K1r   r   N)rP   __docformat__#logilab.common.ureports.html_writerr   r    r   r   <module>rU      s    $ +% :z1J z1r   