Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions OpenXmlPowerTools.Tests/MarkupSimplifierTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public class MarkupSimplifierTests
{
private const WordprocessingDocumentType DocumentType = WordprocessingDocumentType.Document;

private const string SmartTagDocumentTextValue = "The countries include Algeria, Botswana, and Sri Lanka.";

private const string SmartTagDocumentTextValue = "The countries include Algeria, Botswana, and Sri Lanka. This is privileged information!";
private const string SmartTagDocumentXmlString =
@"<w:document xmlns:w=""http://schemas.openxmlformats.org/wordprocessingml/2006/main"">
<w:body>
Expand Down Expand Up @@ -45,7 +44,18 @@ public class MarkupSimplifierTests
</w:smartTag>
</w:smartTag>
<w:r>
<w:t>.</w:t>
<w:t xml:space=""preserve"">. This is </w:t>
</w:r>
<w:smartTag w:uri=""schemas-workshare-com/workshare"" w:element=""confidentialinformationexposure"">
<w:smartTagPr>
<w:attr w:name=""TagType"" w:val=""5""/>
</w:smartTagPr>
<w:r>
<w:t>privileged</w:t>
</w:r>
</w:smartTag>
<w:r>
<w:t xml:space=""preserve""> information!</w:t>
</w:r>
</w:p>
</w:body>
Expand Down
20 changes: 13 additions & 7 deletions OpenXmlPowerTools/MarkupSimplifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,20 @@ private static object RemoveCustomXmlAndContentControlsTransform(
{
if (node is XElement element)
{
if (simplifyMarkupSettings.RemoveSmartTags &&
element.Name == W.smartTag)
if (simplifyMarkupSettings.RemoveSmartTags)
{
return element
.Elements()
.Select(e =>
RemoveCustomXmlAndContentControlsTransform(e,
simplifyMarkupSettings));
if (element.Name == W.smartTag)
{
return element
.Elements()
.Select(e =>
RemoveCustomXmlAndContentControlsTransform(e,
simplifyMarkupSettings));
}
if (element.Name == W.smartTagPr)
{
return null;
}
}

if (simplifyMarkupSettings.RemoveContentControls &&
Expand Down