예제 #1
0
 def run(self):
     """ run
   """
     result = RSTTable.run(self)
     if result and isinstance(result[0], nodes.table):
         self._update_table_classes(result[0])
     return result
    def run(self):
        env = self.state.document.settings.env
        definitions = env.numbered_blocks_definitions

        (table,) = RSTTable.run(self)
        if isinstance(table, nodes.system_message):
            return [table]

        numbered = self.numbered()
        if not table['ids']:
            id = "%s-%d" % (self.name, env.new_serialno(self.name))
            table['ids'] = [nodes.fully_normalize_name(id)]
            self.add_name(table)

        table['classes'].append('numbered-block')
        table['type'] = self.name
        table['numbered'] = numbered

        title_pos = table.first_child_matching_class(nodes.title)
        if numbered:
            if title_pos == None:
                table.insert(0, nodes.title('', ''))
            else:
                title = table.children[title_pos]
                title.insert(0, nodes.inline('', definitions[self.name]['title-separator'], classes=['separator']))

        return [table]
예제 #3
0
 def run(self):
    """ run
    """
    result = RSTTable.run(self)
    if result and isinstance(result[0], nodes.table):
       self._update_table_classes(result[0])
    return result
예제 #4
0
파일: xtable.py 프로젝트: xcore/xdoc
    def run(self):
        content = ''
        for x in self.content:
            content += x + "\n"

        if len(self.arguments) > 0 and re.match('[Tt]he.*',self.arguments[0]):
            print >>sys.stderr, "WARNING: Style: Caption '%s' begins with 'The'" % self.arguments[0]

        if content.find('.. raw::') != -1:
            table = nodes.table()
            table['classes'] = ['raw']

            content_split = re.split('.. raw:: (.*)',content)
            content_split = content_split[1:]
            raw_nodes = []
            while content_split != []:
                format = content_split[0]
                text = content_split[1]
                content_split = content_split[2:]

                raw = nodes.raw('',text+"\n",format=format)
                raw_nodes.append(raw)


            table['caption'] = self.arguments[0]

            if 'position' in self.options:
                table['position'] = self.options['position']

            caption = nodes.title()
            caption.append(nodes.Text(self.arguments[0]))

            table.append(caption)
            table += raw_nodes
            return [table]
        else:
           x = RSTTable.run(self)
           return x