コード例 #1
0
ファイル: wp_formatting.py プロジェクト: bahuafeng/wordtex
def subsection_num(texpart, *args, **kwargs):
    global SUBSECTION_NUMBER
    SUBSECTION_NUMBER += 1
    texpart.text_data.insert(0, SUBSECTION_NAME + ' {0}.{1}: '.format(
        SECTION_NUMBER, SUBSECTION_NUMBER))
    texpart.text_data = texlib.reform_text(texpart.text_data, 
                                           no_indicators= True)
コード例 #2
0
ファイル: wp_formatting.py プロジェクト: bahuafeng/wordtex
    def __call__(self, texpart, *args, **kwargs):
        '''Have to do a call here only because the "item"s may or may not have
        an end point (particularily the last one). Have to create a start and stop 
        so it can be handled by process_inout'''
        
        # have to handle itemize and enumerate first for nested lists
        use_dict = {'itemize': begin_dict['itemize'],
                    'enumerate': begin_dict['enumerate']}
        texpart.no_update_text = False
        texpart.update_text(use_dict)
        regexp = re.compile(r'\\item ([\w\W]*?)(?=(\\item|$))')
        researched = []
        for n in texpart.text_data:
            if type(n) in (str, unicode):
#                pdb.set_trace()
                researched.extend(textools.re_search(regexp, n))
            else:
                researched.append(n)
        new_body = []
        for text in researched:
            if type(text) in (str, unicode, texlib.TexPart):
                new_body.append(text)
            else:
                self.count += 1
                assert( r'\end{itemize}' not in text.group(1))
                new_body.append(r'\startitem ' + text.group(1) + r'\enditem ')
#                need = r'\end{itemize}'
#                if need in text.text:
#                    new_body.append(text.text[text.text.find(need):])
        texpart.text_data = texlib.reform_text(new_body, no_indicators = True)
        
        line_items = [
        ['item'         ,tp(add_outside = ('<li>','</li>'), 
                        no_outer_pgraphs = True)],
        ]
        use_dict = build_dict('list_call', line_items, r'\\start{0} ', None, 
                              r'\\end{0}')
        texpart.update_text(use_dict = use_dict)
        texpart.update_text()