__doc__ = """Example of a mdbook preprocessor""" import datetime import json import os import re import sys from typing import Any _DEBUG = os.getenv("DEBUG", "") def debug(*obj) -> Any: return obj if _DEBUG in ["1", "yes"]: _DEBUG_OUTPUT = "./debug.txt" if os.path.exists(_DEBUG_OUTPUT): os.truncate(_DEBUG_OUTPUT, 0) def debug(*obj) -> Any: with open(_DEBUG_OUTPUT, "+a") as stdout: print(f"DEBUG[{datetime.date.today()}]:", *obj, file=stdout) return obj def modify_content(content: str) -> str | None: ############## MODIFY 'content' HERE ############## """Alter the contents of each chapter Args: content (str): The contents of a chapter received. Is in markdown format. Returns: str | None: The chapter contents modified. If `None`, the original content will be used instead """ author_template = "
" + r"""Publisher: \g""" + "
" author_pattern = r"\A(?P\w+)\s\|\s(?P(?P\d{4})-(?P\d{2})-(?P\d{2}))\s(?P