From a8fe5d665025eaf416922e7fd5478a84b9082599 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 26 Apr 2016 22:09:16 +0100 Subject: Add test for empty paragraph --- dotnet/Mammoth.Tests/DocumentConverterTests.cs | 12 +++++++++++- .../mammoth/internal/styles/parsing/StyleMapParser.cs | 12 ++++++++++-- 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 { "

This XML has a byte order mark.

"); } + [Fact] + public void EmptyParagraphsAreIgnoredByDefault() { + assertSuccessfulConversion( + ConvertToHtml("empty.docx"), + ""); + } + private void assertSuccessfulConversion(IResult 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 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(); } } } -- cgit v1.2.3