示例#1
0
    def parser(self, name, args, content):
        if '/' in name:
            type = Type(name)
        else:
            type = Type(type='x-moin',
                        subtype='format',
                        parameters={'name': name})
        logging.debug("parser type: %r" % (type, ))

        elem = moin_page.part(attrib={moin_page.content_type: type})

        if args:
            elem_arguments = moin_page.arguments()
            elem.append(elem_arguments)

            for key, value in args.items():
                attrib = {}
                if key:
                    attrib[moin_page.name] = key
                elem_arg = moin_page.argument(attrib=attrib,
                                              children=(value, ))
                elem_arguments.append(elem_arg)

        if content:
            elem.append(moin_page.body(children=content))

        return elem
示例#2
0
    def visit_reference(self, node):
        refuri = node.get('refuri', u'')
        if refuri.startswith(u'<<') and refuri.endswith(u'>>'):  # moin macro
            macro_name = refuri[2:-2].split(u'(')[0]
            if macro_name == u"TableOfContents":
                arguments = refuri[2:-2].split(u'(')[1][:-1].split(u',')
                node = moin_page.table_of_content()
                self.open_moin_page_node(node)
                if arguments and arguments[0]:
                    node.set(moin_page.outline_level, arguments[0])
                return
            arguments = refuri[2:-2].split(u'(')[1][:-1].split(u',')
            self.open_moin_page_node(
                moin_page.part(
                    attrib={moin_page.content_type: "x-moin/macro;name={0}".format(macro_name)}))
            if arguments:
                self.open_moin_page_node(moin_page.arguments())
                for i in arguments:
                    self.open_moin_page_node(moin_page.argument(children=[i]))
                    self.close_moin_page_node()
                self.close_moin_page_node()
            self.open_moin_page_node(refuri)
            self.close_moin_page_node()
            return

        if not allowed_uri_scheme(refuri):
            return
        self.open_moin_page_node(moin_page.a(attrib={xlink.href: refuri}))
示例#3
0
    def visit_reference(self, node):
        refuri = node.get('refuri', u'')
        if refuri.startswith(u'<<') and refuri.endswith(u'>>'):  # moin macro
            macro_name = refuri[2:-2].split(u'(')[0]
            if macro_name == u"TableOfContents":
                arguments = refuri[2:-2].split(u'(')[1][:-1].split(u',')
                node = moin_page.table_of_content()
                self.open_moin_page_node(node)
                if arguments and arguments[0]:
                    node.set(moin_page.outline_level, arguments[0])
                return
            arguments = refuri[2:-2].split(u'(')[1][:-1].split(u',')
            self.open_moin_page_node(
                moin_page.part(
                    attrib={
                        moin_page.content_type:\
                            "x-moin/macro;name=%s" % macro_name, }))
            if arguments:
                self.open_moin_page_node(moin_page.arguments())
                for i in arguments:
                    self.open_moin_page_node(moin_page.argument(children=[i]))
                    self.close_moin_page_node()
                self.close_moin_page_node()
            self.open_moin_page_node(refuri)
            self.close_moin_page_node()
            return

        self.open_moin_page_node(moin_page.a(attrib={xlink.href: refuri}))
示例#4
0
 def visit_literal_block(self, node):
     parser = node.get('parser', u'')
     if parser:
         named_args = re.findall(r"(\w+)=(\w+)", parser)
         simple_args = re.findall(r"(?:\s)\w+(?:\s|$)", parser)
         args = []
         for value in simple_args:
             args.append(moin_page.argument(children=[value]))
         for name, value in named_args:
             args.append(moin_page.argument(attrib={moin_page.name: name}, children=[value]))
         arguments = moin_page.arguments(children=args)
         self.open_moin_page_node(moin_page.part(children=[arguments], attrib={moin_page.content_type: "x-moin/format;name={0}".format(parser.split(' ')[0])}))
     else:
         self.open_moin_page_node(moin_page.blockcode())
示例#5
0
 def visit_literal_block(self, node):
     parser = node.get('parser', u'')
     if parser:
         named_args = re.findall(r"(\w+)=(\w+)", parser)
         simple_args = re.findall(r"(?:\s)\w+(?:\s|$)", parser)
         args = []
         for value in simple_args:
             args.append(moin_page.argument(children=[value]))
         for name, value in named_args:
             args.append(
                 moin_page.argument(attrib={moin_page.name: name},
                                    children=[value]))
         arguments = moin_page.arguments(children=args)
         self.open_moin_page_node(
             moin_page.part(children=[arguments],
                            attrib={
                                moin_page.content_type:
                                "x-moin/format;name=%s" %
                                parser.split(' ')[0]
                            }))
     else:
         self.open_moin_page_node(moin_page.blockcode())
示例#6
0
    def parser(self, name, args, content):
        if '/' in name:
            type = Type(name)
        else:
            type = Type(type='x-moin', subtype='format', parameters={'name': name})
        logging.debug("parser type: %r" % (type, ))

        elem = moin_page.part(attrib={moin_page.content_type: type})

        if args:
            elem_arguments = moin_page.arguments()
            elem.append(elem_arguments)

            for key, value in args.items():
                attrib = {}
                if key:
                    attrib[moin_page.name] = key
                elem_arg = moin_page.argument(attrib=attrib, children=(value, ))
                elem_arguments.append(elem_arg)

        if content:
            elem.append(moin_page.body(children=content))

        return elem