o f'hab9@sdZdZddlZddlZddlZddlZddlmZmZmZddl m Z ddl m Z e ejedejeedZd d ZGd d d e jZGd dde jZdS)z S5/HTML Slideshow Writer. reStructuredTextN)frontendnodesutils) html4css1) directivesdummythemescCs0tjt|}tj|std||f|S)Nz(Theme directory not found: %r (path: %r))ospathjointhemes_dir_pathisdirdocutilsApplicationError)namer rC/usr/lib/python3/dist-packages/docutils/writers/s5_html/__init__.py find_themes   rc@seZdZejjddddgddddfd d gd d d fddgdejdfddgdddfddgddgdddfddgddejd fd!d"gd#ddfd$d%gdejdfd&d'gd(ddff fZd)d*iZd+Z d,Z d-d.Z d/S)0WriterzS5 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.aBSpecify an installed S5 theme by name. Overrides --theme-url. The default theme name is "default". The theme files will be copied into a "ui/" 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--themedefaultz theme_url)rmetavar overrideszSpecify an S5 theme URL. The destination file (output HTML) will link to this theme; nothing will be copied. Overrides --theme.z --theme-urlztheme)rrz{Allow existing theme files in the ``ui/`` 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/`` directory; do not overwrite any. This is the default.z--keep-theme-filesoverwrite_theme_files store_false)destrz@Set the initial view mode to "slideshow" [default] or "outline".z --view-mode slideshowoutlinez)choicesrrzONormally hide the presentation controls in slideshow mode. This is the default.z--hidden-controlsT)rrrz^Always show the presentation controls in slideshow mode. The default is to hide the controls.z--visible-controlshidden_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_backlinksrzs5_html writer)writersz html writerszhtml4css1 writercCstj|t|_dSN)rr__init__S5HTMLTranslatortranslator_classselfrrrr)Ys  zWriter.__init__N) __name__ __module__ __qualname__rr settings_specrvalidate_booleansettings_default_overridesconfig_sectionconfig_section_dependenciesr)rrrrr#sh  . rc@seZdZdZdZdZdZ dZ dZ dZ e eZ dd Z d d Z d d Z edZddZddZddZddZddZddZddZdS)r*a zA z
r__base__)z slides.cssz outline.cssz print.cssz opera.cssz slides.js)z s5-core.cssz framing.cssz pretty.cssz blank.gifz iepngfix.htccGstjj|g|Rd|_||jjj}d|jjj}|j |j |j||d|jjj s7|j |j |dg|_g|_d|_d|_dS)N)visiblehidden)r view_modecontrol_visibilityz) r)rHTMLTranslatorr)theme_file_path setup_themedocumentsettingsr9r$ stylesheetappends5_stylesheet_templater%disable_current_slideadd_meta s5_footer s5_header section_counttheme_files_copied)r-argsr9r:rrrr)s(     zS5HTMLTranslator.__init__cCs:|jjjr |dS|jjjr|jjj|_dStd)Nz&No theme specified for S5/HTML writer.)r>r?r copy_themerr<rrr,rrrr=s   zS5HTMLTranslator.setup_themec Cs|jj}t|j}|g}i|_i}dd|jf|_|jr6tj tj |jd|j}tj |s5t |ndSd}|rt |D]}||jkrIqA||||rY||jvrYd||<qA|r]n]tj ||j}tj|rt| }|} Wdn1s~wY| D]} | } | r| dst| }||vrd}n||nqd}nd}|st|j}||d}|ssz/S5HTMLTranslator.copy_theme..)r>r?rrrHr< _destinationr r r dirnamermakedirslistdirbase_theme_file copy_filerequired_theme_filesisfileopen readlinesstrip startswithrA default_themelenlistkeysremoverr) r-r?r theme_pathsrequired_files_copiedr rrOrUlineslinerequiredrrrrJsr              zS5HTMLTranslator.copy_themez~$|\.bak$|#$|\.cvsignore$c Cstj||}tj||}||jvrdSd|j|<tj|rw|j|r(dS|jj}tj |r=|j s=|j |dSt |d}|}|t |d} |tjd}| |d||ddt| |j |dStj|rdSdS)z Copy file `name` from `source_dir` to `dest_dir`. Return 1 if the file exists in either `source_dir` or `dest_dir`. rLNrbwb/s ui/defaultzui/)r r r rHrXfiles_to_skip_patternsearchr>r?existsrrecord_dependenciesaddrYreadclosereplacesepwriterfindencodesysgetfilesystemencoding) r-r source_dirdest_dirsourcer r?src_filesrc_data dest_filerrrrVs8          zS5HTMLTranslator.copy_filecCs~|j|j|jd|jjig|j|j|j d|j |jj |j d|j |jj |j rF|jdkr?|j |j n|j|j |j|j dd|j|jd|j}d|j}d|jdd}|j|||d}|j||jd |j|d gd gd d |js|jd|j dd|j|jdd|j|j|j|jdddS)NlangrmathjaxrLz

z

)headertitlefooterz
slideslide0)classesidsdivz
) head_prefixextenddoctypehead_prefix_templater? language_code html_prologrAmetainsert content_typeoutput_encodinghead math_header math_outputr@ html_headfragmentbodyr rFrE html_titlerqlayout_template body_prefixstarttagrG body_suffix html_bodybody_pre_docinfodocinfo)r-noderrrlayoutrrrdepart_documentsH          z S5HTMLTranslator.depart_documentcCsH|j}|jd|j|j|d|jd|j|d=dS)Nz

z

)contextpoprErArr)r-rstartrrr depart_footer;s   zS5HTMLTranslator.depart_footercCsJ|j}dg}||j|d|d|j|d=|j|dS)Nz )rrrrrArF)r-rrrrrr depart_headerBs   zS5HTMLTranslator.depart_headercCsp|js |jd|jd7_|jd7_|jdkr*|j|j|ddddS|j|j|ddddS)NrrLrsection)CLASSr)rGrrA section_levelrr-rrrr visit_sectionJs  zS5HTMLTranslator.visit_sectioncCsnt|jtjr.|j|jd}|dkrd}d|}|j|||d|j d|dSt j ||dS)NrLzh%srz ) isinstanceparentrrrinitial_header_levelrrArrrr;visit_subtitle)r-rleveltagrrrrUszS5HTMLTranslator.visit_subtitlecCstj||dSr()rr; visit_titlerrrrr`szS5HTMLTranslator.visit_titleN)r.r/r0rBrCrr]rUdirect_theme_filesindirect_theme_filesrWr)r=rJrecompilerjrVrrrrrrrrrrr*^s2 A " r*)__doc__ __docformat__rvr rrrrrdocutils.writersrdocutils.parsers.rstr relative_pathr r getcwd_datadir__file__r rrr;r*rrrrs    ;