use html2md on web_fetch (fixes #3)
This commit is contained in:
parent
d5aad5c1a4
commit
e17c46edc1
2 changed files with 5 additions and 1 deletions
|
|
@ -20,6 +20,7 @@ edition.workspace = true
|
|||
|
||||
[dependencies]
|
||||
anyhow = "1"
|
||||
html2md = "0.2"
|
||||
crossterm = { version = "0.29", features = ["event-stream", "bracketed-paste", "osc52"] }
|
||||
clap = { version = "4", features = ["derive"] }
|
||||
figment = { version = "0.10", features = ["env"] }
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use std::sync::Arc;
|
|||
|
||||
use anyhow::{Context, Result};
|
||||
use serde::Deserialize;
|
||||
use html2md::parse_html;
|
||||
|
||||
pub fn tools() -> [super::Tool; 2] {
|
||||
[
|
||||
|
|
@ -42,7 +43,9 @@ async fn web_fetch(args: &serde_json::Value) -> Result<String> {
|
|||
let body = response.text().await
|
||||
.with_context(|| format!("failed to read body from {}", a.url))?;
|
||||
|
||||
Ok(super::truncate_output(body, 30000))
|
||||
// Convert HTML to Markdown, then truncate
|
||||
let markdown = parse_html(&body);
|
||||
Ok(super::truncate_output(markdown, 30000))
|
||||
}
|
||||
|
||||
// ── Search ──────────────────────────────────────────────────────
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue