tikz-gallery-generator

Custum build of stapix for tikz.pablopie.xyz

Commit
f4f1bcff50410f655c9a62b40fb5fe4f334fc29e
Parent
7d79b58a568bf5696c8958abb9d908557fc8aa24
Author
Pablo <pablo-escobar@riseup.net>
Date

Added warnings for empty alt attributes

Diffstat

2 files changed, 9 insertions, 1 deletion

Status File Name N° Changes Insertions Deletions
Modified src/main.rs 8 8 0
Modified src/types.rs 2 1 1
diff --git a/src/main.rs b/src/main.rs
@@ -55,6 +55,14 @@ fn render_gallery(pic_infos: Vec<PictureInfo>) -> io::Result<()> {
         }
     }
 
+    // Warn the user if a particular path doesn't have an associated alt string
+    for pic in &pic_infos {
+        if pic.alt.is_empty() {
+            eprintln!("WARNING: Empty text alternative was specified for the file {name:?}",
+                      name = pic.file_name);
+        }
+    }
+
     render_index(&pic_infos)?;
 
     for pic in pic_infos {
diff --git a/src/types.rs b/src/types.rs
@@ -26,7 +26,7 @@ impl<'de> Deserialize<'de> for PictureInfo {
             Ok(
                 Self {
                     path: path.clone(),
-                    alt: alt.clone(),
+                    alt: alt.trim().to_string(),
                     file_name: String::from(file_name)
                 }
             )