import re import cgi import collections from anki.utils import stripHTML from anki.hooks import runFilter from anki.template import furigana; furigana.install() from anki.template import hint; hint.install() from anki.lang import _ clozeReg = r"\{\{c%s::(.*?)(::(.*?))?\}\}" modifiers = {} def modifier(symbol): """Decorator for associating a function with a Mustache tag modifier. @modifier('P') def render_tongue(self, tag_name=None, context=None): return ":P %s" % tag_name {{P yo }} => :P yo """ def set_modifier(func): modifiers[symbol] = func return func return set_modifier def get_or_attr(obj, name, default=None): try: return obj[name] except KeyError:
import re from anki.utils import stripHTML, stripHTMLMedia from anki.hooks import runFilter from anki.template import furigana; furigana.install() from anki.template import hint; hint.install() clozeReg = r"(?si)\{\{(c)%s::(.*?)(::(.*?))?\}\}" modifiers = {} def modifier(symbol): """Decorator for associating a function with a Mustache tag modifier. @modifier('P') def render_tongue(self, tag_name=None, context=None): return ":P %s" % tag_name {{P yo }} => :P yo """ def set_modifier(func): modifiers[symbol] = func return func return set_modifier def get_or_attr(obj, name, default=None): try: return obj[name] except KeyError: return default except: try:
import re from anki.utils import stripHTML, stripHTMLMedia from anki.hooks import runFilter from anki.template import furigana furigana.install() from anki.template import hint hint.install() clozeReg = r"(?si)\{\{(c)%s::(.*?)(::(.*?))?\}\}" modifiers = {} def modifier(symbol): """Decorator for associating a function with a Mustache tag modifier. @modifier('P') def render_tongue(self, tag_name=None, context=None): return ":P %s" % tag_name {{P yo }} => :P yo """ def set_modifier(func): modifiers[symbol] = func return func return set_modifier def get_or_attr(obj, name, default=None): try:
# -*- coding: utf-8 -*- import re from anki.hooks import runFilter from anki.template import furigana from anki.template import hint from anki.utils import stripHTML, stripHTMLMedia furigana.install() hint.install() clozeReg = r"(?s)\{\{c%s::(.*?)(::(.*?))?\}\}" modifiers = {} def modifier(symbol): """Decorator for associating a function with a Mustache tag modifier. @modifier('P') def render_tongue(self, tag_name=None, context=None): return ":P %s" % tag_name {{P yo }} => :P yo """ def set_modifier(func): modifiers[symbol] = func return func return set_modifier