ORDINALS = { 1: "1st", 2: "2nd", 3: "3rd", 4: "4th", 5: "5th", 6: "6th", 7: "7th", 8: "8th", 9: "9th", } PDFTK_CMD = "pdftk" jinja_env = forms.jinja_environment() jinja_env.filters["rst_to_latex"] = latex.rst_to_latex jinja_env.filters["rst_to_html"] = epub.rst_to_html jinja_env.filters["to_heading_id"] = epub.to_heading_id jinja_env.filters["boxed"] = latex.rst_to_boxlatex jinja_env.filters["spellsheetparser"] = latex.msavage_spell_info # Custom types File = Union[Path, str] class CharacterRenderer(): def __init__(self, template_name: str): self.template_name = template_name def __call__(self,
else: # Mark hit dice in monospace font if format_dice: rst = dice_re.sub(r"``\1``", rst) _html_parts = html_parts(rst) html = _html_parts["body"] return html def to_heading_id(inpt: str) -> str: """Take a string and make it suitable for use as an HTML header id.""" bad_characters = [ "'", "(", ")", "&", "/", "+", ",", "=", ] for c in bad_characters: inpt = inpt.replace(c, "") return inpt.replace(" ", "-") # Prepare the jinja environment jinja_env = jinja_environment() jinja_env.filters["rst_to_html"] = rst_to_html jinja_env.filters["to_heading_id"] = to_heading_id