patch.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:henet 作者: AcrDijon 项目源码 文件源码
def bullet(self, match, context, next_state):
    bulletlist = nodes.bullet_list()
    self.parent += bulletlist
    bulletlist['bullet'] = match.string[0]
    i, blank_finish = self.list_item(match.end())
    bulletlist += i
    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=bulletlist, initial_state='BulletList',
            blank_finish=blank_finish)

    raw = []
    indent = '  '

    def _indent(line):
        if line == '':
            return ''
        return indent + line

    prefix = bulletlist['bullet'] + ' '
    for child in bulletlist.children:
        lines = child.rawsource.split('\n')
        lines = [_indent(line) for line in lines]
        raw.append(prefix + '\n'.join(lines).lstrip())

    bulletlist.rawsource = '\n'.join(raw)
    if bulletlist.rawsource.endswith('\n'):
        bulletlist.rawsource = bulletlist.rawsource[:-1]

    self.goto_line(new_line_offset)
    if not blank_finish:
        self.parent += self.unindent_warning('Bullet list')

    return [], next_state, []
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号