From bfff60cd61c77cd4528991137a86117f2c1e3ea9 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Wed, 25 Jun 2025 17:31:17 -0500 Subject: [PATCH] Fix so all :ref:s are removed, and other fixes Port fixes from PRIMEDB from EVA MPG. Previously, only refs without a space in the subsituted text were removed. Also, fix so EOF ending a block works. --- doc/filter_refs.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/filter_refs.py b/doc/filter_refs.py index a19d899..10d0722 100755 --- a/doc/filter_refs.py +++ b/doc/filter_refs.py @@ -1,5 +1,5 @@ #!/usr/bin/python3 -# Copyright (C) 2023 The Meme Factory, Inc. http://www.karlpinc.com/ +# Copyright (C) 2023, 2025 The Meme Factory, Inc. http://www.karlpinc.com/ # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -20,14 +20,15 @@ import sys import re -EXP = re.compile(r"(\s*..\s+\|[^\s]+\|\s+replace::\s+):ref:`(.*)\s+<.*>`") +EXP = re.compile(r"(\s*..\s+\|.+\|\s+replace::\s+):ref:`(.*)\s+<.*>`") BLOCK_START = re.compile(r"(\s*..\s+)") def write_block(block): - match = EXP.match(block) + line = f'{"".join(block)}\n' + match = EXP.match(line) if match is None: - print(block, end="") + print(line, end="") else: print(f"{match.group(1)}{match.group(2)}") @@ -39,7 +40,7 @@ def main(): for line in sys.stdin: if in_block: if line[0:indent] != prefix: - write_block(f'{"".join(block)}\n') + write_block(block) block = [] in_block = False else: -- 2.34.1