<s> from xml . sax import handler <EOL> from xml . sax . saxutils import escape , quoteattr <EOL> from xml . dom import Node <EOL> from . opendocument import load <EOL> from . namespaces import ANIMNS , CHARTNS , CONFIGNS , DCNS , DR3DNS , DRAWNS , FONS , FORMNS , MATHNS , METANS , NUMBERNS , OFFICENS , PRESENTATIONNS , SCRIPTNS , SMILNS , STYLENS , SVGNS , TABLENS , TEXTNS , XLINKNS <EOL> class StyleToCSS : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> self . fontdict = { } <EOL> self . fillimages = { } <EOL> self . ruleconversions = { <EOL> ( DRAWNS , '<STR_LIT>' ) : self . c_drawfillimage , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( FONS , "<STR_LIT>" ) : self . c_page_width , <EOL> ( FONS , "<STR_LIT>" ) : self . c_page_height , <EOL> ( FONS , "<STR_LIT>" ) : self . c_text_align , <EOL> ( FONS , "<STR_LIT>" ) : self . c_fo , <EOL> ( TABLENS , '<STR_LIT>' ) : self . c_border_model , <EOL> ( STYLENS , '<STR_LIT>' ) : self . c_width , <EOL> ( STYLENS , "<STR_LIT>" ) : self . c_fn , <EOL> ( STYLENS , '<STR_LIT>' ) : self . c_hp , <EOL> ( STYLENS , '<STR_LIT>' ) : self . c_text_position , <EOL> ( STYLENS , '<STR_LIT>' ) : self . c_text_line_through_style , <EOL> ( STYLENS , '<STR_LIT>' ) : self . c_text_underline_style , <EOL> ( STYLENS , '<STR_LIT:width>' ) : self . c_width , <EOL> } <EOL> def save_font ( self , name , family , generic ) : <EOL> """<STR_LIT>""" <EOL> htmlgeneric = "<STR_LIT>" <EOL> if generic == "<STR_LIT>" : htmlgeneric = "<STR_LIT>" <EOL> elif generic == "<STR_LIT>" : htmlgeneric = "<STR_LIT>" <EOL> elif generic == "<STR_LIT>" : htmlgeneric = "<STR_LIT>" <EOL> elif generic == "<STR_LIT>" : htmlgeneric = "<STR_LIT>" <EOL> elif generic == "<STR_LIT>" : htmlgeneric = "<STR_LIT>" <EOL> elif generic == "<STR_LIT>" : htmlgeneric = "<STR_LIT>" <EOL> self . fontdict [ name ] = ( family , htmlgeneric ) <EOL> def c_drawfillimage ( self , ruleset , sdict , rule , val ) : <EOL> """<STR_LIT>""" <EOL> sdict [ '<STR_LIT>' ] = "<STR_LIT>" % self . fillimages [ val ] <EOL> def c_fo ( self , ruleset , sdict , rule , val ) : <EOL> """<STR_LIT>""" <EOL> selector = rule [ <NUM_LIT:1> ] <EOL> sdict [ selector ] = val <EOL> def c_border_model ( self , ruleset , sdict , rule , val ) : <EOL> """<STR_LIT>""" <EOL> if val == '<STR_LIT>' : <EOL> sdict [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> else : <EOL> sdict [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> def c_width ( self , ruleset , sdict , rule , val ) : <EOL> """<STR_LIT>""" <EOL> sdict [ '<STR_LIT:width>' ] = val <EOL> def c_text_align ( self , ruleset , sdict , rule , align ) : <EOL> """<STR_LIT>""" <EOL> if align == "<STR_LIT:start>" : align = "<STR_LIT:left>" <EOL> if align == "<STR_LIT:end>" : align = "<STR_LIT:right>" <EOL> sdict [ '<STR_LIT>' ] = align <EOL> def c_fn ( self , ruleset , sdict , rule , fontstyle ) : <EOL> """<STR_LIT>""" <EOL> generic = ruleset . get ( ( STYLENS , '<STR_LIT>' ) ) <EOL> if generic is not None : <EOL> self . save_font ( fontstyle , fontstyle , generic ) <EOL> family , htmlgeneric = self . fontdict . get ( fontstyle , ( fontstyle , '<STR_LIT>' ) ) <EOL> sdict [ '<STR_LIT>' ] = '<STR_LIT>' % ( family , htmlgeneric ) <EOL> def c_text_position ( self , ruleset , sdict , rule , tp ) : <EOL> """<STR_LIT>""" <EOL> textpos = tp . split ( '<STR_LIT:U+0020>' ) <EOL> if len ( textpos ) == <NUM_LIT:2> and textpos [ <NUM_LIT:0> ] != "<STR_LIT>" : <EOL> sdict [ '<STR_LIT>' ] = textpos [ <NUM_LIT:1> ] <EOL> if textpos [ <NUM_LIT:0> ] == "<STR_LIT>" : <EOL> sdict [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> elif textpos [ <NUM_LIT:0> ] == "<STR_LIT>" : <EOL> sdict [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> else : <EOL> sdict [ '<STR_LIT>' ] = textpos [ <NUM_LIT:0> ] <EOL> def c_hp ( self , ruleset , sdict , rule , hpos ) : <EOL> wrap = ruleset . get ( ( STYLENS , '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> if hpos == "<STR_LIT>" : <EOL> sdict [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> sdict [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> if hpos in ( "<STR_LIT:right>" , "<STR_LIT>" ) : <EOL> if wrap in ( "<STR_LIT:left>" , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> sdict [ '<STR_LIT:float>' ] = "<STR_LIT:right>" <EOL> elif wrap == "<STR_LIT>" : <EOL> sdict [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> sdict [ '<STR_LIT>' ] = "<STR_LIT:0>" <EOL> sdict [ '<STR_LIT:right>' ] = "<STR_LIT:0>" ; <EOL> else : <EOL> sdict [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> sdict [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> elif hpos in ( "<STR_LIT:left>" , "<STR_LIT>" ) : <EOL> if wrap in ( "<STR_LIT:right>" , "<STR_LIT>" , "<STR_LIT>" ) : <EOL> sdict [ '<STR_LIT:float>' ] = "<STR_LIT:left>" <EOL> elif wrap == "<STR_LIT>" : <EOL> sdict [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> sdict [ '<STR_LIT>' ] = "<STR_LIT:0>" <EOL> sdict [ '<STR_LIT:left>' ] = "<STR_LIT:0>" <EOL> else : <EOL> sdict [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> sdict [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> elif hpos in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> if wrap in ( "<STR_LIT:right>" , "<STR_LIT>" ) : <EOL> sdict [ '<STR_LIT:float>' ] = "<STR_LIT:left>" <EOL> else : <EOL> sdict [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> if ( SVGNS , '<STR_LIT:x>' ) in ruleset : <EOL> sdict [ '<STR_LIT:left>' ] = ruleset [ ( SVGNS , '<STR_LIT:x>' ) ] <EOL> def c_page_width ( self , ruleset , sdict , rule , val ) : <EOL> """<STR_LIT>""" <EOL> sdict [ '<STR_LIT:width>' ] = val <EOL> def c_text_underline_style ( self , ruleset , sdict , rule , val ) : <EOL> """<STR_LIT>""" <EOL> if val and val != "<STR_LIT:none>" : <EOL> sdict [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> def c_text_line_through_style ( self , ruleset , sdict , rule , val ) : <EOL> """<STR_LIT>""" <EOL> if val and val != "<STR_LIT:none>" : <EOL> sdict [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> def c_page_height ( self , ruleset , sdict , rule , val ) : <EOL> """<STR_LIT>""" <EOL> sdict [ '<STR_LIT>' ] = val <EOL> def convert_styles ( self , ruleset ) : <EOL> """<STR_LIT>""" <EOL> sdict = { } <EOL> for rule , val in list ( ruleset . items ( ) ) : <EOL> if rule [ <NUM_LIT:0> ] == '<STR_LIT>' : <EOL> sdict [ rule [ <NUM_LIT:1> ] ] = val <EOL> continue <EOL> method = self . ruleconversions . get ( rule , None ) <EOL> if method : <EOL> method ( ruleset , sdict , rule , val ) <EOL> return sdict <EOL> class TagStack : <EOL> def __init__ ( self ) : <EOL> self . stack = [ ] <EOL> def push ( self , tag , attrs ) : <EOL> self . stack . append ( ( tag , attrs ) ) <EOL> def pop ( self ) : <EOL> item = self . stack . pop ( ) <EOL> return item <EOL> def stackparent ( self ) : <EOL> item = self . stack [ - <NUM_LIT:1> ] <EOL> return item [ <NUM_LIT:1> ] <EOL> def rfindattr ( self , attr ) : <EOL> """<STR_LIT>""" <EOL> for tag , attrs in self . stack : <EOL> if attr in attrs : <EOL> return attrs [ attr ] <EOL> return None <EOL> def count_tags ( self , tag ) : <EOL> c = <NUM_LIT:0> <EOL> for ttag , tattrs in self . stack : <EOL> if ttag == tag : c = c + <NUM_LIT:1> <EOL> return c <EOL> special_styles = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:address>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> class ODF2XHTML ( handler . ContentHandler ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , generate_css = True , embedable = False ) : <EOL> self . generate_css = generate_css <EOL> self . elements = { <EOL> ( DCNS , '<STR_LIT:title>' ) : ( self . s_processcont , self . e_dc_title ) , <EOL> ( DCNS , '<STR_LIT>' ) : ( self . s_processcont , self . e_dc_contentlanguage ) , <EOL> ( DCNS , '<STR_LIT>' ) : ( self . s_processcont , self . e_dc_creator ) , <EOL> ( DCNS , '<STR_LIT:description>' ) : ( self . s_processcont , self . e_dc_metatag ) , <EOL> ( DCNS , '<STR_LIT:date>' ) : ( self . s_processcont , self . e_dc_metatag ) , <EOL> ( DRAWNS , '<STR_LIT>' ) : ( self . s_custom_shape , self . e_custom_shape ) , <EOL> ( DRAWNS , '<STR_LIT>' ) : ( self . s_draw_frame , self . e_draw_frame ) , <EOL> ( DRAWNS , '<STR_LIT:image>' ) : ( self . s_draw_image , None ) , <EOL> ( DRAWNS , '<STR_LIT>' ) : ( self . s_draw_fill_image , None ) , <EOL> ( DRAWNS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( DRAWNS , '<STR_LIT:object>' ) : ( self . s_draw_object , None ) , <EOL> ( DRAWNS , '<STR_LIT>' ) : ( self . s_draw_object_ole , None ) , <EOL> ( DRAWNS , '<STR_LIT>' ) : ( self . s_draw_page , self . e_draw_page ) , <EOL> ( DRAWNS , '<STR_LIT>' ) : ( self . s_draw_textbox , self . e_draw_textbox ) , <EOL> ( METANS , '<STR_LIT>' ) : ( self . s_processcont , self . e_dc_metatag ) , <EOL> ( METANS , '<STR_LIT>' ) : ( self . s_processcont , self . e_dc_metatag ) , <EOL> ( METANS , '<STR_LIT>' ) : ( self . s_processcont , self . e_dc_metatag ) , <EOL> ( METANS , '<STR_LIT>' ) : ( self . s_processcont , self . e_dc_metatag ) , <EOL> ( NUMBERNS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( NUMBERNS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( NUMBERNS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( NUMBERNS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( NUMBERNS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( OFFICENS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( OFFICENS , "<STR_LIT>" ) : ( self . s_office_automatic_styles , None ) , <EOL> ( OFFICENS , "<STR_LIT>" ) : ( self . s_office_document_content , self . e_office_document_content ) , <EOL> ( OFFICENS , "<STR_LIT>" ) : ( self . s_office_document_content , self . e_office_document_content ) , <EOL> ( OFFICENS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( OFFICENS , "<STR_LIT>" ) : ( self . s_office_master_styles , None ) , <EOL> ( OFFICENS , "<STR_LIT>" ) : ( self . s_ignorecont , None ) , <EOL> ( OFFICENS , "<STR_LIT>" ) : ( self . s_office_presentation , self . e_office_presentation ) , <EOL> ( OFFICENS , "<STR_LIT>" ) : ( self . s_office_spreadsheet , self . e_office_spreadsheet ) , <EOL> ( OFFICENS , "<STR_LIT>" ) : ( self . s_office_styles , None ) , <EOL> ( OFFICENS , "<STR_LIT:text>" ) : ( self . s_office_text , self . e_office_text ) , <EOL> ( OFFICENS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( OFFICENS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( PRESENTATIONNS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( STYLENS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( STYLENS , "<STR_LIT>" ) : ( self . s_style_default_style , self . e_style_default_style ) , <EOL> ( STYLENS , "<STR_LIT>" ) : ( self . s_style_handle_properties , None ) , <EOL> ( STYLENS , "<STR_LIT>" ) : ( self . s_style_font_face , None ) , <EOL> ( STYLENS , "<STR_LIT>" ) : ( self . s_style_handle_properties , None ) , <EOL> ( STYLENS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( STYLENS , "<STR_LIT>" ) : ( self . s_style_master_page , None ) , <EOL> ( STYLENS , "<STR_LIT>" ) : ( self . s_style_handle_properties , None ) , <EOL> ( STYLENS , "<STR_LIT>" ) : ( self . s_style_page_layout , self . e_style_page_layout ) , <EOL> ( STYLENS , "<STR_LIT>" ) : ( self . s_style_handle_properties , None ) , <EOL> ( STYLENS , "<STR_LIT>" ) : ( self . s_style_style , self . e_style_style ) , <EOL> ( STYLENS , "<STR_LIT>" ) : ( self . s_style_handle_properties , None ) , <EOL> ( STYLENS , "<STR_LIT>" ) : ( self . s_style_handle_properties , None ) , <EOL> ( STYLENS , "<STR_LIT>" ) : ( self . s_style_handle_properties , None ) , <EOL> ( STYLENS , "<STR_LIT>" ) : ( self . s_style_handle_properties , None ) , <EOL> ( SVGNS , '<STR_LIT>' ) : ( self . s_ignorexml , None ) , <EOL> ( TABLENS , '<STR_LIT>' ) : ( self . s_ignorexml , None ) , <EOL> ( TABLENS , '<STR_LIT>' ) : ( self . s_table_table_cell , self . e_table_table_cell ) , <EOL> ( TABLENS , '<STR_LIT>' ) : ( self . s_table_table_column , None ) , <EOL> ( TABLENS , '<STR_LIT>' ) : ( self . s_table_table_row , self . e_table_table_row ) , <EOL> ( TABLENS , '<STR_LIT>' ) : ( self . s_table_table , self . e_table_table ) , <EOL> ( TEXTNS , '<STR_LIT:a>' ) : ( self . s_text_a , self . e_text_a ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_x_source , self . e_text_x_source ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_x_source , self . e_text_x_source ) , <EOL> ( TEXTNS , '<STR_LIT>' ) : ( self . s_text_bookmark , None ) , <EOL> ( TEXTNS , '<STR_LIT>' ) : ( self . s_text_bookmark , None ) , <EOL> ( TEXTNS , '<STR_LIT>' ) : ( self . s_text_bookmark_ref , self . e_text_a ) , <EOL> ( TEXTNS , '<STR_LIT>' ) : ( self . s_text_bookmark_ref , None ) , <EOL> ( TEXTNS , '<STR_LIT:h>' ) : ( self . s_text_h , self . e_text_h ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_x_source , self . e_text_x_source ) , <EOL> ( TEXTNS , '<STR_LIT>' ) : ( self . s_text_line_break , None ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( TEXTNS , "<STR_LIT:list>" ) : ( self . s_text_list , self . e_text_list ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_list_item , self . e_text_list_item ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_list_level_style_bullet , self . e_text_list_level_style_bullet ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_list_level_style_number , self . e_text_list_level_style_number ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( None , None ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_note , None ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_note_body , self . e_text_note_body ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( None , self . e_text_note_citation ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_x_source , self . e_text_x_source ) , <EOL> ( TEXTNS , '<STR_LIT:p>' ) : ( self . s_text_p , self . e_text_p ) , <EOL> ( TEXTNS , '<STR_LIT:s>' ) : ( self . s_text_s , None ) , <EOL> ( TEXTNS , '<STR_LIT>' ) : ( self . s_text_span , self . e_text_span ) , <EOL> ( TEXTNS , '<STR_LIT>' ) : ( self . s_text_tab , None ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_x_source , self . e_text_x_source ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_x_source , self . e_text_x_source ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_x_source , self . e_text_x_source ) , <EOL> } <EOL> if embedable : <EOL> self . make_embedable ( ) <EOL> self . _resetobject ( ) <EOL> def set_plain ( self ) : <EOL> """<STR_LIT>""" <EOL> self . generate_css = False <EOL> def set_embedable ( self ) : <EOL> """<STR_LIT>""" <EOL> self . elements [ ( OFFICENS , "<STR_LIT:text>" ) ] = ( None , None ) <EOL> self . elements [ ( OFFICENS , "<STR_LIT>" ) ] = ( None , None ) <EOL> self . elements [ ( OFFICENS , "<STR_LIT>" ) ] = ( None , None ) <EOL> self . elements [ ( OFFICENS , "<STR_LIT>" ) ] = ( None , None ) <EOL> def add_style_file ( self , stylefilename , media = None ) : <EOL> """<STR_LIT>""" <EOL> self . use_internal_css = False <EOL> self . stylefilename = stylefilename <EOL> if media : <EOL> self . metatags . append ( '<STR_LIT>' % ( stylefilename , media ) ) <EOL> else : <EOL> self . metatags . append ( '<STR_LIT>' % ( stylefilename ) ) <EOL> def _resetfootnotes ( self ) : <EOL> self . notedict = { } <EOL> self . currentnote = <NUM_LIT:0> <EOL> self . notebody = '<STR_LIT>' <EOL> def _resetobject ( self ) : <EOL> self . lines = [ ] <EOL> self . _wfunc = self . _wlines <EOL> self . xmlfile = '<STR_LIT>' <EOL> self . title = '<STR_LIT>' <EOL> self . language = '<STR_LIT>' <EOL> self . creator = '<STR_LIT>' <EOL> self . data = [ ] <EOL> self . tagstack = TagStack ( ) <EOL> self . htmlstack = [ ] <EOL> self . pstack = [ ] <EOL> self . processelem = True <EOL> self . processcont = True <EOL> self . listtypes = { } <EOL> self . headinglevels = [ <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> self . use_internal_css = True <EOL> self . cs = StyleToCSS ( ) <EOL> self . anchors = { } <EOL> self . stylestack = [ ] <EOL> self . styledict = { } <EOL> self . currentstyle = None <EOL> self . _resetfootnotes ( ) <EOL> self . metatags = [ ] <EOL> def writeout ( self , s ) : <EOL> if s != '<STR_LIT>' : <EOL> self . _wfunc ( s ) <EOL> def writedata ( self ) : <EOL> d = '<STR_LIT>' . join ( self . data ) <EOL> if d != '<STR_LIT>' : <EOL> self . writeout ( escape ( d ) ) <EOL> def opentag ( self , tag , attrs = { } , block = False ) : <EOL> """<STR_LIT>""" <EOL> self . htmlstack . append ( ( tag , attrs , block ) ) <EOL> a = [ ] <EOL> for key , val in list ( attrs . items ( ) ) : <EOL> a . append ( '''<STR_LIT>''' % ( key , quoteattr ( val ) ) ) <EOL> if len ( a ) == <NUM_LIT:0> : <EOL> self . writeout ( "<STR_LIT>" % tag ) <EOL> else : <EOL> self . writeout ( "<STR_LIT>" % ( tag , "<STR_LIT:U+0020>" . join ( a ) ) ) <EOL> if block == True : <EOL> self . writeout ( "<STR_LIT:\n>" ) <EOL> def closetag ( self , tag , block = True ) : <EOL> """<STR_LIT>""" <EOL> self . htmlstack . pop ( ) <EOL> self . writeout ( "<STR_LIT>" % tag ) <EOL> if block == True : <EOL> self . writeout ( "<STR_LIT:\n>" ) <EOL> def emptytag ( self , tag , attrs = { } ) : <EOL> a = [ ] <EOL> for key , val in list ( attrs . items ( ) ) : <EOL> a . append ( '''<STR_LIT>''' % ( key , quoteattr ( val ) ) ) <EOL> self . writeout ( "<STR_LIT>" % ( tag , "<STR_LIT:U+0020>" . join ( a ) ) ) <EOL> def characters ( self , data ) : <EOL> if self . processelem and self . processcont : <EOL> self . data . append ( data ) <EOL> def startElementNS ( self , tag , qname , attrs ) : <EOL> self . pstack . append ( ( self . processelem , self . processcont ) ) <EOL> if self . processelem : <EOL> method = self . elements . get ( tag , ( None , None ) ) [ <NUM_LIT:0> ] <EOL> if method : <EOL> self . handle_starttag ( tag , method , attrs ) <EOL> else : <EOL> self . unknown_starttag ( tag , attrs ) <EOL> self . tagstack . push ( tag , attrs ) <EOL> def endElementNS ( self , tag , qname ) : <EOL> stag , attrs = self . tagstack . pop ( ) <EOL> if self . processelem : <EOL> method = self . elements . get ( tag , ( None , None ) ) [ <NUM_LIT:1> ] <EOL> if method : <EOL> self . handle_endtag ( tag , attrs , method ) <EOL> else : <EOL> self . unknown_endtag ( tag , attrs ) <EOL> self . processelem , self . processcont = self . pstack . pop ( ) <EOL> def handle_starttag ( self , tag , method , attrs ) : <EOL> method ( tag , attrs ) <EOL> def handle_endtag ( self , tag , attrs , method ) : <EOL> method ( tag , attrs ) <EOL> def unknown_starttag ( self , tag , attrs ) : <EOL> pass <EOL> def unknown_endtag ( self , tag , attrs ) : <EOL> pass <EOL> def s_ignorexml ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . processelem = False <EOL> def s_ignorecont ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . processcont = False <EOL> def s_processcont ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . processcont = True <EOL> def classname ( self , attrs ) : <EOL> """<STR_LIT>""" <EOL> c = attrs . get ( ( TEXTNS , '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> c = c . replace ( "<STR_LIT:.>" , "<STR_LIT:_>" ) <EOL> return c <EOL> def get_anchor ( self , name ) : <EOL> """<STR_LIT>""" <EOL> if name not in self . anchors : <EOL> self . anchors [ name ] = "<STR_LIT>" % ( len ( self . anchors ) + <NUM_LIT:1> ) <EOL> return self . anchors . get ( name ) <EOL> def purgedata ( self ) : <EOL> self . data = [ ] <EOL> def e_dc_title ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . title = '<STR_LIT>' . join ( self . data ) <EOL> self . data = [ ] <EOL> def e_dc_metatag ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . metatags . append ( '<STR_LIT>' % ( tag [ <NUM_LIT:1> ] , quoteattr ( '<STR_LIT>' . join ( self . data ) ) ) ) <EOL> self . data = [ ] <EOL> def e_dc_contentlanguage ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . language = '<STR_LIT>' . join ( self . data ) <EOL> self . metatags . append ( '<STR_LIT>' % escape ( self . language ) ) <EOL> self . data = [ ] <EOL> def e_dc_creator ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . creator = '<STR_LIT>' . join ( self . data ) <EOL> self . metatags . append ( '<STR_LIT>' % escape ( self . creator ) ) <EOL> self . data = [ ] <EOL> def s_custom_shape ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> anchor_type = attrs . get ( ( TEXTNS , '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> htmltag = '<STR_LIT>' <EOL> name = "<STR_LIT>" + attrs . get ( ( DRAWNS , '<STR_LIT>' ) , "<STR_LIT>" ) <EOL> if name == '<STR_LIT>' : <EOL> name = "<STR_LIT>" + attrs . get ( ( PRESENTATIONNS , '<STR_LIT>' ) , "<STR_LIT>" ) <EOL> name = name . replace ( "<STR_LIT:.>" , "<STR_LIT:_>" ) <EOL> if anchor_type == "<STR_LIT>" : <EOL> style = '<STR_LIT>' <EOL> elif anchor_type == '<STR_LIT>' : <EOL> style = "<STR_LIT>" <EOL> elif anchor_type == '<STR_LIT>' : <EOL> htmltag = '<STR_LIT>' <EOL> style = '<STR_LIT>' <EOL> else : <EOL> style = "<STR_LIT>" <EOL> if ( SVGNS , "<STR_LIT:width>" ) in attrs : <EOL> style = style + "<STR_LIT>" + attrs [ ( SVGNS , "<STR_LIT:width>" ) ] + "<STR_LIT:;>" <EOL> if ( SVGNS , "<STR_LIT>" ) in attrs : <EOL> style = style + "<STR_LIT>" + attrs [ ( SVGNS , "<STR_LIT>" ) ] + "<STR_LIT:;>" <EOL> if ( SVGNS , "<STR_LIT:x>" ) in attrs : <EOL> style = style + "<STR_LIT>" + attrs [ ( SVGNS , "<STR_LIT:x>" ) ] + "<STR_LIT:;>" <EOL> if ( SVGNS , "<STR_LIT:y>" ) in attrs : <EOL> style = style + "<STR_LIT>" + attrs [ ( SVGNS , "<STR_LIT:y>" ) ] + "<STR_LIT:;>" <EOL> if self . generate_css : <EOL> self . opentag ( htmltag , { '<STR_LIT:class>' : name , '<STR_LIT>' : style } ) <EOL> else : <EOL> self . opentag ( htmltag ) <EOL> def e_custom_shape ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . closetag ( '<STR_LIT>' ) <EOL> def s_draw_frame ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> anchor_type = attrs . get ( ( TEXTNS , '<STR_LIT>' ) , '<STR_LIT>' ) <EOL> htmltag = '<STR_LIT>' <EOL> name = "<STR_LIT>" + attrs . get ( ( DRAWNS , '<STR_LIT>' ) , "<STR_LIT>" ) <EOL> if name == '<STR_LIT>' : <EOL> name = "<STR_LIT>" + attrs . get ( ( PRESENTATIONNS , '<STR_LIT>' ) , "<STR_LIT>" ) <EOL> name = name . replace ( "<STR_LIT:.>" , "<STR_LIT:_>" ) <EOL> if anchor_type == "<STR_LIT>" : <EOL> style = '<STR_LIT>' <EOL> elif anchor_type == '<STR_LIT>' : <EOL> style = "<STR_LIT>" <EOL> elif anchor_type == '<STR_LIT>' : <EOL> htmltag = '<STR_LIT>' <EOL> style = '<STR_LIT>' <EOL> else : <EOL> style = "<STR_LIT>" <EOL> if ( SVGNS , "<STR_LIT:width>" ) in attrs : <EOL> style = style + "<STR_LIT>" + attrs [ ( SVGNS , "<STR_LIT:width>" ) ] + "<STR_LIT:;>" <EOL> if ( SVGNS , "<STR_LIT>" ) in attrs : <EOL> style = style + "<STR_LIT>" + attrs [ ( SVGNS , "<STR_LIT>" ) ] + "<STR_LIT:;>" <EOL> if ( SVGNS , "<STR_LIT:x>" ) in attrs : <EOL> style = style + "<STR_LIT>" + attrs [ ( SVGNS , "<STR_LIT:x>" ) ] + "<STR_LIT:;>" <EOL> if ( SVGNS , "<STR_LIT:y>" ) in attrs : <EOL> style = style + "<STR_LIT>" + attrs [ ( SVGNS , "<STR_LIT:y>" ) ] + "<STR_LIT:;>" <EOL> if self . generate_css : <EOL> self . opentag ( htmltag , { '<STR_LIT:class>' : name , '<STR_LIT>' : style } ) <EOL> else : <EOL> self . opentag ( htmltag ) <EOL> def e_draw_frame ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . closetag ( '<STR_LIT>' ) <EOL> def s_draw_fill_image ( self , tag , attrs ) : <EOL> name = attrs . get ( ( DRAWNS , '<STR_LIT:name>' ) , "<STR_LIT>" ) <EOL> imghref = attrs [ ( XLINKNS , "<STR_LIT>" ) ] <EOL> imghref = self . rewritelink ( imghref ) <EOL> self . cs . fillimages [ name ] = imghref <EOL> def rewritelink ( self , imghref ) : <EOL> """<STR_LIT>""" <EOL> return imghref <EOL> def s_draw_image ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> parent = self . tagstack . stackparent ( ) <EOL> anchor_type = parent . get ( ( TEXTNS , '<STR_LIT>' ) ) <EOL> imghref = attrs [ ( XLINKNS , "<STR_LIT>" ) ] <EOL> imghref = self . rewritelink ( imghref ) <EOL> htmlattrs = { '<STR_LIT>' : "<STR_LIT>" , '<STR_LIT:src>' : imghref } <EOL> if self . generate_css : <EOL> if anchor_type != "<STR_LIT>" : <EOL> htmlattrs [ '<STR_LIT>' ] = "<STR_LIT>" <EOL> self . emptytag ( '<STR_LIT>' , htmlattrs ) <EOL> def s_draw_object ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> objhref = attrs [ ( XLINKNS , "<STR_LIT>" ) ] <EOL> for c in self . document . childnodes : <EOL> if c . folder == objhref : <EOL> self . _walknode ( c . topnode ) <EOL> def s_draw_object_ole ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> class_id = attrs [ ( DRAWNS , "<STR_LIT>" ) ] <EOL> if class_id and class_id . lower ( ) == "<STR_LIT>" : <EOL> tagattrs = { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT:class>' : '<STR_LIT>' } <EOL> self . opentag ( '<STR_LIT:a>' , tagattrs ) <EOL> self . closetag ( '<STR_LIT:a>' , tagattrs ) <EOL> def s_draw_page ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> name = attrs . get ( ( DRAWNS , '<STR_LIT:name>' ) , "<STR_LIT>" ) <EOL> stylename = attrs . get ( ( DRAWNS , '<STR_LIT>' ) , "<STR_LIT>" ) <EOL> stylename = stylename . replace ( "<STR_LIT:.>" , "<STR_LIT:_>" ) <EOL> masterpage = attrs . get ( ( DRAWNS , '<STR_LIT>' ) , "<STR_LIT>" ) <EOL> masterpage = masterpage . replace ( "<STR_LIT:.>" , "<STR_LIT:_>" ) <EOL> if self . generate_css : <EOL> self . opentag ( '<STR_LIT>' , { '<STR_LIT:class>' : "<STR_LIT>" % ( stylename , masterpage ) } ) <EOL> else : <EOL> self . opentag ( '<STR_LIT>' ) <EOL> self . opentag ( '<STR_LIT>' ) <EOL> self . writeout ( escape ( name ) ) <EOL> self . closetag ( '<STR_LIT>' ) <EOL> def e_draw_page ( self , tag , attrs ) : <EOL> self . closetag ( '<STR_LIT>' ) <EOL> def s_draw_textbox ( self , tag , attrs ) : <EOL> style = '<STR_LIT>' <EOL> if ( FONS , "<STR_LIT>" ) in attrs : <EOL> style = style + "<STR_LIT>" + attrs [ ( FONS , "<STR_LIT>" ) ] + "<STR_LIT:;>" <EOL> self . opentag ( '<STR_LIT>' ) <EOL> def e_draw_textbox ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . closetag ( '<STR_LIT>' ) <EOL> def html_body ( self , tag , attrs ) : <EOL> self . writedata ( ) <EOL> if self . generate_css and self . use_internal_css : <EOL> self . opentag ( '<STR_LIT>' , { '<STR_LIT:type>' : "<STR_LIT>" } , True ) <EOL> self . writeout ( '<STR_LIT>' ) <EOL> self . generate_stylesheet ( ) <EOL> self . writeout ( '<STR_LIT>' ) <EOL> self . closetag ( '<STR_LIT>' ) <EOL> self . purgedata ( ) <EOL> self . closetag ( '<STR_LIT>' ) <EOL> self . opentag ( '<STR_LIT:body>' , block = True ) <EOL> default_styles = """<STR_LIT>""" <EOL> def generate_stylesheet ( self ) : <EOL> for name in self . stylestack : <EOL> styles = self . styledict . get ( name ) <EOL> if '<STR_LIT>' in styles and styles [ '<STR_LIT>' ] in self . styledict : <EOL> familystyle = self . styledict [ styles [ '<STR_LIT>' ] ] . copy ( ) <EOL> del styles [ '<STR_LIT>' ] <EOL> for style , val in list ( styles . items ( ) ) : <EOL> familystyle [ style ] = val <EOL> styles = familystyle <EOL> while '<STR_LIT>' in styles and styles [ '<STR_LIT>' ] in self . styledict : <EOL> parentstyle = self . styledict [ styles [ '<STR_LIT>' ] ] . copy ( ) <EOL> del styles [ '<STR_LIT>' ] <EOL> for style , val in list ( styles . items ( ) ) : <EOL> parentstyle [ style ] = val <EOL> styles = parentstyle <EOL> self . styledict [ name ] = styles <EOL> self . writeout ( self . default_styles ) <EOL> for name in self . stylestack : <EOL> styles = self . styledict . get ( name ) <EOL> css2 = self . cs . convert_styles ( styles ) <EOL> self . writeout ( "<STR_LIT>" % name ) <EOL> for style , val in list ( css2 . items ( ) ) : <EOL> self . writeout ( "<STR_LIT>" % ( style , val ) ) <EOL> self . writeout ( "<STR_LIT>" ) <EOL> def generate_footnotes ( self ) : <EOL> if self . currentnote == <NUM_LIT:0> : <EOL> return <EOL> if self . generate_css : <EOL> self . opentag ( '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' } , True ) <EOL> else : <EOL> self . opentag ( '<STR_LIT>' ) <EOL> for key in range ( <NUM_LIT:1> , self . currentnote + <NUM_LIT:1> ) : <EOL> note = self . notedict [ key ] <EOL> self . opentag ( '<STR_LIT>' , { '<STR_LIT:id>' : "<STR_LIT>" % key } ) <EOL> self . writeout ( note [ '<STR_LIT:body>' ] ) <EOL> self . closetag ( '<STR_LIT>' ) <EOL> self . closetag ( '<STR_LIT>' ) <EOL> def s_office_automatic_styles ( self , tag , attrs ) : <EOL> if self . xmlfile == '<STR_LIT>' : <EOL> self . autoprefix = "<STR_LIT:A>" <EOL> else : <EOL> self . autoprefix = "<STR_LIT>" <EOL> def s_office_document_content ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . writeout ( '<STR_LIT>' ) <EOL> self . writeout ( '<STR_LIT>' ) <EOL> self . opentag ( '<STR_LIT:html>' , { '<STR_LIT>' : "<STR_LIT>" } , True ) <EOL> self . opentag ( '<STR_LIT>' , block = True ) <EOL> self . emptytag ( '<STR_LIT>' , { '<STR_LIT>' : "<STR_LIT:Content-Type>" , '<STR_LIT:content>' : "<STR_LIT>" } ) <EOL> for metaline in self . metatags : <EOL> self . writeout ( metaline ) <EOL> self . writeout ( '<STR_LIT>' % escape ( self . title ) ) <EOL> def e_office_document_content ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . closetag ( '<STR_LIT:html>' ) <EOL> def s_office_master_styles ( self , tag , attrs ) : <EOL> """<STR_LIT:U+0020>""" <EOL> def s_office_presentation ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . styledict [ '<STR_LIT:p>' ] = { ( FONS , '<STR_LIT>' ) : "<STR_LIT>" } <EOL> self . styledict [ '<STR_LIT>' ] = { ( FONS , '<STR_LIT>' ) : "<STR_LIT>" } <EOL> self . html_body ( tag , attrs ) <EOL> def e_office_presentation ( self , tag , attrs ) : <EOL> self . generate_footnotes ( ) <EOL> self . closetag ( '<STR_LIT:body>' ) <EOL> def s_office_spreadsheet ( self , tag , attrs ) : <EOL> self . html_body ( tag , attrs ) <EOL> def e_office_spreadsheet ( self , tag , attrs ) : <EOL> self . generate_footnotes ( ) <EOL> self . closetag ( '<STR_LIT:body>' ) <EOL> def s_office_styles ( self , tag , attrs ) : <EOL> self . autoprefix = "<STR_LIT>" <EOL> def s_office_text ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . styledict [ '<STR_LIT>' ] = { ( STYLENS , '<STR_LIT>' ) : '<STR_LIT>' } <EOL> self . html_body ( tag , attrs ) <EOL> def e_office_text ( self , tag , attrs ) : <EOL> self . generate_footnotes ( ) <EOL> self . closetag ( '<STR_LIT:body>' ) <EOL> def s_style_handle_properties ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> for key , attr in list ( attrs . items ( ) ) : <EOL> self . styledict [ self . currentstyle ] [ key ] = attr <EOL> familymap = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:p>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:text>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } <EOL> def s_style_default_style ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> family = attrs [ ( STYLENS , '<STR_LIT>' ) ] <EOL> htmlfamily = self . familymap . get ( family , '<STR_LIT>' ) <EOL> self . currentstyle = htmlfamily <EOL> self . styledict [ self . currentstyle ] = { } <EOL> def e_style_default_style ( self , tag , attrs ) : <EOL> self . currentstyle = None <EOL> def s_style_font_face ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> name = attrs [ ( STYLENS , "<STR_LIT:name>" ) ] <EOL> family = attrs [ ( SVGNS , "<STR_LIT>" ) ] <EOL> generic = attrs . get ( ( STYLENS , '<STR_LIT>' ) , "<STR_LIT>" ) <EOL> self . cs . save_font ( name , family , generic ) <EOL> def s_style_footer ( self , tag , attrs ) : <EOL> self . opentag ( '<STR_LIT>' , { '<STR_LIT:id>' : "<STR_LIT>" } ) <EOL> self . purgedata ( ) <EOL> def e_style_footer ( self , tag , attrs ) : <EOL> self . writedata ( ) <EOL> self . closetag ( '<STR_LIT>' ) <EOL> self . purgedata ( ) <EOL> def s_style_footer_style ( self , tag , attrs ) : <EOL> self . currentstyle = "<STR_LIT>" <EOL> self . stylestack . append ( self . currentstyle ) <EOL> self . styledict [ self . currentstyle ] = { } <EOL> def s_style_header ( self , tag , attrs ) : <EOL> self . opentag ( '<STR_LIT>' , { '<STR_LIT:id>' : "<STR_LIT>" } ) <EOL> self . purgedata ( ) <EOL> def e_style_header ( self , tag , attrs ) : <EOL> self . writedata ( ) <EOL> self . closetag ( '<STR_LIT>' ) <EOL> self . purgedata ( ) <EOL> def s_style_header_style ( self , tag , attrs ) : <EOL> self . currentstyle = "<STR_LIT>" <EOL> self . stylestack . append ( self . currentstyle ) <EOL> self . styledict [ self . currentstyle ] = { } <EOL> def s_style_default_page_layout ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . currentstyle = "<STR_LIT>" <EOL> self . stylestack . append ( self . currentstyle ) <EOL> self . styledict [ self . currentstyle ] = { } <EOL> def s_style_page_layout ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> name = attrs [ ( STYLENS , '<STR_LIT:name>' ) ] <EOL> name = name . replace ( "<STR_LIT:.>" , "<STR_LIT:_>" ) <EOL> self . currentstyle = "<STR_LIT>" + name <EOL> self . stylestack . append ( self . currentstyle ) <EOL> self . styledict [ self . currentstyle ] = { } <EOL> def e_style_page_layout ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . currentstyle = None <EOL> def s_style_master_page ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> name = attrs [ ( STYLENS , '<STR_LIT:name>' ) ] <EOL> name = name . replace ( "<STR_LIT:.>" , "<STR_LIT:_>" ) <EOL> self . currentstyle = "<STR_LIT>" + name <EOL> self . stylestack . append ( self . currentstyle ) <EOL> self . styledict [ self . currentstyle ] = { ( '<STR_LIT>' , '<STR_LIT>' ) : '<STR_LIT>' } <EOL> pagelayout = attrs . get ( ( STYLENS , '<STR_LIT>' ) , None ) <EOL> if pagelayout : <EOL> pagelayout = "<STR_LIT>" + pagelayout <EOL> if pagelayout in self . styledict : <EOL> styles = self . styledict [ pagelayout ] <EOL> for style , val in list ( styles . items ( ) ) : <EOL> self . styledict [ self . currentstyle ] [ style ] = val <EOL> else : <EOL> self . styledict [ self . currentstyle ] [ '<STR_LIT>' ] = pagelayout <EOL> self . s_ignorexml ( tag , attrs ) <EOL> _familyshort = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT:P>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:text>' : '<STR_LIT:S>' , '<STR_LIT>' : '<STR_LIT:D>' , <EOL> '<STR_LIT>' : '<STR_LIT:T>' , '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } <EOL> def s_style_style ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> name = attrs [ ( STYLENS , '<STR_LIT:name>' ) ] <EOL> name = name . replace ( "<STR_LIT:.>" , "<STR_LIT:_>" ) <EOL> family = attrs [ ( STYLENS , '<STR_LIT>' ) ] <EOL> htmlfamily = self . familymap . get ( family , '<STR_LIT>' ) <EOL> sfamily = self . _familyshort . get ( family , '<STR_LIT:X>' ) <EOL> name = "<STR_LIT>" % ( self . autoprefix , sfamily , name ) <EOL> parent = attrs . get ( ( STYLENS , '<STR_LIT>' ) ) <EOL> self . currentstyle = special_styles . get ( name , "<STR_LIT:.>" + name ) <EOL> self . stylestack . append ( self . currentstyle ) <EOL> if self . currentstyle not in self . styledict : <EOL> self . styledict [ self . currentstyle ] = { } <EOL> self . styledict [ self . currentstyle ] [ '<STR_LIT>' ] = htmlfamily <EOL> if parent : <EOL> parent = "<STR_LIT>" % ( sfamily , parent ) <EOL> parent = special_styles . get ( parent , "<STR_LIT:.>" + parent ) <EOL> if parent in self . styledict : <EOL> styles = self . styledict [ parent ] <EOL> for style , val in list ( styles . items ( ) ) : <EOL> self . styledict [ self . currentstyle ] [ style ] = val <EOL> else : <EOL> self . styledict [ self . currentstyle ] [ '<STR_LIT>' ] = parent <EOL> def e_style_style ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . currentstyle = None <EOL> def s_table_table ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> c = attrs . get ( ( TABLENS , '<STR_LIT>' ) , None ) <EOL> if c and self . generate_css : <EOL> c = c . replace ( "<STR_LIT:.>" , "<STR_LIT:_>" ) <EOL> self . opentag ( '<STR_LIT>' , { '<STR_LIT:class>' : "<STR_LIT>" % c } ) <EOL> else : <EOL> self . opentag ( '<STR_LIT>' ) <EOL> self . purgedata ( ) <EOL> def e_table_table ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . writedata ( ) <EOL> self . closetag ( '<STR_LIT>' ) <EOL> self . purgedata ( ) <EOL> def s_table_table_cell ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> htmlattrs = { } <EOL> rowspan = attrs . get ( ( TABLENS , '<STR_LIT>' ) ) <EOL> if rowspan : <EOL> htmlattrs [ '<STR_LIT>' ] = rowspan <EOL> colspan = attrs . get ( ( TABLENS , '<STR_LIT>' ) ) <EOL> if colspan : <EOL> htmlattrs [ '<STR_LIT>' ] = colspan <EOL> c = attrs . get ( ( TABLENS , '<STR_LIT>' ) ) <EOL> if c : <EOL> htmlattrs [ '<STR_LIT:class>' ] = '<STR_LIT>' % c . replace ( "<STR_LIT:.>" , "<STR_LIT:_>" ) <EOL> self . opentag ( '<STR_LIT>' , htmlattrs ) <EOL> self . purgedata ( ) <EOL> def e_table_table_cell ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . writedata ( ) <EOL> self . closetag ( '<STR_LIT>' ) <EOL> self . purgedata ( ) <EOL> def s_table_table_column ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> c = attrs . get ( ( TABLENS , '<STR_LIT>' ) , None ) <EOL> repeated = int ( attrs . get ( ( TABLENS , '<STR_LIT>' ) , <NUM_LIT:1> ) ) <EOL> htmlattrs = { } <EOL> if c : <EOL> htmlattrs [ '<STR_LIT:class>' ] = "<STR_LIT>" % c . replace ( "<STR_LIT:.>" , "<STR_LIT:_>" ) <EOL> for x in range ( repeated ) : <EOL> self . emptytag ( '<STR_LIT>' , htmlattrs ) <EOL> self . purgedata ( ) <EOL> def s_table_table_row ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> c = attrs . get ( ( TABLENS , '<STR_LIT>' ) , None ) <EOL> htmlattrs = { } <EOL> if c : <EOL> htmlattrs [ '<STR_LIT:class>' ] = "<STR_LIT>" % c . replace ( "<STR_LIT:.>" , "<STR_LIT:_>" ) <EOL> self . opentag ( '<STR_LIT>' , htmlattrs ) <EOL> self . purgedata ( ) <EOL> def e_table_table_row ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . writedata ( ) <EOL> self . closetag ( '<STR_LIT>' ) <EOL> self . purgedata ( ) <EOL> def s_text_a ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . writedata ( ) <EOL> href = attrs [ ( XLINKNS , "<STR_LIT>" ) ] . split ( "<STR_LIT:|>" ) [ <NUM_LIT:0> ] <EOL> if href [ <NUM_LIT:0> ] == "<STR_LIT:#>" : <EOL> href = "<STR_LIT:#>" + self . get_anchor ( href [ <NUM_LIT:1> : ] ) <EOL> self . opentag ( '<STR_LIT:a>' , { '<STR_LIT>' : href } ) <EOL> self . purgedata ( ) <EOL> def e_text_a ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . writedata ( ) <EOL> self . closetag ( '<STR_LIT:a>' , False ) <EOL> self . purgedata ( ) <EOL> def s_text_bookmark ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> name = attrs [ ( TEXTNS , '<STR_LIT:name>' ) ] <EOL> html_id = self . get_anchor ( name ) <EOL> self . writedata ( ) <EOL> self . opentag ( '<STR_LIT>' , { '<STR_LIT:id>' : html_id } ) <EOL> self . closetag ( '<STR_LIT>' , False ) <EOL> self . purgedata ( ) <EOL> def s_text_bookmark_ref ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> name = attrs [ ( TEXTNS , '<STR_LIT>' ) ] <EOL> html_id = "<STR_LIT:#>" + self . get_anchor ( name ) <EOL> self . writedata ( ) <EOL> self . opentag ( '<STR_LIT:a>' , { '<STR_LIT>' : html_id } ) <EOL> self . purgedata ( ) <EOL> def s_text_h ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> level = int ( attrs [ ( TEXTNS , '<STR_LIT>' ) ] ) <EOL> if level > <NUM_LIT:6> : level = <NUM_LIT:6> <EOL> if level < <NUM_LIT:1> : level = <NUM_LIT:1> <EOL> self . headinglevels [ level ] = self . headinglevels [ level ] + <NUM_LIT:1> <EOL> name = self . classname ( attrs ) <EOL> for x in range ( level + <NUM_LIT:1> , <NUM_LIT:10> ) : <EOL> self . headinglevels [ x ] = <NUM_LIT:0> <EOL> special = special_styles . get ( "<STR_LIT>" + name ) <EOL> if special or not self . generate_css : <EOL> self . opentag ( '<STR_LIT>' % level ) <EOL> else : <EOL> self . opentag ( '<STR_LIT>' % level , { '<STR_LIT:class>' : "<STR_LIT>" % name } ) <EOL> self . purgedata ( ) <EOL> def e_text_h ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . writedata ( ) <EOL> level = int ( attrs [ ( TEXTNS , '<STR_LIT>' ) ] ) <EOL> if level > <NUM_LIT:6> : level = <NUM_LIT:6> <EOL> if level < <NUM_LIT:1> : level = <NUM_LIT:1> <EOL> lev = self . headinglevels [ <NUM_LIT:1> : level + <NUM_LIT:1> ] <EOL> outline = '<STR_LIT:.>' . join ( map ( str , lev ) ) <EOL> heading = '<STR_LIT>' . join ( self . data ) <EOL> if self . title == '<STR_LIT>' : self . title = heading <EOL> anchor = self . get_anchor ( "<STR_LIT>" % ( outline , heading ) ) <EOL> self . opentag ( '<STR_LIT:a>' , { '<STR_LIT:id>' : anchor } ) <EOL> self . closetag ( '<STR_LIT:a>' , False ) <EOL> self . closetag ( '<STR_LIT>' % level ) <EOL> self . purgedata ( ) <EOL> def s_text_line_break ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . writedata ( ) <EOL> self . emptytag ( '<STR_LIT>' ) <EOL> self . purgedata ( ) <EOL> def s_text_list ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> name = attrs . get ( ( TEXTNS , '<STR_LIT>' ) ) <EOL> level = self . tagstack . count_tags ( tag ) + <NUM_LIT:1> <EOL> if name : <EOL> name = name . replace ( "<STR_LIT:.>" , "<STR_LIT:_>" ) <EOL> else : <EOL> name = self . tagstack . rfindattr ( ( TEXTNS , '<STR_LIT>' ) ) <EOL> list_class = "<STR_LIT>" % ( name , level ) <EOL> if self . generate_css : <EOL> self . opentag ( '<STR_LIT:%s>' % self . listtypes . get ( list_class , '<STR_LIT>' ) , { '<STR_LIT:class>' : list_class } ) <EOL> else : <EOL> self . opentag ( '<STR_LIT:%s>' % self . listtypes . get ( list_class , '<STR_LIT>' ) ) <EOL> self . purgedata ( ) <EOL> def e_text_list ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . writedata ( ) <EOL> name = attrs . get ( ( TEXTNS , '<STR_LIT>' ) ) <EOL> level = self . tagstack . count_tags ( tag ) + <NUM_LIT:1> <EOL> if name : <EOL> name = name . replace ( "<STR_LIT:.>" , "<STR_LIT:_>" ) <EOL> else : <EOL> name = self . tagstack . rfindattr ( ( TEXTNS , '<STR_LIT>' ) ) <EOL> list_class = "<STR_LIT>" % ( name , level ) <EOL> self . closetag ( self . listtypes . get ( list_class , '<STR_LIT>' ) ) <EOL> self . purgedata ( ) <EOL> def s_text_list_item ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . opentag ( '<STR_LIT>' ) <EOL> self . purgedata ( ) <EOL> def e_text_list_item ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . writedata ( ) <EOL> self . closetag ( '<STR_LIT>' ) <EOL> self . purgedata ( ) <EOL> def s_text_list_level_style_bullet ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> name = self . tagstack . rfindattr ( ( STYLENS , '<STR_LIT:name>' ) ) <EOL> level = attrs [ ( TEXTNS , '<STR_LIT>' ) ] <EOL> self . prevstyle = self . currentstyle <EOL> list_class = "<STR_LIT>" % ( name , level ) <EOL> self . listtypes [ list_class ] = '<STR_LIT>' <EOL> self . currentstyle = "<STR_LIT>" % ( name . replace ( "<STR_LIT:.>" , "<STR_LIT:_>" ) , level ) <EOL> self . stylestack . append ( self . currentstyle ) <EOL> self . styledict [ self . currentstyle ] = { } <EOL> level = int ( level ) <EOL> listtype = ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) [ level % <NUM_LIT:3> ] <EOL> self . styledict [ self . currentstyle ] [ ( '<STR_LIT>' , '<STR_LIT>' ) ] = listtype <EOL> def e_text_list_level_style_bullet ( self , tag , attrs ) : <EOL> self . currentstyle = self . prevstyle <EOL> del self . prevstyle <EOL> def s_text_list_level_style_number ( self , tag , attrs ) : <EOL> name = self . tagstack . stackparent ( ) [ ( STYLENS , '<STR_LIT:name>' ) ] <EOL> level = attrs [ ( TEXTNS , '<STR_LIT>' ) ] <EOL> num_format = attrs . get ( ( STYLENS , '<STR_LIT:name>' ) , "<STR_LIT:1>" ) <EOL> list_class = "<STR_LIT>" % ( name , level ) <EOL> self . prevstyle = self . currentstyle <EOL> self . currentstyle = "<STR_LIT>" % ( name . replace ( "<STR_LIT:.>" , "<STR_LIT:_>" ) , level ) <EOL> self . listtypes [ list_class ] = '<STR_LIT>' <EOL> self . stylestack . append ( self . currentstyle ) <EOL> self . styledict [ self . currentstyle ] = { } <EOL> if num_format == "<STR_LIT:1>" : listtype = "<STR_LIT>" <EOL> elif num_format == "<STR_LIT:I>" : listtype = "<STR_LIT>" <EOL> elif num_format == "<STR_LIT:i>" : listtype = "<STR_LIT>" <EOL> elif num_format == "<STR_LIT:A>" : listtype = "<STR_LIT>" <EOL> elif num_format == "<STR_LIT:a>" : listtype = "<STR_LIT>" <EOL> else : listtype = "<STR_LIT>" <EOL> self . styledict [ self . currentstyle ] [ ( '<STR_LIT>' , '<STR_LIT>' ) ] = listtype <EOL> def e_text_list_level_style_number ( self , tag , attrs ) : <EOL> self . currentstyle = self . prevstyle <EOL> del self . prevstyle <EOL> def s_text_note ( self , tag , attrs ) : <EOL> self . writedata ( ) <EOL> self . purgedata ( ) <EOL> self . currentnote = self . currentnote + <NUM_LIT:1> <EOL> self . notedict [ self . currentnote ] = { } <EOL> self . notebody = [ ] <EOL> def e_text_note ( self , tag , attrs ) : <EOL> pass <EOL> def collectnote ( self , s ) : <EOL> if s != '<STR_LIT>' : <EOL> self . notebody . append ( s ) <EOL> def s_text_note_body ( self , tag , attrs ) : <EOL> self . _orgwfunc = self . _wfunc <EOL> self . _wfunc = self . collectnote <EOL> def e_text_note_body ( self , tag , attrs ) : <EOL> self . _wfunc = self . _orgwfunc <EOL> self . notedict [ self . currentnote ] [ '<STR_LIT:body>' ] = '<STR_LIT>' . join ( self . notebody ) <EOL> self . notebody = '<STR_LIT>' <EOL> del self . _orgwfunc <EOL> def e_text_note_citation ( self , tag , attrs ) : <EOL> mark = '<STR_LIT>' . join ( self . data ) <EOL> self . notedict [ self . currentnote ] [ '<STR_LIT>' ] = mark <EOL> self . opentag ( '<STR_LIT:a>' , { '<STR_LIT>' : "<STR_LIT>" % self . currentnote } ) <EOL> self . opentag ( '<STR_LIT>' ) <EOL> self . writeout ( str ( self . currentnote ) ) <EOL> self . closetag ( '<STR_LIT>' ) <EOL> self . closetag ( '<STR_LIT:a>' ) <EOL> def s_text_p ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> htmlattrs = { } <EOL> specialtag = "<STR_LIT:p>" <EOL> c = attrs . get ( ( TEXTNS , '<STR_LIT>' ) , None ) <EOL> if c : <EOL> c = c . replace ( "<STR_LIT:.>" , "<STR_LIT:_>" ) <EOL> specialtag = special_styles . get ( "<STR_LIT>" + c ) <EOL> if specialtag is None : <EOL> specialtag = '<STR_LIT:p>' <EOL> if self . generate_css : <EOL> htmlattrs [ '<STR_LIT:class>' ] = "<STR_LIT>" % c <EOL> self . opentag ( specialtag , htmlattrs ) <EOL> self . purgedata ( ) <EOL> def e_text_p ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> specialtag = "<STR_LIT:p>" <EOL> c = attrs . get ( ( TEXTNS , '<STR_LIT>' ) , None ) <EOL> if c : <EOL> c = c . replace ( "<STR_LIT:.>" , "<STR_LIT:_>" ) <EOL> specialtag = special_styles . get ( "<STR_LIT>" + c ) <EOL> if specialtag is None : <EOL> specialtag = '<STR_LIT:p>' <EOL> self . writedata ( ) <EOL> self . closetag ( specialtag ) <EOL> self . purgedata ( ) <EOL> def s_text_s ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> c = attrs . get ( ( TEXTNS , '<STR_LIT:c>' ) , "<STR_LIT:1>" ) <EOL> for x in range ( int ( c ) ) : <EOL> self . writeout ( '<STR_LIT>' ) <EOL> def s_text_span ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . writedata ( ) <EOL> c = attrs . get ( ( TEXTNS , '<STR_LIT>' ) , None ) <EOL> htmlattrs = { } <EOL> if c : <EOL> c = c . replace ( "<STR_LIT:.>" , "<STR_LIT:_>" ) <EOL> special = special_styles . get ( "<STR_LIT>" + c ) <EOL> if special is None and self . generate_css : <EOL> htmlattrs [ '<STR_LIT:class>' ] = "<STR_LIT>" % c <EOL> self . opentag ( '<STR_LIT>' , htmlattrs ) <EOL> self . purgedata ( ) <EOL> def e_text_span ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . writedata ( ) <EOL> self . closetag ( '<STR_LIT>' , False ) <EOL> self . purgedata ( ) <EOL> def s_text_tab ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . writedata ( ) <EOL> self . writeout ( '<STR_LIT:U+0020>' ) <EOL> self . purgedata ( ) <EOL> def s_text_x_source ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . writedata ( ) <EOL> self . purgedata ( ) <EOL> self . s_ignorexml ( tag , attrs ) <EOL> def e_text_x_source ( self , tag , attrs ) : <EOL> """<STR_LIT>""" <EOL> self . writedata ( ) <EOL> self . purgedata ( ) <EOL> def load ( self , odffile ) : <EOL> """<STR_LIT>""" <EOL> self . lines = [ ] <EOL> self . _wfunc = self . _wlines <EOL> if isinstance ( odffile , str ) : <EOL> self . document = load ( odffile ) <EOL> else : <EOL> self . document = odffile <EOL> self . _walknode ( self . document . topnode ) <EOL> def _walknode ( self , node ) : <EOL> if node . nodeType == Node . ELEMENT_NODE : <EOL> self . startElementNS ( node . qname , node . tagName , node . attributes ) <EOL> for c in node . childNodes : <EOL> self . _walknode ( c ) <EOL> self . endElementNS ( node . qname , node . tagName ) <EOL> if node . nodeType == Node . TEXT_NODE or node . nodeType == Node . CDATA_SECTION_NODE : <EOL> self . characters ( str ( node ) ) <EOL> def odf2xhtml ( self , odffile ) : <EOL> """<STR_LIT>""" <EOL> self . load ( odffile ) <EOL> return self . xhtml ( ) <EOL> def _wlines ( self , s ) : <EOL> if s != '<STR_LIT>' : self . lines . append ( s ) <EOL> def xhtml ( self ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT>' . join ( self . lines ) <EOL> def _writecss ( self , s ) : <EOL> if s != '<STR_LIT>' : self . _csslines . append ( s ) <EOL> def _writenothing ( self , s ) : <EOL> pass <EOL> def css ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _csslines = [ ] <EOL> self . _wfunc = self . _writecss <EOL> self . generate_stylesheet ( ) <EOL> res = '<STR_LIT>' . join ( self . _csslines ) <EOL> self . _wfunc = self . _wlines <EOL> del self . _csslines <EOL> return res <EOL> def save ( self , outputfile , addsuffix = False ) : <EOL> """<STR_LIT>""" <EOL> if outputfile == '<STR_LIT:->' : <EOL> outputfp = sys . stdout <EOL> else : <EOL> if addsuffix : <EOL> outputfile = outputfile + "<STR_LIT>" <EOL> outputfp = file ( outputfile , "<STR_LIT:w>" ) <EOL> outputfp . write ( self . xhtml ( ) . encode ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> outputfp . close ( ) <EOL> class ODF2XHTMLembedded ( ODF2XHTML ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , lines , generate_css = True , embedable = False ) : <EOL> self . _resetobject ( ) <EOL> self . lines = lines <EOL> self . generate_css = generate_css <EOL> self . elements = { <EOL> ( DRAWNS , '<STR_LIT>' ) : ( self . s_draw_frame , self . e_draw_frame ) , <EOL> ( DRAWNS , '<STR_LIT:image>' ) : ( self . s_draw_image , None ) , <EOL> ( DRAWNS , '<STR_LIT>' ) : ( self . s_draw_fill_image , None ) , <EOL> ( DRAWNS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( DRAWNS , '<STR_LIT>' ) : ( self . s_draw_page , self . e_draw_page ) , <EOL> ( DRAWNS , '<STR_LIT:object>' ) : ( self . s_draw_object , None ) , <EOL> ( DRAWNS , '<STR_LIT>' ) : ( self . s_draw_object_ole , None ) , <EOL> ( DRAWNS , '<STR_LIT>' ) : ( self . s_draw_textbox , self . e_draw_textbox ) , <EOL> ( NUMBERNS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( NUMBERNS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( NUMBERNS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( NUMBERNS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( NUMBERNS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( OFFICENS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( OFFICENS , "<STR_LIT>" ) : ( self . s_ignorecont , None ) , <EOL> ( OFFICENS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( PRESENTATIONNS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( SVGNS , '<STR_LIT>' ) : ( self . s_ignorexml , None ) , <EOL> ( TABLENS , '<STR_LIT>' ) : ( self . s_ignorexml , None ) , <EOL> ( TABLENS , '<STR_LIT>' ) : ( self . s_table_table_cell , self . e_table_table_cell ) , <EOL> ( TABLENS , '<STR_LIT>' ) : ( self . s_table_table_column , None ) , <EOL> ( TABLENS , '<STR_LIT>' ) : ( self . s_table_table_row , self . e_table_table_row ) , <EOL> ( TABLENS , '<STR_LIT>' ) : ( self . s_table_table , self . e_table_table ) , <EOL> ( TEXTNS , '<STR_LIT:a>' ) : ( self . s_text_a , self . e_text_a ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_x_source , self . e_text_x_source ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_x_source , self . e_text_x_source ) , <EOL> ( TEXTNS , '<STR_LIT:h>' ) : ( self . s_text_h , self . e_text_h ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_x_source , self . e_text_x_source ) , <EOL> ( TEXTNS , '<STR_LIT>' ) : ( self . s_text_line_break , None ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( TEXTNS , "<STR_LIT:list>" ) : ( self . s_text_list , self . e_text_list ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_list_item , self . e_text_list_item ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_list_level_style_bullet , self . e_text_list_level_style_bullet ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_list_level_style_number , self . e_text_list_level_style_number ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( None , None ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_note , None ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_note_body , self . e_text_note_body ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( None , self . e_text_note_citation ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_ignorexml , None ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_x_source , self . e_text_x_source ) , <EOL> ( TEXTNS , '<STR_LIT:p>' ) : ( self . s_text_p , self . e_text_p ) , <EOL> ( TEXTNS , '<STR_LIT:s>' ) : ( self . s_text_s , None ) , <EOL> ( TEXTNS , '<STR_LIT>' ) : ( self . s_text_span , self . e_text_span ) , <EOL> ( TEXTNS , '<STR_LIT>' ) : ( self . s_text_tab , None ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_x_source , self . e_text_x_source ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_x_source , self . e_text_x_source ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( self . s_text_x_source , self . e_text_x_source ) , <EOL> ( TEXTNS , "<STR_LIT>" ) : ( None , None ) , <EOL> } </s>
