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
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:
@@ -11,11 +11,11 @@ repository.workspace = true
|
||||
[package.metadata.convertis]
|
||||
id = "pandoc"
|
||||
api-version = 2
|
||||
debian-dependencies = ["pandoc"]
|
||||
rpm-dependencies = ["/usr/bin/pandoc"]
|
||||
debian-dependencies = ["pandoc", "texlive-latex-recommended"]
|
||||
rpm-dependencies = ["/usr/bin/pandoc", "texlive-collection-latexrecommended"]
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
convertis-plugin-api.workspace = true
|
||||
convertis-plugin-api.workspace = true
|
||||
|
||||
@@ -54,6 +54,7 @@ const IMAGES: &[&str] = &["png", "jpeg", "gif", "webp", "bmp", "tiff", "ico"];
|
||||
const MAGICK_IMAGES: &[&str] = &[
|
||||
"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> {
|
||||
tracing::trace!(
|
||||
@@ -165,6 +166,12 @@ pub fn official_plugins() -> Vec<PluginMetadata> {
|
||||
.map(|from| Conversion::file(from, "text", (255, 180, 230)))
|
||||
.collect(),
|
||||
),
|
||||
metadata(
|
||||
"pandoc",
|
||||
"convertis-pandoc",
|
||||
"Pandoc document conversion",
|
||||
all_pairs(DOCUMENTS, (240, 210, 180)),
|
||||
),
|
||||
];
|
||||
|
||||
let mut to_frames: Vec<_> = VIDEO_INPUTS
|
||||
@@ -296,5 +303,6 @@ mod tests {
|
||||
recommend_packages("mp4", "frames"),
|
||||
vec!["convertis-ffmpeg-video-to-frames"]
|
||||
);
|
||||
assert_eq!(recommend_packages("html", "pdf"), vec!["convertis-pandoc"]);
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -260,6 +260,7 @@ fn main() {
|
||||
}
|
||||
let options = parse_options(&args.options).unwrap_or_else(|error| fail(error));
|
||||
let mut banned = Vec::new();
|
||||
let mut route_failures = Vec::new();
|
||||
|
||||
let result = loop {
|
||||
tracing::debug!(
|
||||
@@ -277,6 +278,14 @@ fn main() {
|
||||
&banned,
|
||||
) else {
|
||||
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);
|
||||
tracing::trace!(?packages, "resolved package recommendations");
|
||||
if packages.is_empty() {
|
||||
@@ -348,6 +357,7 @@ fn main() {
|
||||
}
|
||||
Err((error, plugin)) => {
|
||||
tracing::warn!("plugin {plugin} failed: {error}; trying another route");
|
||||
route_failures.push((plugin.clone(), error));
|
||||
banned.push(plugin);
|
||||
tracing::trace!(?banned, "updated failed-plugin exclusion list");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user