aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/zwobble/mammoth/styles/StyleMapBuilder.java
blob: b33e0db72a3fa73b43ab7add95b33c28aed44aa1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package org.zwobble.mammoth.styles;

import com.google.common.collect.ImmutableList;

public class StyleMapBuilder {
    private HtmlPath underline;
    private HtmlPath strikethrough;
    private final ImmutableList.Builder<StyleMapping> paragraphStyles = ImmutableList.builder();

    public StyleMapBuilder() {
        this.underline = HtmlPath.EMPTY;
        this.strikethrough = HtmlPath.collapsibleElement("s");
    }

    public StyleMapBuilder underline(HtmlPath path) {
        this.underline = path;
        return this;
    }

    public StyleMapBuilder strikethrough(HtmlPath path) {
        this.strikethrough = path;
        return this;
    }

    public StyleMapBuilder mapParagraph(ParagraphMatcher paragraphMatcher, HtmlPath path) {
        paragraphStyles.add(new StyleMapping(paragraphMatcher, path));
        return this;
    }

    public StyleMap build() {
        return new StyleMap(underline, strikethrough, paragraphStyles.build());
    }
}