chiark / gitweb /
Fix another HTML syntax error
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 17 Apr 2022 23:06:15 +0000 (00:06 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 17 Apr 2022 23:07:46 +0000 (00:07 +0100)
Define the type of `otherwise`, to be an Html variant.  And pass
HtmlStr values.  Otherwise the HTML gets re-escaped, leading to a
xyntax error.

An effect of this is that the hollow diamond is actually hollow now.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/pieces.rs

index e7123e990fd516051bfc1ffca635d22beade1f20..e06d8e399027cbd234bc4e2862fb0356b42bdf76 100644 (file)
@@ -273,7 +273,9 @@ impl<Desc, Outl:'static> GenericSimpleShape<Desc, Outl>
     &self, f: &mut Html, face: FaceId,
     stroke_attrs_hook: &mut dyn FnMut(&mut Html) -> Result<(),IE>,
   ) {
-    let ef = |f: &mut Html, cmap: &ColourMap, attrname: &str, otherwise| {
+    let ef = |f: &mut Html,
+              cmap: &ColourMap, attrname: &str,
+              otherwise: &HtmlStr| {
       if let Some(colour) = cmap.get(face) {
         hwrite!(f, r##" {}="{}""##, attrname, colour)
       } else {
@@ -289,12 +291,12 @@ impl<Desc, Outl:'static> GenericSimpleShape<Desc, Outl>
              &path)?;
     }
     hwrite!(f, r##"<path"##)?;
-    ef(f, &self.colours, "fill", r##" fill="none""##)?;
+    ef(f, &self.colours, "fill", &Html::lit(r##" fill="none""##))?;
     if self.edges.len() != 0 {
       hwrite!(f, r##" stroke-width="{}""##, &self.edge_width)?;
     }
     stroke_attrs_hook(f)?;
-    ef(f, &self.edges, "stroke", "")?;
+    ef(f, &self.edges, "stroke", default())?;
     hwrite!(f, r##" d="{}"/>"##, &path)?;
   }
 }