def inline_emphstrong_repl(self, stack, emphstrong, emphstrong_follow=''): if len(emphstrong) == 5: if stack.top_check('emphasis'): stack.pop() if stack.top_check('strong'): stack.pop() else: stack.push(moin_page.strong()) elif stack.top_check('strong'): if stack.top_check('strong'): stack.pop() else: stack.push(moin_page.strong()) else: if len(emphstrong_follow) == 3: stack.push(moin_page.emphasis()) stack.push(moin_page.strong()) else: stack.push(moin_page.strong()) stack.push(moin_page.emphasis()) elif len(emphstrong) == 3: if stack.top_check('strong'): stack.pop() else: stack.push(moin_page.strong()) elif len(emphstrong) == 2: if stack.top_check('emphasis'): stack.pop() else: stack.push(moin_page.emphasis())
def recurse(self, elem): new_childs = [] for child in elem: if isinstance(child, (unicode, str)): pos = 0 # Restrict it to our own namespace for now if elem.tag.uri == moin_page.namespace: for match in re.finditer(self.pattern, child): text = child[pos:match.start()] new_childs.append(text) text = child[match.start():match.end()] attrib = {html.class_: 'moin-highlight'} e = moin_page.strong(attrib=attrib, children=[text]) new_childs.append(e) pos = match.end() new_childs.append(child[pos:]) else: self.recurse(child) new_childs.append(child) # Use inline replacement to avoid a complete tree copy if len(new_childs) > len(elem): elem[:] = new_childs
def visit_copyright(self, node): self.open_moin_page_node(moin_page.table_row()) self.open_moin_page_node(moin_page.table_cell()) self.open_moin_page_node(moin_page.strong()) # TODO: i18n for docutils: self.open_moin_page_node(u"Copyright:") self.close_moin_page_node() self.close_moin_page_node() self.close_moin_page_node() self.open_moin_page_node(moin_page.table_cell())
def visit_version(self, node): self.open_moin_page_node(moin_page.table_row()) self.open_moin_page_node(moin_page.table_cell()) self.open_moin_page_node(moin_page.strong()) # TODO: i18n for docutils: self.open_moin_page_node(u"Version:") self.close_moin_page_node() self.close_moin_page_node() self.close_moin_page_node() self.open_moin_page_node(moin_page.table_cell())
def visit_author(self, node): self.open_moin_page_node(moin_page.table_row()) self.open_moin_page_node(moin_page.table_cell()) self.open_moin_page_node(moin_page.strong()) # TODO: i18n for docutils: self.open_moin_page_node(u"Author:") self.close_moin_page_node() self.close_moin_page_node() self.close_moin_page_node() self.open_moin_page_node(moin_page.table_cell())
def inline_strong_repl(self, stack, strong): if not stack.top_check('strong'): stack.push(moin_page.strong()) else: stack.pop_name('strong')
def visit_strong(self, node): self.open_moin_page_node(moin_page.strong())
def visit_field_name(self, node): self.open_moin_page_node(moin_page.table_cell()) self.open_moin_page_node(moin_page.strong()) self.open_moin_page_node(u'{0}:'.format(node.astext())) node.children = [] self.close_moin_page_node()