Example #1
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>"
Example #2
0
def note_creation(ctx: TemplateRenderContext) -> str:
    # convert millisecond timestamp to seconds
    note_creation_unix_timestamp = ctx.note().id // 1000
    # convert timestamp to a human years-months-days
    return time.strftime("%Y-%m-%d", time.localtime(note_creation_unix_timestamp))