Example #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)
Example #3
0
def on_card_did_render(output: TemplateRenderOutput, context: TemplateRenderContext):

    #TODO lvl == 0; review == 0 -> show word translation
    # f = open("/Users/ihor/Library/Application Support/Anki2/addons21/2055492100/log.txt", "a")
    # f.write(str(context.card()))
    # f.write("\n")
    # f.write(str(context.note()))
    # f.write("\n")
    # f.write(str(context.fields()))
    # f.write("\n")
    # f.write(str(context.fields()))
    # f.write("\n")
    # f.write(str(context.fields()["translation"]))
    # f.write("\n")
    # f.write(str(output))
    # f.write("\n")
    # f.close()
    # word {
    # debug {

    # output.question_text += f"<style>#debug {{ display: block; }}</style>"
    #
    # if context.card().did == gc("deckId") and context.card().ivl < 5 and context.card().reps > 5:
    #     output.question_text += f"<style>#word {{ color: red; }}</style>"
    #lapses=0

    # HIGHLIGHT EASY CARDS
    if context.card().did == gc("deckId") and context.card().lapses < 2 and context.card().reps > 6:
        # output.question_text += f"<style>.easy {{ display: block !important; }}</style>"
        output.question_text += f"<style>body {{ background-color: #7cedff21 !important; }}</style>"

    # HIDE GIF FOR CARDS WITH SOME PROGRESS
    if context.card().did == gc("deckId") and context.card().reps > 10 and context.card().ivl <= 10:
        output.question_text += f"<style>#gif {{ display: none; }}</style>"

    # SHOW TRANSLATION FOR NEW CARDS
    if context.card().did == gc("deckId") and context.card().ivl == 0 and context.card().reps == 0:
        output.question_text += f"<style>.hint {{ display: block; }}</style>"

    #FILL BLANK FOR MORE MATURE CARDS
    if context.card().did == gc("filteredDeckId") and context.card().ivl > 5:
        output.question_text += f"<style>#context, #word {{ display: none; }}</style>"''
        output.question_text += f"<style>#fill-blank-block, .hint.word, #gif {{ display: block; }}</style>"''
        # add original clip audio to back
        output.answer_av_tags = [output.question_av_tags[0]]
        # clear front
        output.question_av_tags = []

    if (context.card().did == gc("deckId") or context.card().did == 1606067545027) and context.card().ivl > 10:
        output.question_text += f"<style>#gif, #context {{ display: none; }}</style>"
        output.question_av_tags = [output.answer_av_tags[0]]
Example #4
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>"