aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-04-26 22:09:16 +0100
committerMichael Williamson <mike@zwobble.org>2016-04-26 22:09:16 +0100
commita8fe5d665025eaf416922e7fd5478a84b9082599 (patch)
treed8d0cc36c09d4a6cf0123ed14ee140bf151703fd
parent074bf195ebc0c59b1335983904ab0176996ceef5 (diff)
Add test for empty paragraph
-rw-r--r--dotnet/Mammoth.Tests/DocumentConverterTests.cs12
-rw-r--r--dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/StyleMapParser.cs12
2 files changed, 21 insertions, 3 deletions
diff --git a/dotnet/Mammoth.Tests/DocumentConverterTests.cs b/dotnet/Mammoth.Tests/DocumentConverterTests.cs
index adfd368..c467d74 100644
--- a/dotnet/Mammoth.Tests/DocumentConverterTests.cs
+++ b/dotnet/Mammoth.Tests/DocumentConverterTests.cs
@@ -1,5 +1,6 @@
using Xunit;
using System.IO;
+using Xunit.Sdk;
namespace Mammoth.Tests {
public class DocumentConverterTests {
@@ -17,8 +18,17 @@ namespace Mammoth.Tests {
"<p>This XML has a byte order mark.</p>");
}
+ [Fact]
+ public void EmptyParagraphsAreIgnoredByDefault() {
+ assertSuccessfulConversion(
+ ConvertToHtml("empty.docx"),
+ "");
+ }
+
private void assertSuccessfulConversion(IResult<string> result, string expectedValue) {
- Assert.Empty(result.Warnings);
+ if (result.Warnings.Count > 0) {
+ throw new XunitException("Unexpected warnings: " + string.Join(", ", result.Warnings));
+ }
Assert.Equal(expectedValue, result.Value);
}
diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/StyleMapParser.cs b/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/StyleMapParser.cs
index 44d1ddd..53315f3 100644
--- a/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/StyleMapParser.cs
+++ b/dotnet/Mammoth/Couscous/mammoth/internal/styles/parsing/StyleMapParser.cs
@@ -4,11 +4,19 @@ using Mammoth.Couscous.org.zwobble.mammoth.@internal.styles;
namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.styles.parsing {
internal static class StyleMapParser {
internal static StyleMap parseStyleMappings(List<string> mappings) {
- return StyleMap.builder().build();
+ return DefaultStyleMap();
}
internal static StyleMap parse(string styleMap) {
- return StyleMap.builder().build();
+ return DefaultStyleMap();
+ }
+
+ private static StyleMap DefaultStyleMap() {
+ return StyleMap.builder()
+
+ .mapParagraph(ParagraphMatcher.styleName("Normal"), HtmlPath.element("p"))
+
+ .build();
}
}
}