aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-02-14 11:23:35 +0000
committerMichael Williamson <mike@zwobble.org>2016-02-14 11:23:35 +0000
commitf33735eb241e0bd590036dcba4a084074a681543 (patch)
tree360fd9a8f082f8ea37d62f226afcf001027c5f00
parent67a6d352cd536526fbd8d5f3d317d7cc9978f69b (diff)
Wrap strikethough runs in <s> by default
-rw-r--r--src/main/java/org/zwobble/mammoth/DocumentConverter.java7
-rw-r--r--src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java7
2 files changed, 12 insertions, 2 deletions
diff --git a/src/main/java/org/zwobble/mammoth/DocumentConverter.java b/src/main/java/org/zwobble/mammoth/DocumentConverter.java
index 4efe497..583d8bd 100644
--- a/src/main/java/org/zwobble/mammoth/DocumentConverter.java
+++ b/src/main/java/org/zwobble/mammoth/DocumentConverter.java
@@ -35,12 +35,15 @@ public class DocumentConverter {
@Override
public List<HtmlNode> visit(Run run) {
List<HtmlNode> nodes = convertChildrenToHtml(run);
- if (run.isBold()) {
- nodes = list(Html.element("strong", nodes));
+ if (run.isStrikethrough()) {
+ nodes = list(Html.element("s", nodes));
}
if (run.isItalic()) {
nodes = list(Html.element("em", nodes));
}
+ if (run.isBold()) {
+ nodes = list(Html.element("strong", nodes));
+ }
return nodes;
}
diff --git a/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java b/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java
index f6125ed..a0c0a66 100644
--- a/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java
+++ b/src/test/java/org/zwobble/mammoth/tests/DocumentConverterTests.java
@@ -59,6 +59,13 @@ public class DocumentConverterTests {
deepEquals(list(Html.text("Hello"))));
}
+ @Test
+ public void struckthroughRunsAreWrappedInStrikethroughTagsByDefault() {
+ assertThat(
+ convertToHtml(make(a(RUN, with(STRIKETHROUGH, true), with(CHILDREN, list(new Text("Hello")))))),
+ deepEquals(list(Html.element("s", list(Html.text("Hello"))))));
+ }
+
private List<HtmlNode> convertToHtml(DocumentElement element) {
return DocumentConverter.convertToHtml(element);