diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-04-28 22:07:05 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-04-28 22:07:05 +0100 |
| commit | 47a53a67199033258a953cc5b71981328eab7e49 (patch) | |
| tree | 71e76e047e4cb1be9a26b55305d5049c9e00cbad /dotnet | |
| parent | 4caa94950ef6c53d109e83172270160419225495 (diff) | |
Enable AddStyleMap
Diffstat (limited to 'dotnet')
| -rw-r--r-- | dotnet/Mammoth.Tests/DocumentConverterTests.cs | 21 | ||||
| -rw-r--r-- | 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 { "<p>Datum plane</p>"); } + [Fact] + public void CanUseCustomStyleMap() { + AssertSuccessfulConversion( + ConvertToHtml("underline.docx", mammoth => mammoth.AddStyleMap("u => em")), + "<p><strong>The <em>Sunset</em> Tree</strong></p>"); + } + + [Fact] + public void MostRecentlyAddedStyleMapTakesPrecedence() { + AssertSuccessfulConversion( + ConvertToHtml("underline.docx", mammoth => mammoth.AddStyleMap("u => em").AddStyleMap("u => strong")), + "<p><strong>The <strong>Sunset</strong> Tree</strong></p>"); + } + + [Fact] + public void RulesFromPreviouslyAddedStyleMapsStillTakeEffectIfNotOverriden() { + AssertSuccessfulConversion( + ConvertToHtml("underline.docx", mammoth => mammoth.AddStyleMap("u => em").AddStyleMap("strike => del")), + "<p><strong>The <em>Sunset</em> Tree</strong></p>"); + } + [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()); |
