Handle Wikipedia code blocks in /fetch command (#12780)

This PR extends the `/fetch` command with support for Wikipedia code
blocks.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers
2024-06-07 12:54:33 -04:00
committed by GitHub
parent 9174858225
commit 834089feb1
3 changed files with 107 additions and 4 deletions
@@ -43,12 +43,15 @@ impl FetchSlashCommand {
Box::new(markdown::ListHandler),
Box::new(markdown::TableHandler::new()),
Box::new(markdown::StyledTextHandler),
Box::new(markdown::CodeHandler),
];
if url.contains("wikipedia.org") {
use html_to_markdown::structure::wikipedia;
handlers.push(Box::new(wikipedia::WikipediaChromeRemover));
handlers.push(Box::new(wikipedia::WikipediaInfoboxHandler));
handlers.push(Box::new(wikipedia::WikipediaCodeHandler::new()));
} else {
handlers.push(Box::new(markdown::CodeHandler));
}
convert_html_to_markdown(&body[..], handlers)