
    ohe8                     r   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 ddl	m
Z
  ej                  ej                  j                   ej                         d      ej                  j                   ej                  e      d            Zd Z G d	 d
e
j&                        Z G d de
j(                        Zy)z
S5/HTML Slideshow Writer.
reStructuredText    N)frontendnodesutils)	html4css1dummythemesc                     t         j                  j                  t        |       }t         j                  j	                  |      st        j                  d| d|d      |S )NzTheme directory not found: z (path: ))ospathjointhemes_dir_pathisdirdocutilsApplicationError)namer   s     C/usr/lib/python3/dist-packages/docutils/writers/s5_html/__init__.py
find_themer      sJ     77<<.D77=='':>EG 	GK    c                   0   e Zd Zej                  j
                  ddddgddddfd	d
gdddfddgdej                  dfddgdddfddgddgdddfddgddej                  d fd!d"gd#ddfd$d%gdej                  dfd&d'gd(ddff	fz   Zd)d*iZd+Z	d,Z
d- Zy.)/WriterzS5 Slideshow Specific OptionszFor the S5/HTML writer, the --no-toc-backlinks option (defined in General Docutils Options above) is the default, and should not be changed.aB  Specify an installed S5 theme by name.  Overrides --theme-url.  The default theme name is "default".  The theme files will be copied into a "ui/<theme>" directory, in the same directory as the destination file (output HTML).  Note that existing theme files will not be overwritten (unless --overwrite-theme-files is used).z--themedefaultz<name>	theme_url)r   metavar	overrideszSpecify an S5 theme URL.  The destination file (output HTML) will link to this theme; nothing will be copied.  Overrides --theme.z--theme-urlz<URL>theme)r   r   z{Allow existing theme files in the ``ui/<theme>`` directory to be overwritten.  The default is not to overwrite theme files.z--overwrite-theme-files
store_true)action	validatorzfKeep existing theme files in the ``ui/<theme>`` directory; do not overwrite any.  This is the default.z--keep-theme-filesoverwrite_theme_filesstore_false)destr   z@Set the initial view mode to "slideshow" [default] or "outline".z--view-mode	slideshowoutlinez<mode>)choicesr   r   zONormally hide the presentation controls in slideshow mode. This is the default.z--hidden-controlsT)r   r   r    z^Always show the presentation controls in slideshow mode.  The default is to hide the controls.z--visible-controlshidden_controlszMEnable the current slide indicator ("1 / 15").  The default is to disable it.z--current-slidez:Disable the current slide indicator.  This is the default.z--no-current-slidecurrent_slidetoc_backlinksr   zs5_html writer)writerszhtml writerszhtml4css1 writerc                 X    t         j                  j                  |        t        | _        y N)r   r   __init__S5HTMLTranslatortranslator_classselfs    r   r-   zWriter.__init__Y   s    !!$' 0r   N)__name__
__module____qualname__r   r   settings_specr   validate_booleansettings_default_overridesconfig_sectionconfig_section_dependenciesr-    r   r   r   r   #   sT   $$22'	%N
 +H#%
&L/G
4
6G$
%!0I0I
J
L1
 *m
D
F M/"I.; 
!!
!d 113
4
1
 $
>
@*
!0I0I
J
L G
 "m
<
>K'	@,6A ,AM\ #21!5%N#71r   r   c                       e Zd ZdZdZdZdZ	 dZ	 dZ	 dZ		 e	ez   Z
	 d Zd	 Zd
 Z ej                  d      Zd Zd Zd Zd Zd Zd Zd Zy)r.   a  <!-- configuration parameters -->
<meta name="defaultView" content="%(view_mode)s" />
<meta name="controlVis" content="%(control_visibility)s" />
<!-- style sheet links -->
<script src="%(path)s/slides.js" type="text/javascript"></script>
<link rel="stylesheet" href="%(path)s/slides.css"
      type="text/css" media="projection" id="slideProj" />
<link rel="stylesheet" href="%(path)s/outline.css"
      type="text/css" media="screen" id="outlineStyle" />
<link rel="stylesheet" href="%(path)s/print.css"
      type="text/css" media="print" id="slidePrint" />
<link rel="stylesheet" href="%(path)s/opera.css"
      type="text/css" media="projection" id="operaFix" />
