Skip to content

Commit

Permalink
Handle AnkiApp's 'BackSide' special field
Browse files Browse the repository at this point in the history
  • Loading branch information
abdnh committed Jul 23, 2024
1 parent 60fb19f commit 0b66018
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/importers/ankiapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def __init__(
self.style = style
self.front = self._fix_field_refs(front)
self.back = self._fix_field_refs(back)
self._replace_special_fields()

ANKIAPP_FIELD_REF_RE = re.compile(r"\{\{\[(#|/|^)?(.*?)\]\}\}")

Expand All @@ -104,6 +105,10 @@ def repl(m: Match[str]) -> str:

return self.ANKIAPP_FIELD_REF_RE.sub(repl, template)

def _replace_special_fields(self) -> None:
"""Replace AnkiApp's special `{{BackSide}}` reference in front template."""
self.front = self.front.replace("{{BackSide}}", self.back)

def __repr__(self) -> str:
return f"NoteType({self.name=}, {self.fields=}, {self.front=}, {self.back=})"

Expand Down

0 comments on commit 0b66018

Please sign in to comment.