diff options
Diffstat (limited to 'src/main/java/org/zwobble/mammoth/styles/StyleMap.java')
| -rw-r--r-- | src/main/java/org/zwobble/mammoth/styles/StyleMap.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/main/java/org/zwobble/mammoth/styles/StyleMap.java b/src/main/java/org/zwobble/mammoth/styles/StyleMap.java index 1db5c65..383554f 100644 --- a/src/main/java/org/zwobble/mammoth/styles/StyleMap.java +++ b/src/main/java/org/zwobble/mammoth/styles/StyleMap.java @@ -1,5 +1,12 @@ package org.zwobble.mammoth.styles; +import org.zwobble.mammoth.documents.Paragraph; + +import java.util.Map; +import java.util.Optional; + +import static org.zwobble.mammoth.util.MammothLists.list; + public class StyleMap { public static StyleMapBuilder builder() { return new StyleMapBuilder(); @@ -9,10 +16,12 @@ public class StyleMap { private final HtmlPath underline; private final HtmlPath strikethrough; + private final Map<String, HtmlPath> paragraphStyles; - public StyleMap(HtmlPath underline, HtmlPath strikethrough) { + public StyleMap(HtmlPath underline, HtmlPath strikethrough, Map<String, HtmlPath> paragraphStyles) { this.underline = underline; this.strikethrough = strikethrough; + this.paragraphStyles = paragraphStyles; } public HtmlPath getUnderline() { @@ -22,4 +31,10 @@ public class StyleMap { public HtmlPath getStrikethrough() { return strikethrough; } + + public HtmlPath getParagraphStyleMapping(Paragraph paragraph) { + return paragraph.getStyle() + .flatMap(style -> Optional.ofNullable(paragraphStyles.get(style.getStyleId()))) + .orElse(new HtmlPath(list(HtmlPath.element("p")))); + } } |
