MCPcopy Create free account
hub / github.com/executablebooks/markdown-it-py / render

Method render

markdown_it/renderer.py:67–88  ·  view source on GitHub ↗

Takes token stream and generates HTML. :param tokens: list on block tokens to render :param options: params of parser instance :param env: additional data from parsed input

(
        self, tokens: Sequence[Token], options: OptionsDict, env: EnvType
    )

Source from the content-addressed store, hash-verified

65 }
66
67 def render(
68 self, tokens: Sequence[Token], options: OptionsDict, env: EnvType
69 ) -> str:
70 """Takes token stream and generates HTML.
71
72 :param tokens: list on block tokens to render
73 :param options: params of parser instance
74 :param env: additional data from parsed input
75
76 """
77 result = ""
78
79 for i, token in enumerate(tokens):
80 if token.type == "inline":
81 if token.children:
82 result += self.renderInline(token.children, options, env)
83 elif token.type in self.rules:
84 result += self.rules[token.type](tokens, i, options, env)
85 else:
86 result += self.renderToken(tokens, i, options, env)
87
88 return result
89
90 def renderInline(
91 self, tokens: Sequence[Token], options: OptionsDict, env: EnvType

Callers

nothing calls this directly

Calls 2

renderInlineMethod · 0.95
renderTokenMethod · 0.95

Tested by

no test coverage detected