mirror of
https://github.com/github/awesome-copilot.git
synced 2026-04-13 11:45:56 +00:00
Address Copilot code review feedback
- Fix browser leak in render_url_to_pdf (try/finally around Playwright) - Remove setup.sh references from SKILL.md (not bundled in plugin) - Use consistent <path-to>/eyeball.py paths in SKILL.md - Update plugin README install instructions for awesome-copilot - Add Windows pywin32 install step to SKILL.md Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -241,26 +241,30 @@ def render_url_to_pdf(url, output_pdf_path):
|
||||
)
|
||||
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch(headless=True)
|
||||
page = browser.new_page()
|
||||
page.goto(url, wait_until="networkidle", timeout=30000)
|
||||
browser = None
|
||||
try:
|
||||
browser = p.chromium.launch(headless=True)
|
||||
page = browser.new_page()
|
||||
page.goto(url, wait_until="networkidle", timeout=30000)
|
||||
|
||||
# Clean up navigation/footer elements for cleaner output
|
||||
page.evaluate("""
|
||||
document.querySelectorAll(
|
||||
'header, footer, nav, [data-testid="header"], [data-testid="footer"], '
|
||||
+ '.site-header, .site-footer, #cookie-banner, .cookie-consent'
|
||||
).forEach(el => el.remove());
|
||||
""")
|
||||
# Clean up navigation/footer elements for cleaner output
|
||||
page.evaluate("""
|
||||
document.querySelectorAll(
|
||||
'header, footer, nav, [data-testid="header"], [data-testid="footer"], '
|
||||
+ '.site-header, .site-footer, #cookie-banner, .cookie-consent'
|
||||
).forEach(el => el.remove());
|
||||
""")
|
||||
|
||||
page.pdf(
|
||||
path=output_pdf_path,
|
||||
format="Letter",
|
||||
print_background=True,
|
||||
margin={"top": "0.5in", "bottom": "0.5in",
|
||||
"left": "0.75in", "right": "0.75in"}
|
||||
)
|
||||
browser.close()
|
||||
page.pdf(
|
||||
path=output_pdf_path,
|
||||
format="Letter",
|
||||
print_background=True,
|
||||
margin={"top": "0.5in", "bottom": "0.5in",
|
||||
"left": "0.75in", "right": "0.75in"}
|
||||
)
|
||||
finally:
|
||||
if browser is not None:
|
||||
browser.close()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user