mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add line numbers to newly generated nodes.
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user