コード例 #1
0
 def create_definition_list(self, items):
     """ creates an ET with a definition list made from items """
     def_list = moin_page.list()
     for label, body in items:
         item_label = moin_page.list_item_label(children=[label])
         item_body = moin_page.list_item_body(children=[body])
         item = moin_page.list_item(children=[item_label, item_body])
         def_list.append(item)
     return def_list
コード例 #2
0
ファイル: _base.py プロジェクト: pombredanne/moin2
 def create_definition_list(self, items):
     """ creates an ET with a definition list made from items """
     def_list = moin_page.list()
     for label, body in items:
         item_label = moin_page.list_item_label(children=[label])
         item_body = moin_page.list_item_body(children=[body])
         item = moin_page.list_item(children=[item_label, item_body])
         def_list.append(item)
     return def_list
コード例 #3
0
    def macro(self):
        iwlist = app.cfg.interwiki_map.items()
        iwlist.sort()

        iw_list = moin_page.list()
        for tag, url in iwlist:
            href = join_wiki(url, 'RecentChanges')
            link = moin_page.a(attrib={xlink.href: href}, children=[tag])
            label = moin_page.code(children=[link])
            iw_item_label = moin_page.list_item_label(children=[label])
            if '$PAGE' not in url:
                link = moin_page.a(attrib={xlink.href: url}, children=[url])
            else:
                link = url
            body = moin_page.code(children=[link])
            iw_item_body = moin_page.list_item_body(children=[body])
            iw_item = moin_page.list_item(children=[iw_item_label, iw_item_body])
            iw_list.append(iw_item)
        return iw_list
コード例 #4
0
    def indent_repl(self, iter_content, stack, line,
                    indent, text, list_begin=None, list_definition=None,
                    list_definition_text=None, list_numbers=None,
                    list_alpha=None, list_roman=None, list_bullet=None,
                    list_start_number=None, list_start_roman=None, list_start_alpha=None,
                    list_none=None):

        level = len(indent)

        # default to blockquote / indented text / bulletless list
        list_type = 'unordered', 'no-bullet'

        if list_begin:
            if list_definition:
                list_type = 'definition', None
            elif list_numbers:
                list_type = 'ordered', None
            elif list_alpha and list_alpha[:2] == 'A.':
                list_type = 'ordered', 'upper-alpha'
            elif list_alpha:
                list_type = 'ordered', 'lower-alpha'
            elif list_roman and list_roman[:2] == 'I.':
                list_type = 'ordered', 'upper-roman'
            elif list_roman:
                list_type = 'ordered', 'lower-roman'
            elif list_bullet == u'*':
                list_type = 'unordered', None

        element_use = None
        while len(stack) > 1:
            cur = stack.top()
            if cur.tag.name == 'list-item-body':
                if level > cur.level:
                    element_use = cur
                    break
            if cur.tag.name == 'list':
                if level >= cur.level and list_type == cur.list_type:
                    element_use = cur
                    break
            stack.pop()

        if not element_use:
            element_use = stack.top()

        if indent:
            if element_use.tag.name != 'list':
                attrib = {}
                if not list_definition:
                    attrib[moin_page.item_label_generate] = list_type[0]
                if list_type[1]:
                    attrib[moin_page.list_style_type] = list_type[1]
                if list_start_number or list_start_alpha or list_start_roman:
                    attrib[moin_page.list_start] = list_start_number or list_start_alpha or list_start_roman
                element = moin_page.list(attrib=attrib)
                element.level, element.list_type = level, list_type
                stack.push(element)

            stack.push(moin_page.list_item())

            if list_definition_text:
                element_label = moin_page.list_item_label()
                stack.top_append(element_label)
                new_stack = _Stack(element_label, iter_content=iter_content)

                self.parse_inline(list_definition_text, new_stack, self.inline_re)
            if not list_definition_text or text:
                # if text == true, then we have object:: definition, not object::\n ::definition
                element_body = moin_page.list_item_body()
                element_body.level, element_body.type = level, type

                stack.push(element_body)
                new_stack = _Stack(element_body, iter_content=iter_content)
        else:
            new_stack = stack

        iter = _Iter(self.indent_iter(iter_content, text, level), startno=iter_content.lineno)
        for line in iter:
            match = self.block_re.match(line)
            it = iter
            # XXX: Hack to allow nowiki to ignore the list identation
            if match.lastgroup == 'nowiki':
                it = iter_content
            self._apply(match, 'block', it, new_stack)
コード例 #5
0
    def indent_repl(self, iter_content, stack, line,
                    indent, text, list_begin=None, list_definition=None,
                    list_definition_text=None, list_numbers=None,
                    list_bullet=None,
                    list_none=None):
        level = len(indent)
        list_type = 'unordered', 'none'
        if list_begin:
            if list_definition:
                list_type = 'definition', None
            elif list_numbers:
                list_type = 'ordered', None
            elif list_bullet:
                list_type = 'unordered', None
            elif list_none:
                list_type = None, None

        element_use = None
        while len(stack) > 1:
            cur = stack.top()
            if cur.tag.name == 'list-item-body':
                if level > cur.level:
                    element_use = cur
                    break
            if cur.tag.name == 'list':
                if level >= cur.level and list_type == cur.list_type:
                    element_use = cur
                    break
            stack.pop()

        if not element_use:
            element_use = stack.top()
        if list_begin:
            if element_use.tag.name != 'list':
                attrib = {}
                if not list_definition:
                    attrib[moin_page.item_label_generate] = list_type[0]
                if list_type[1]:
                    attrib[moin_page.list_style_type] = list_type[1]
                element = moin_page.list(attrib=attrib)
                element.level, element.list_type = level, list_type
                stack.push(element)

            stack.push(moin_page.list_item())
            if list_definition:
                element_label = moin_page.list_item_label()
                stack.top_append(element_label)
                new_stack = _Stack(element_label, iter_content=iter_content)
                # TODO: definition list doesn't work,
                #       if definition of the term on the next line
                splited_text = text.split(':')
                list_definition_text = splited_text.pop(0)
                text = ':'.join(splited_text)

                self.parse_inline(list_definition_text, new_stack, self.inline_re)

            element_body = moin_page.list_item_body()
            element_body.level, element_body.type = level, type

            stack.push(element_body)
            new_stack = _Stack(element_body, iter_content=iter_content)
        else:
            new_stack = stack
            level = 0

        is_list = list_begin
        iter = _Iter(self.indent_iter(iter_content, text, level, is_list), startno=iter_content.lineno)
        for line in iter:
            match = self.block_re.match(line)
            it = iter
            # XXX: Hack to allow nowiki to ignore the list identation
            if match.lastgroup == 'table' or match.lastgroup == 'nowiki':
                it = iter_content
            self._apply(match, 'block', it, new_stack)
コード例 #6
0
    def indent_repl(self, iter_content, stack, line,
                    indent, text, list_begin=None, list_definition=None,
                    list_definition_text=None, list_numbers=None,
                    list_alpha=None, list_roman=None, list_bullet=None,
                    list_start_number=None, list_start_roman=None, list_start_alpha=None,
                    list_none=None):

        level = len(indent)

        # default to blockquote / indented text / bulletless list
        list_type = 'unordered', 'no-bullet'

        if list_begin:
            if list_definition:
                list_type = 'definition', None
            elif list_numbers:
                list_type = 'ordered', None
            elif list_alpha and list_alpha[:2] == 'A.':
                list_type = 'ordered', 'upper-alpha'
            elif list_alpha:
                list_type = 'ordered', 'lower-alpha'
            elif list_roman and list_roman[:2] == 'I.':
                list_type = 'ordered', 'upper-roman'
            elif list_roman:
                list_type = 'ordered', 'lower-roman'
            elif list_bullet == u'*':
                list_type = 'unordered', None

        element_use = None
        while len(stack) > 1:
            cur = stack.top()
            if cur.tag.name == 'list-item-body':
                if level > cur.level:
                    element_use = cur
                    break
            if cur.tag.name == 'list':
                if level >= cur.level and list_type == cur.list_type:
                    element_use = cur
                    break
            stack.pop()

        if not element_use:
            element_use = stack.top()

        if indent:
            if element_use.tag.name != 'list':
                attrib = {}
                if not list_definition:
                    attrib[moin_page.item_label_generate] = list_type[0]
                if list_type[1]:
                    attrib[moin_page.list_style_type] = list_type[1]
                if list_start_number or list_start_alpha or list_start_roman:
                    attrib[moin_page.list_start] = list_start_number or list_start_alpha or list_start_roman
                element = moin_page.list(attrib=attrib)
                element.level, element.list_type = level, list_type
                stack.push(element)

            stack.push(moin_page.list_item())

            if list_definition_text:
                element_label = moin_page.list_item_label()
                stack.top_append(element_label)
                new_stack = _Stack(element_label, iter_content=iter_content)

                self.parse_inline(list_definition_text, new_stack, self.inline_re)

            element_body = moin_page.list_item_body()
            element_body.level, element_body.type = level, type

            stack.push(element_body)
            new_stack = _Stack(element_body, iter_content=iter_content)
        else:
            new_stack = stack

        iter = _Iter(self.indent_iter(iter_content, text, level), startno=iter_content.lineno)
        for line in iter:
            match = self.block_re.match(line)
            it = iter
            # XXX: Hack to allow nowiki to ignore the list identation
            if match.lastgroup == 'nowiki':
                it = iter_content
            self._apply(match, 'block', it, new_stack)
コード例 #7
0
ファイル: rst_in.py プロジェクト: YelaSeamless/moin-2.0
 def visit_term(self, node):
     self.open_moin_page_node(moin_page.list_item_label())
コード例 #8
0
ファイル: rst_in.py プロジェクト: ThomasWaldmann/moin-2.0-dev
 def visit_term(self, node):
     self.open_moin_page_node(moin_page.list_item_label())