Add line numbers to newly generated nodes.

This commit is contained in:
Georg Brandl
2011-01-07 11:16:55 +01:00
parent c50054c8da
commit 33ed935df2
3 changed files with 5 additions and 0 deletions

View File

@@ -64,6 +64,7 @@ class CodeBlock(Directive):
literal = nodes.literal_block(code, code)
literal['language'] = self.arguments[0]
literal['linenos'] = 'linenos' in self.options
literal.line = self.lineno
return [literal]
@@ -180,6 +181,7 @@ class LiteralInclude(Directive):
text = text.expandtabs(self.options['tab-width'])
retnode = nodes.literal_block(text, text, source=fn)
retnode.line = 1
retnode.attributes['line_number'] = self.lineno
if self.options.get('language', ''):
retnode['language'] = self.options['language']
if 'linenos' in self.options:

View File

@@ -260,6 +260,7 @@ class TabularColumns(Directive):
def run(self):
node = addnodes.tabular_col_spec()
node['spec'] = self.arguments[0]
node.line = self.lineno
return [node]

View File

@@ -69,6 +69,8 @@ class MathDirective(Directive):
node['nowrap'] = 'nowrap' in self.options
node['docname'] = self.state.document.settings.env.docname
ret = [node]
node.line = self.lineno
node.source = self.src
if node['label']:
tnode = nodes.target('', '', ids=['equation-' + node['label']])
self.state.document.note_explicit_target(tnode)