Skip to content

Copy the 'content' from the Markdown or from it's focused child #4249

Closed Answered by villekr
villekr asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for pointing me to look for the solution from the correct place. Added one if-clause to parse_from_children and it works now.

    def parse_from_children(self, block: MarkdownBlock, indent_depth: int = -2) -> str:
        children = block.children
        print(f"[{indent_depth}] {block=} {children=}")

        if isinstance(block, MarkdownFence):
            return block.code

        if len(children) > 0:
            text = ""
            for child in children:
                text += self.parse_from_children(child, indent_depth + 1)
            return text
        else:
            if isinstance(block, MarkdownBullet):
                return " " * indent_depth + "- "
            r…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@villekr
Comment options

@TomJGooding
Comment options

@villekr
Comment options

Answer selected by villekr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants