From 29e476f4822b1c7b80ff41a77ed1a87f96ad4391 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 8 Jan 2020 14:42:54 +1000 Subject: [PATCH] no longer try fields with : in their names it's not supported by the card generation code, and the card layout screen will automatically fix note types --- pylib/anki/template/template.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/pylib/anki/template/template.py b/pylib/anki/template/template.py index b96936458..8e0bba6e9 100644 --- a/pylib/anki/template/template.py +++ b/pylib/anki/template/template.py @@ -158,22 +158,13 @@ class Template: @modifier(None) def render_unescaped(self, tag_name=None, context=None) -> Any: """Render a tag without escaping it.""" - txt = get_or_attr(context, tag_name) - if txt is not None: - # some field names could have colons in them - # avoid interpreting these as field modifiers - # better would probably be to put some restrictions on field names - return txt - - # field modifiers - parts = tag_name.split(":") - extra = None - if len(parts) == 1 or parts[0] == "": - return "{unknown field %s}" % tag_name - else: - mods, tag = parts[:-1], parts[-1] # py3k has *mods, tag = parts + # split out field modifiers + *mods, tag = tag_name.split(":") + # return an error if field doesn't exist txt = get_or_attr(context, tag) + if txt is None: + return "{unknown field %s}" % tag_name # Since 'text:' and other mods can affect html on which Anki relies to # process clozes, we need to make sure clozes are always