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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 107 additions and 4 deletions

View file

@ -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)