From 47a53a67199033258a953cc5b71981328eab7e49 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 28 Apr 2016 22:07:05 +0100 Subject: Enable AddStyleMap --- dotnet/Mammoth.Tests/DocumentConverterTests.cs | 21 +++++++++++++++++++++ dotnet/Mammoth/DocumentConverter.cs | 7 +++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/dotnet/Mammoth.Tests/DocumentConverterTests.cs b/dotnet/Mammoth.Tests/DocumentConverterTests.cs index 8f34fea..8788b9d 100644 --- a/dotnet/Mammoth.Tests/DocumentConverterTests.cs +++ b/dotnet/Mammoth.Tests/DocumentConverterTests.cs @@ -115,6 +115,27 @@ namespace Mammoth.Tests { "

Datum plane

"); } + [Fact] + public void CanUseCustomStyleMap() { + AssertSuccessfulConversion( + ConvertToHtml("underline.docx", mammoth => mammoth.AddStyleMap("u => em")), + "

The Sunset Tree

"); + } + + [Fact] + public void MostRecentlyAddedStyleMapTakesPrecedence() { + AssertSuccessfulConversion( + ConvertToHtml("underline.docx", mammoth => mammoth.AddStyleMap("u => em").AddStyleMap("u => strong")), + "

The Sunset Tree

"); + } + + [Fact] + public void RulesFromPreviouslyAddedStyleMapsStillTakeEffectIfNotOverriden() { + AssertSuccessfulConversion( + ConvertToHtml("underline.docx", mammoth => mammoth.AddStyleMap("u => em").AddStyleMap("strike => del")), + "

The Sunset Tree

"); + } + [Fact] public void CanExtractRawTextFromFile() { AssertSuccessfulConversion( diff --git a/dotnet/Mammoth/DocumentConverter.cs b/dotnet/Mammoth/DocumentConverter.cs index 5a439d3..04dc632 100644 --- a/dotnet/Mammoth/DocumentConverter.cs +++ b/dotnet/Mammoth/DocumentConverter.cs @@ -22,10 +22,9 @@ namespace Mammoth { return new DocumentConverter(options.preserveEmptyParagraphs()); } - // TODO -// public DocumentConverter AddStyleMap(string styleMap) { -// return new DocumentConverter(options.addStyleMap(styleMap)); -// } + public DocumentConverter AddStyleMap(string styleMap) { + return new DocumentConverter(options.addStyleMap(styleMap)); + } // // public DocumentConverter DisableDefaultStyleMap() { // return new DocumentConverter(options.disableDefaultStyleMap()); -- cgit v1.2.3