From d8ff620412641d5a94085df703a8321e5964ae33 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 6 Nov 2020 18:54:59 +0000 Subject: Add style mapping for all caps --- src/main/java/org/zwobble/mammoth/internal/styles/StyleMap.java | 8 ++++++++ .../java/org/zwobble/mammoth/internal/styles/StyleMapBuilder.java | 8 ++++++++ .../mammoth/internal/styles/parsing/DocumentMatcherParser.java | 2 ++ 3 files changed, 18 insertions(+) (limited to 'src/main/java/org/zwobble/mammoth/internal/styles') diff --git a/src/main/java/org/zwobble/mammoth/internal/styles/StyleMap.java b/src/main/java/org/zwobble/mammoth/internal/styles/StyleMap.java index 2b1d19a..1b094fd 100644 --- a/src/main/java/org/zwobble/mammoth/internal/styles/StyleMap.java +++ b/src/main/java/org/zwobble/mammoth/internal/styles/StyleMap.java @@ -24,6 +24,7 @@ public class StyleMap { Optionals.first(high.italic, low.italic), Optionals.first(high.underline, low.underline), Optionals.first(high.strikethrough, low.strikethrough), + Optionals.first(high.allCaps, low.allCaps), Optionals.first(high.smallCaps, low.smallCaps), Optionals.first(high.commentReference, low.commentReference), Lists.eagerConcat(high.paragraphStyles, low.paragraphStyles), @@ -39,6 +40,7 @@ public class StyleMap { private final Optional italic; private final Optional underline; private final Optional strikethrough; + private final Optional allCaps; private final Optional smallCaps; private final Optional commentReference; private final List> paragraphStyles; @@ -51,6 +53,7 @@ public class StyleMap { Optional italic, Optional underline, Optional strikethrough, + Optional allCaps, Optional smallCaps, Optional commentReference, List> paragraphStyles, @@ -63,6 +66,7 @@ public class StyleMap { this.italic = italic; this.underline = underline; this.strikethrough = strikethrough; + this.allCaps = allCaps; this.smallCaps = smallCaps; this.commentReference = commentReference; this.paragraphStyles = paragraphStyles; @@ -92,6 +96,10 @@ public class StyleMap { return strikethrough; } + public Optional getAllCaps() { + return allCaps; + } + public Optional getSmallCaps() { return smallCaps; } diff --git a/src/main/java/org/zwobble/mammoth/internal/styles/StyleMapBuilder.java b/src/main/java/org/zwobble/mammoth/internal/styles/StyleMapBuilder.java index dbd4fa8..2d90219 100644 --- a/src/main/java/org/zwobble/mammoth/internal/styles/StyleMapBuilder.java +++ b/src/main/java/org/zwobble/mammoth/internal/styles/StyleMapBuilder.java @@ -12,6 +12,7 @@ import java.util.Optional; public class StyleMapBuilder { private Optional underline; private Optional strikethrough; + private Optional allCaps; private Optional smallCaps; private Optional bold; private Optional italic; @@ -25,6 +26,7 @@ public class StyleMapBuilder { this.bold = Optional.empty(); this.underline = Optional.empty(); this.strikethrough = Optional.empty(); + this.allCaps = Optional.empty(); this.smallCaps = Optional.empty(); this.italic = Optional.empty(); this.commentReference = Optional.empty(); @@ -50,6 +52,11 @@ public class StyleMapBuilder { return this; } + public StyleMapBuilder allCaps(HtmlPath path) { + this.allCaps = Optional.of(path); + return this; + } + public StyleMapBuilder smallCaps(HtmlPath path) { this.smallCaps = Optional.of(path); return this; @@ -86,6 +93,7 @@ public class StyleMapBuilder { italic, underline, strikethrough, + allCaps, smallCaps, commentReference, paragraphStyles, diff --git a/src/main/java/org/zwobble/mammoth/internal/styles/parsing/DocumentMatcherParser.java b/src/main/java/org/zwobble/mammoth/internal/styles/parsing/DocumentMatcherParser.java index f955431..fdd2797 100644 --- a/src/main/java/org/zwobble/mammoth/internal/styles/parsing/DocumentMatcherParser.java +++ b/src/main/java/org/zwobble/mammoth/internal/styles/parsing/DocumentMatcherParser.java @@ -30,6 +30,8 @@ public class DocumentMatcherParser { return StyleMapBuilder::underline; case "strike": return StyleMapBuilder::strikethrough; + case "all-caps": + return StyleMapBuilder::allCaps; case "small-caps": return StyleMapBuilder::smallCaps; case "comment-reference": -- cgit v1.2.3