Skip to content

Unable to render custom math output #1119

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

You must be logged in to vote

It dawned on me that render_math_inline and render_math_block were inside of a function and thus were not going to get overridden that way. I instead just wrote two functions:

def render_math_inline(
    self: RendererProtocol,
    tokens: Sequence[Token],
    idx: int,
    options: OptionsDict,
    env: EnvType,
):
    return f"<span class='language-math math-inline'>{tokens[idx].content}</span>"


def render_math_block(
    self: RendererProtocol,
    tokens: Sequence[Token],
    idx: int,
    options: OptionsDict,
    env: EnvType,
) -> str:
    return f'<div class="language-math math-display">\n{tokens[idx].content}\n</div>\n'

And then explicitly added them as render rules:

md = (
  …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by bitstein
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant