lepture / mistune

A fast yet powerful Python Markdown parser with renderers and plugins.

Home Page:http://mistune.lepture.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nested blocks inside a directive

ahopkins opened this issue · comments

Are nested directives supported? I am trying to create a custom directive to add some columns. But, I would like to also have other directives and block level items. It seems that only inline parsing is happening inside of the directive. Is there something that I need to enable? Is this supported?

Figured it out.

class Column(DirectivePlugin):
    def parse(
        self, block: BlockParser, m: Match, state: BlockState
    ) -> dict[str, Any]:
        info = m.groupdict()

        new_state = block.state_cls()
        new_state.process(dedent(info["text"]))
        block.parse(new_state)

        return {
			...,
            "children": new_state.tokens,
        }

@ahopkins Hi, if you have already fixed it, I'll close this issue. If not, please reopen it.

All good, thanks.