Coverage for src/extratools_html/cleanup.py: 50%
6 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-12 00:31 -0700
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-12 00:31 -0700
1from asyncio import create_subprocess_exec, subprocess
2from asyncio.subprocess import Process
5async def cleanup_page(page_html: str) -> str:
6 # https://github.com/danburzo/percollate
7 process: Process = await create_subprocess_exec(
8 "percollate",
9 *[
10 "html",
11 "--output",
12 "-",
13 ],
14 stdin=subprocess.PIPE,
15 stdout=subprocess.PIPE,
16 stderr=subprocess.DEVNULL,
17 )
18 stdout, _ = await process.communicate(page_html.encode())
20 return stdout.decode()