wordmodel: honor explicit underline off values

This commit is contained in:
Dylan M. Taylor committed 2026-11-14 10:05:58 +00:00
1 parent f0f4758c01
commit b473c24097
2 files changed
+14

No files matched your search

+10
View File
@@ -93,6 +93,16 @@ mod tests {
}
}
#[test]
fn explicit_off_values_disable_underline() {
for value in ["off", "false", "0"] {
assert_eq!(Underline::from_ooxml(value), Underline::None, "{value}");
}
assert_eq!(Underline::from_ooxml("none"), Underline::None);
assert_eq!(Underline::from_ooxml("single"), Underline::Single);
assert_eq!(Underline::from_ooxml("unknown"), Underline::Single);
}
/// The 16 `w14:ligatures` values of [MS-DOCX], each to its flags and back.
#[test]
fn ligature_names() {
+4
View File
@@ -51,6 +51,10 @@ impl Underline {
}
pub fn from_ooxml(s: &str) -> Underline {
Underline::ALL.iter().copied().find(|u| u.ooxml() == s).unwrap_or(match s {
// Some Word producers serialize the generic on/off values here, although the
// underline simple type normally uses `none`. Honor an explicit disable rather
// than treating an unrecognized value as the default single underline.
"off" | "false" | "0" => Underline::None,
"thickDash" | "dashLong" | "dashedHeavy" | "dashLongHeavy" => Underline::Dash,
"dottedHeavy" => Underline::Dotted,
"wavyHeavy" => Underline::Wave,