<s> import os <EOL> import codecs <EOL> import shutil <EOL> import optparse <EOL> from markdown import markdown <EOL> HERE = os . path . abspath ( os . path . dirname ( __file__ ) ) <EOL> markdown_options = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> def copy ( dst ) : <EOL> try : <EOL> shutil . copytree ( os . path . join ( HERE , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> os . path . join ( dst , "<STR_LIT>" ) ) <EOL> shutil . copytree ( os . path . join ( HERE , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> os . path . join ( dst , '<STR_LIT>' ) ) <EOL> except : <EOL> pass <EOL> def slides_split ( slides ) : <EOL> data = '<STR_LIT>' <EOL> css = '<STR_LIT>' <EOL> for item in slides . split ( '<STR_LIT:\n>' ) : <EOL> if item . startswith ( '<STR_LIT>' ) : <EOL> yield css , data <EOL> css = '<STR_LIT:U+0020>' . join ( item . split ( '<STR_LIT:U+0020>' ) [ <NUM_LIT:1> : ] ) <EOL> data = '<STR_LIT>' <EOL> else : <EOL> data += item + '<STR_LIT:\n>' <EOL> yield css , data <EOL> def handle ( md , dst ) : <EOL> copy ( dst ) <EOL> slides = codecs . open ( md , '<STR_LIT:r>' , '<STR_LIT:utf-8>' ) . read ( ) <EOL> data = '<STR_LIT>' <EOL> for css , item in slides_split ( slides ) : <EOL> if not item : <EOL> continue <EOL> data += '<STR_LIT>' % css + '<STR_LIT>' + markdown ( item , markdown_options ) + '<STR_LIT>' + '<STR_LIT>' <EOL> index_template = os . path . join ( HERE , '<STR_LIT>' , '<STR_LIT>' ) <EOL> html = codecs . open ( index_template , '<STR_LIT:r>' , '<STR_LIT:utf-8>' ) <EOL> html = html . read ( ) . replace ( '<STR_LIT>' , data ) <EOL> f = codecs . open ( os . path . join ( dst , '<STR_LIT>' ) , '<STR_LIT:w>' , '<STR_LIT:utf-8>' ) <EOL> f . write ( html ) <EOL> f . close ( ) <EOL> def main ( ) : <EOL> '''<STR_LIT>''' <EOL> parser = optparse . OptionParser ( ) <EOL> ( options , args ) = parser . parse_args ( ) <EOL> if len ( args ) != <NUM_LIT:2> : <EOL> print '<STR_LIT>' <EOL> else : <EOL> handle ( * args ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