zA
<style type="text/css">
#currentSlide {display: none;}
</style>
z<div class="layout">
<div id="controls"></div>
<div id="currentSlide"></div>
<div id="header">
%(header)s
</div>
<div id="footer">
%(title)s%(footer)s
</div>
</div>
r   __base__)z
slides.csszoutline.cssz	print.cssz	opera.cssz	slides.js)zs5-core.csszframing.cssz
pretty.cssc                 \   t        j                  j                  | g|  d | _        | j	                          | j
                  j                  j                  }d| j
                  j                  j                     }| j                  j                  | j                  | j                  ||dz         | j
                  j                  j                  s%| j                  j                  | j                         | j                  j                  d       g | _        g | _        d| _        d | _        y )N)visiblehidden)r   	view_modecontrol_visibilityz)<meta name="version" content="S5 1.1" />
r   )r   HTMLTranslatorr-   theme_file_pathsetup_themedocumentsettingsr@   r'   
stylesheetappends5_stylesheet_templater(   disable_current_slidemeta	s5_footer	s5_headersection_counttheme_files_copied)r1   argsr@   rA   s       r   r-   zS5HTMLTranslator.__init__   s      ))$66#MM**44	24==3I3I4COEt::*.*>*>/88J"L L 	M }}%%33OO""4#=#=>		EF"&r   c                    | j                   j                  j                  r| j                          y | j                   j                  j                  r&| j                   j                  j                  | _        y t        j                  d      )Nz&No theme specified for S5/HTML writer.)rE   rF   r   
copy_themer   rC   r   r   r0   s    r   rD   zS5HTMLTranslator.setup_theme   s`    ==!!''OO]]##--#'==#9#9#C#CD ++8: :r   c                    | j                   j                  }t        |j                        }|g}i | _        i }dd|j                  | _        |j                  rt        j                  j                  t        j                  j                  |j                        d|j                        }t        j                  j                  |      st        j                  |       nyd}|rGt        j                  |      D ]:  }|| j                  k(  r| j                  |||      s'|| j                   v s6d||<   < |rnt        j                  j                  || j                        }t        j                  j#                  |      ryt%        |d      5 }|j'                         }	ddd       	D ]K  }
|
j)                         }
|
s|
j+                  d      r(t        |
      }||v rd}n|j-                  |        n d}nd}|s(t        | j.                        }|j-                  |       d	}|rGt1        |      t1        | j                         k7  rit3        | j                         }|j5                         D ]  }|j7                  |        t9        j:                  d
dj                  d |D              z        y# 1 sw Y   xY w)a  
        Locate & copy theme files.

        A theme may be explicitly based on another theme via a '__base__'
        file.  The default base theme is 'default'.  Files are accumulated
        from the specified theme, any base themes, and 'default'.
        ui/NF   zutf-8)encoding#TzTheme files not found: %sz, c              3   &   K   | ]	  }d |z    yw)z%rNr:   ).0fs     r   	<genexpr>z.S5HTMLTranslator.copy_theme.<locals>.<genexpr>   s     7D1H7s   )rE   rF   r   r   rO   rC   _destinationr   r   r   dirnamer   makedirslistdirbase_theme_file	copy_filerequired_theme_filesisfileopen	readlinesstrip
startswithrH   default_themelenlistkeysremover   r   )r1   rF   r   theme_pathsrequired_files_copiedr#   r   r[   ra   lineslinerequireds               r   rR   zS5HTMLTranslator.copy_theme   sd    ==))(..)f"$ "*.?  77<< 5 56hnnND77==&D! ZZ% 1,,,NN1dD1T666/0)!,1  ggll41E1EFOww~~o./G< *KKME*! 
 D::<DDOOC$8)$/;.#'D'..t4
   D!$"4"45""4(? @ $%T-F-F)GGD556H*//1 #"#+++))7h7789 9 H'* *s   J99Kz~$|\.bak$|#$|\.cvsignore$c           
         t         j                  j                  ||      }t         j                  j                  ||      }|| j                  v ryd| j                  |<   t         j                  j	                  |      rC| j
                  j                  |      ry| j                  j                  }t         j                  j                  |      r(|j                  s|j                  j                  |       yt        |d      5 }|j                         }ddd       t        |d      5 }	|j                  t         j                   d      }|	j#                  j                  d||j%                  d      d j'                  t)        j*                                            ddd       |j                  j                  |       yt         j                  j	                  |      ryy# 1 sw Y   xY w# 1 sw Y   RxY w)z
        Copy file `name` from `source_dir` to `dest_dir`.
        Return 1 if the file exists in either `source_dir` or `dest_dir`.
        rV   NrbwbrU   s
   ui/defaultzui/)r   r   r   rO   rd   files_to_skip_patternsearchrE   rF   existsr!   record_dependenciesaddre   readreplacesepwriterfindencodesysgetfilesystemencoding)
r1   r   
source_dirdest_dirsourcer#   rF   src_filesrc_data	dest_files
             r   rb   zS5HTMLTranslator.copy_file   s   
 j$/ww||Hd+4***,-D##D)77>>&!))008}}--Hww~~d#H,J,J,,006  &$' /8'}}H/$% ;'//<HOOH$4$4% !6!78??5579%: ;; ,,00877>>$  / /; ;s   G#)A5G/#G,/G8c                    | j                   j                  | j                  | j                  d| j                  j
                  iz  g       | j                  j                  | j                         | j                  d d  | j                  z   | _	        | j                  rZ| j                  dk(  r&| j                  j                  | j                         n%| j                  j                  | j                         | j                  j                  | j                  dd         | j                  j                  | j                         dj!                  | j"                        }dj!                  | j$                        }dj!                  | j&                        j)                  dd      }| j*                  |||dz  }| j,                  j                  |       | j,                  j                  d       | j,                  j                  | j/                  d	gd
gdd             | j0                  s| j                  j                  d       | j2                  j5                  dd       | j6                  j                  | j,                  dd  | j8                  z   | j:                  z   | j                  z   | j2                  d d z          y )NlangmathjaxrV    z<h1 class="title">z<h1>)headertitlefooterz<div class="presentation">
slideslide0)classesidsdivz</div>
r   )head_prefixextenddoctypehead_prefix_templaterF   language_codehtml_prologrH   rK   headmath_headermath_outputrG   	html_headfragmentbodyr   rM   rL   
html_titler|   layout_templatebody_prefixstarttagrN   body_suffixinsert	html_bodybody_pre_docinfodocinfo)r1   noder   r   r   layouts         r   depart_documentz S5HTMLTranslator.depart_document  s1   !%!:!:"($--*E*E!F"G!H 	I 	-IIaL499,	9,		  !1!12&&t'7'78diim,TYY'(((001EvN%%62739); ; 	' >?MMwi
CUK	M!!IIZ(:.d..qr2T5J5JJ $-/3yy9 $ 0 0" 56 	7r   c                    | j                   j                         }| j                  j                  d       | j                  j	                  | j
                  |d         | j                  j                  d       | j
                  |d = y )Nz<h2>z</h2>)contextpoprL   rH   r   r   )r1   r   starts      r   depart_footerzS5HTMLTranslator.depart_footer9  sc      "f%dii/0g&IIefr   c                     | j                   j                         }dg}|j                  | j                  |d         |j	                  d       | j                  |d = | j
                  j                  |       y )Nz<div id="header">

</div>
)r   r   r   r   rH   rM   )r1   r   r   r   s       r   depart_headerzS5HTMLTranslator.depart_header@  s_      "'(dii'(l#IIeff%r   c                 z   | j                   s| j                  j                  d       | xj                   dz  c_         | xj                  dz  c_        | j                  dkD  r.| j                  j                  | j	                  |dd             y | j                  j                  | j	                  |dd             y )Nr   rV   r   section)CLASSr   )rN   r   rH   section_levelr   r1   r   s     r   visit_sectionzS5HTMLTranslator.visit_sectionH  s    !!II\*aa!IIT]]4i]HIIIT]]4g]FGr   c                 r   t        |j                  t        j                        rs| j                  | j
                  z   dz
  }|dk(  rd}d|z  }| j                  j                  | j                  ||d             | j                  j                  d|z         y t        j                  j                  | |       y )NrV      zh%sr   z</%s>
)
isinstanceparentr   r   r   initial_header_levelr   rH   r   r   r   rB   visit_subtitle)r1   r   leveltags       r   r   zS5HTMLTranslator.visit_subtitleS  s    dkk5==1&&)B)BBQFEz%-CIIT]]4b9:LL	C0$$33D$?r   c                 D    t         j                  j                  | |       y r,   )r   rB   visit_titler   s     r   r   zS5HTMLTranslator.visit_title^  s      ,,T48r   N)r2   r3   r4   rI   rJ   r   ri   ra   direct_theme_filesindirect_theme_filesrc   r-   rD   rR   recompilerv   rb   r   r   r   r   r   r   r:   r   r   r.   r.   ^   s    ?$

O  M$ OALD4 02DD)'(:?9B 'BJJ'CD>7B&	H	@9r   r.   )__doc____docformat__r   r   r   r   r   r   r   docutils.writersr   relative_pathr   r   getcwd_datadir__file__r   r   r   rB   r.   r:   r   r   <module>r      s    #  	 	  + + &%%%%GGLLg&GGLL"""8,h79
81Y 81vA9y// A9r   