本文整理汇总了Python中docutils.nodes.line_block方法的典型用法代码示例。如果您正苦于以下问题:Python nodes.line_block方法的具体用法?Python nodes.line_block怎么用?Python nodes.line_block使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类docutils.nodes
的用法示例。
在下文中一共展示了nodes.line_block方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import line_block [as 别名]
def run(self):
self.assert_has_content()
block = nodes.line_block(classes=self.options.get('class', []))
self.add_name(block)
node_list = [block]
for line_text in self.content:
text_nodes, messages = self.state.inline_text(
line_text.strip(), self.lineno + self.content_offset)
line = nodes.line(line_text, '', *text_nodes)
if line_text.strip():
line.indent = len(line_text) - len(line_text.lstrip())
block += line
node_list.extend(messages)
self.content_offset += 1
self.state.nest_line_block_lines(block)
return node_list
示例2: line_block
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import line_block [as 别名]
def line_block(self, match, context, next_state):
"""First line of a line block."""
block = nodes.line_block()
self.parent += block
lineno = self.state_machine.abs_line_number()
line, messages, blank_finish = self.line_block_line(match, lineno)
block += line
self.parent += messages
if not blank_finish:
offset = self.state_machine.line_offset + 1 # next line
new_line_offset, blank_finish = self.nested_list_parse(
self.state_machine.input_lines[offset:],
input_offset=self.state_machine.abs_line_offset() + 1,
node=block, initial_state='LineBlock',
blank_finish=0)
self.goto_line(new_line_offset)
if not blank_finish:
self.parent += self.reporter.warning(
'Line block ends without a blank line.',
line=lineno+1)
if len(block):
if block[0].indent is None:
block[0].indent = 0
self.nest_line_block_lines(block)
return [], next_state, []
示例3: nest_line_block_segment
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import line_block [as 别名]
def nest_line_block_segment(self, block):
indents = [item.indent for item in block]
least = min(indents)
new_items = []
new_block = nodes.line_block()
for item in block:
if item.indent > least:
new_block.append(item)
else:
if len(new_block):
self.nest_line_block_segment(new_block)
new_items.append(new_block)
new_block = nodes.line_block()
new_items.append(item)
if len(new_block):
self.nest_line_block_segment(new_block)
new_items.append(new_block)
block[:] = new_items
示例4: get_section
# 需要导入模块: from docutils import nodes [as 别名]
# 或者: from docutils.nodes import line_block [as 别名]
def get_section(self, section):
try:
lines = self.layout['layout'][section]
except KeyError:
# Return nothing, if not specific configuration is given for layout section
return []
# Needed for PDF/Latex output, where empty line_blocks raise exceptions during build
if len(lines) == 0:
return []
lines_container = nodes.line_block(classes=['needs_{}'.format(section)])
for line in lines:
# line_block_node = nodes.line_block()
line_node = nodes.line()
line_parsed = self._parse(line)
line_ready = self._func_replace(line_parsed)
line_node += line_ready
lines_container.append(line_node)
return lines_container