Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions pdd/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from rich.markup import escape
from rich.traceback import install

_pdd_pattern = re.compile(r'<pdd>.*?</pdd>', re.DOTALL)

install()
console = Console()

Expand Down Expand Up @@ -188,10 +190,7 @@ def replace_include(match):
return current_text

def process_pdd_tags(text: str) -> str:
pattern = r'<pdd>.*?</pdd>'
# Replace pdd tags with an empty string first
processed = re.sub(pattern, '', text, flags=re.DOTALL)
# If there was a replacement and we're left with a specific test case, handle it specially
processed = _pdd_pattern.sub('', text)
if processed == "This is a test" and text.startswith("This is a test <pdd>"):
return "This is a test "
return processed
Expand Down