Loading md_to_docx_converter/src/to_html/preprocessing.py +24 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,29 @@ files_with_references = [NORMATIVE_REF_FILE, INFORMATIVE_REF_FILE] # region Helpers def undo_prettier_formatting(text: str) -> str: """Undo any formatting changes made by Prettier to ensure the Markdown is in a more raw format for processing.""" def fix_notes_and_examples(text: str) -> str: if text.startswith("> > >"): text = text.replace("> > >", ">>>") return text # Remove spaces before and after colons in headings new_lines = [] lines = text.split("\n") for line in lines: new_line = line # Fix notes and examples new_line = fix_notes_and_examples(new_line) new_lines.append(new_line) new_text = "\n".join(new_lines) return new_text def run_format_checks(filename: str, file_lines: list[str]): """Runs various checks on the Markdown file contents to ensure they are properly formatted. If any improper formatting is detected, display any fatal errors or warnings as necessary.""" Loading Loading @@ -616,6 +639,7 @@ def preprocess( try: text = open(input_path, "r", encoding="utf-8").read() text = undo_prettier_formatting(text) run_format_checks(filename, text.splitlines()) text = remove_ignore_prettier_statements(text) Loading Loading
md_to_docx_converter/src/to_html/preprocessing.py +24 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,29 @@ files_with_references = [NORMATIVE_REF_FILE, INFORMATIVE_REF_FILE] # region Helpers def undo_prettier_formatting(text: str) -> str: """Undo any formatting changes made by Prettier to ensure the Markdown is in a more raw format for processing.""" def fix_notes_and_examples(text: str) -> str: if text.startswith("> > >"): text = text.replace("> > >", ">>>") return text # Remove spaces before and after colons in headings new_lines = [] lines = text.split("\n") for line in lines: new_line = line # Fix notes and examples new_line = fix_notes_and_examples(new_line) new_lines.append(new_line) new_text = "\n".join(new_lines) return new_text def run_format_checks(filename: str, file_lines: list[str]): """Runs various checks on the Markdown file contents to ensure they are properly formatted. If any improper formatting is detected, display any fatal errors or warnings as necessary.""" Loading Loading @@ -616,6 +639,7 @@ def preprocess( try: text = open(input_path, "r", encoding="utf-8").read() text = undo_prettier_formatting(text) run_format_checks(filename, text.splitlines()) text = remove_ignore_prettier_statements(text) Loading