Exemple #1
0
def on_card_did_render(
    output: TemplateRenderOutput, ctx: TemplateRenderContext
) -> None:
    output.question_text = render_latex(
        output.question_text, ctx.note_type(), ctx.col()
    )
    output.answer_text = render_latex(output.answer_text, ctx.note_type(), ctx.col())
def insert_fen_table(output: TemplateRenderOutput,
                     context: TemplateRenderContext):
    u"""
    Replace well formed  FEN data with a chess board diagram.

    This is a wrapper that looks for `[fen]`, `[/fen]` tags and
    replaces the content.
    """
    # replace both answer and question tag
    output.question_text = fen_re.sub(insert_table, output.question_text)
    output.answer_text = fen_re.sub(insert_table, output.answer_text)
Exemple #3
0
def on_card_did_render(output: TemplateRenderOutput,
                       context: TemplateRenderContext):
    # let's uppercase the characters of the front text
    output.question_text = output.question_text.upper()

    # if the note is tagged "easy", show the answer in green
    # otherwise, in red
    if context.note().has_tag("easy"):
        colour = "green"
    else:
        colour = "red"

    output.answer_text += f"<style>.card {{ color: {colour}; }}</style>"