adding new extract command to extract selector or main content as markdown, updateing version as 0.5.0
Package Extension / package-extension (push) Successful in 12s
Build & Publish Package / publish (push) Failing after 21s

This commit is contained in:
2026-04-10 03:44:49 +02:00
parent 79093ed558
commit f2a7f85ee3
8 changed files with 286 additions and 2 deletions
+3
View File
@@ -247,6 +247,9 @@ class BrowserCLI:
def extract_json(self, selector: str):
return self._cmd("extract.json", {"selector": selector})
def extract_markdown(self, selector: str | None = None) -> str:
return self._cmd("extract.markdown", {"selector": selector}) or ""
# ── Session ───────────────────────────────────────────────────────────
def session_save(self, name: str) -> None:
+8
View File
@@ -73,3 +73,11 @@ def extract_html():
"""Print the full HTML of the active tab to stdout."""
html = _handle("extract.html")
click.echo(html or "")
@extract_group.command("markdown")
@click.option("--selector", help="Extract only the DOM subtree matching this CSS selector.")
def extract_markdown(selector):
"""Extract the page's main content as Markdown."""
markdown = _handle("extract.markdown", {"selector": selector})
click.echo(markdown or "", nl=not (markdown or "").endswith("\n"))