feat: add pandoc plugin for document conversion and implement error reporting for failed conversion routes
Release / check-release (push) Successful in 22s
Release / build (push) Skipped
Release / package (deb) (push) Skipped
Release / package (rpm) (push) Skipped
Release / publish (push) Skipped
CI / test (push) Successful in 1m45s
Plugin Releases / build-package-publish (push) Successful in 2m10s

This commit is contained in:
Elias Wendland committed 2026-07-18 12:22:18 +02:00
1 parent 726628b641
commit 362fa474ab
3 files changed
+21 -3

No files matched your search

+3 -3
View File
@@ -11,11 +11,11 @@ repository.workspace = true
[package.metadata.convertis] [package.metadata.convertis]
id = "pandoc" id = "pandoc"
api-version = 2 api-version = 2
debian-dependencies = ["pandoc"] debian-dependencies = ["pandoc", "texlive-latex-recommended"]
rpm-dependencies = ["/usr/bin/pandoc"] rpm-dependencies = ["/usr/bin/pandoc", "texlive-collection-latexrecommended"]
[lib] [lib]
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
convertis-plugin-api.workspace = true convertis-plugin-api.workspace = true
+8
View File
@@ -54,6 +54,7 @@ const IMAGES: &[&str] = &["png", "jpeg", "gif", "webp", "bmp", "tiff", "ico"];
const MAGICK_IMAGES: &[&str] = &[ const MAGICK_IMAGES: &[&str] = &[
"png", "jpeg", "gif", "webp", "bmp", "tiff", "ico", "avif", "heic", "jxl", "svg", "pdf", "png", "jpeg", "gif", "webp", "bmp", "tiff", "ico", "avif", "heic", "jxl", "svg", "pdf",
]; ];
const DOCUMENTS: &[&str] = &["md", "html", "pdf", "docx", "ltx", "epub"];
fn all_pairs(formats: &[&str], scores: (u8, u8, u8)) -> Vec<Conversion> { fn all_pairs(formats: &[&str], scores: (u8, u8, u8)) -> Vec<Conversion> {
tracing::trace!( tracing::trace!(
@@ -165,6 +166,12 @@ pub fn official_plugins() -> Vec<PluginMetadata> {
.map(|from| Conversion::file(from, "text", (255, 180, 230))) .map(|from| Conversion::file(from, "text", (255, 180, 230)))
.collect(), .collect(),
), ),
metadata(
"pandoc",
"convertis-pandoc",
"Pandoc document conversion",
all_pairs(DOCUMENTS, (240, 210, 180)),
),
]; ];
let mut to_frames: Vec<_> = VIDEO_INPUTS let mut to_frames: Vec<_> = VIDEO_INPUTS
@@ -296,5 +303,6 @@ mod tests {
recommend_packages("mp4", "frames"), recommend_packages("mp4", "frames"),
vec!["convertis-ffmpeg-video-to-frames"] vec!["convertis-ffmpeg-video-to-frames"]
); );
assert_eq!(recommend_packages("html", "pdf"), vec!["convertis-pandoc"]);
} }
} }
+10
View File
@@ -260,6 +260,7 @@ fn main() {
} }
let options = parse_options(&args.options).unwrap_or_else(|error| fail(error)); let options = parse_options(&args.options).unwrap_or_else(|error| fail(error));
let mut banned = Vec::new(); let mut banned = Vec::new();
let mut route_failures = Vec::new();
let result = loop { let result = loop {
tracing::debug!( tracing::debug!(
@@ -277,6 +278,14 @@ fn main() {
&banned, &banned,
) else { ) else {
tracing::debug!("no installed conversion route was found"); tracing::debug!("no installed conversion route was found");
if !route_failures.is_empty() {
let failures = route_failures
.iter()
.map(|(plugin, error)| format!("{plugin}: {error}"))
.collect::<Vec<_>>()
.join("; ");
fail(format!("all conversion routes failed: {failures}"));
}
let packages = catalog::recommend_packages(&detected.format, &target); let packages = catalog::recommend_packages(&detected.format, &target);
tracing::trace!(?packages, "resolved package recommendations"); tracing::trace!(?packages, "resolved package recommendations");
if packages.is_empty() { if packages.is_empty() {
@@ -348,6 +357,7 @@ fn main() {
} }
Err((error, plugin)) => { Err((error, plugin)) => {
tracing::warn!("plugin {plugin} failed: {error}; trying another route"); tracing::warn!("plugin {plugin} failed: {error}; trying another route");
route_failures.push((plugin.clone(), error));
banned.push(plugin); banned.push(plugin);
tracing::trace!(?banned, "updated failed-plugin exclusion list"); tracing::trace!(?banned, "updated failed-plugin exclusion list");
} }