Skip to content

Commit 7970000

Browse files
authored
When removing smart tags, also remove smart tag properties (if present)
2 parents 5708226 + a0b53cf commit 7970000

5 files changed

Lines changed: 97 additions & 83 deletions

File tree

.github/workflows/dotnet.yml

Lines changed: 69 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -5,92 +5,90 @@ env:
55

66
on:
77
push:
8+
pull_request:
89

910
jobs:
1011
build:
12+
if: |
13+
github.event_name == 'push' ||
14+
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository)
1115
runs-on: ${{ matrix.os }}
1216
strategy:
1317
matrix:
1418
os: [ubuntu-latest, macos-latest, windows-latest]
1519
steps:
16-
- uses: actions/checkout@v5
17-
- name: Setup .NET
18-
uses: actions/setup-dotnet@v5
19-
with:
20-
dotnet-version: |
21-
8.0.x
22-
10.0.x
23-
- name: Restore dependencies
24-
run: dotnet restore
25-
- name: Build
26-
run: dotnet build --configuration Release --no-restore
27-
- name: Test
28-
run: dotnet test --no-build --verbosity normal --configuration Release --logger "trx;LogFileName=${{ runner.workspace }}/OpenXmlPowerTools/TestResult/test_results.trx"
29-
- name: Publish Unit Test Results
30-
uses: actions/upload-artifact@v5
31-
if: failure()
32-
with:
33-
name: TestResult
34-
path: "TestResult/**/*"
20+
- uses: actions/checkout@v6
21+
- name: Setup .NET
22+
uses: actions/setup-dotnet@v5
23+
with:
24+
dotnet-version: |
25+
8.0.x
26+
10.0.x
27+
- name: Restore dependencies
28+
run: dotnet restore
29+
- name: Build
30+
run: dotnet build --configuration Release --no-restore
31+
- name: Test
32+
run: dotnet test --no-build --verbosity normal --configuration Release --logger "trx;LogFileName=${{ runner.workspace }}/OpenXmlPowerTools/TestResult/test_results.trx"
33+
- name: Upload build artifacts
34+
uses: actions/upload-artifact@v6
35+
if: matrix.os == 'ubuntu-latest'
36+
with:
37+
name: build-artifacts
38+
path: |
39+
OpenXmlPowerTools/bin/Release/
40+
- name: Publish Unit Test Results
41+
uses: actions/upload-artifact@v6
42+
if: failure()
43+
with:
44+
name: TestResult
45+
path: "TestResult/**/*"
3546

3647
deployRelease:
37-
if: github.ref == 'refs/heads/release'
48+
if: github.event_name == 'push' && github.ref == 'refs/heads/release'
3849
runs-on: ubuntu-latest
39-
needs: build
50+
needs: build
4051
steps:
41-
- uses: actions/checkout@v5
42-
- name: Setup .NET
43-
uses: actions/setup-dotnet@v5
44-
with:
45-
dotnet-version: |
46-
8.0.x
47-
10.0.x
48-
- name: Restore dependencies
49-
run: dotnet restore
50-
- name: Build
51-
run: dotnet build --configuration Release --no-restore
52-
- name: NugetPush
53-
env:
52+
- uses: actions/checkout@v6
53+
- name: Download build artifacts
54+
uses: actions/download-artifact@v6
55+
with:
56+
name: build-artifacts
57+
- name: NugetPush
58+
env:
5459
NUGET_TOKEN_EXISTS: ${{ secrets.NUGET_TOKEN }}
55-
if: env.NUGET_TOKEN_EXISTS != ''
56-
run: |
57-
dotnet nuget push ./OpenXmlPowerTools/bin/Release/*.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TOKEN}} --source https://api.nuget.org/v3/index.json
58-
- name: Github Release
59-
shell: bash
60-
env:
61-
GITHUB_TOKEN: ${{ github.TOKEN }}
62-
if: env.GITHUB_TOKEN != ''
63-
run: |
64-
gh release create ${{env.CURRENT_VERSION}} ./OpenXmlPowerTools/bin/Release/*.*nupkg --generate-notes
60+
if: env.NUGET_TOKEN_EXISTS != ''
61+
run: |
62+
dotnet nuget push *.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TOKEN}} --source https://api.nuget.org/v3/index.json
63+
- name: Github Release
64+
shell: bash
65+
env:
66+
GITHUB_TOKEN: ${{ github.TOKEN }}
67+
if: env.GITHUB_TOKEN != ''
68+
run: |
69+
gh release create ${{env.CURRENT_VERSION}} *.*nupkg --generate-notes
6570
6671
deployTest:
67-
if: github.ref == 'refs/heads/main'
72+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
6873
runs-on: ubuntu-latest
69-
needs: build
74+
needs: build
7075
steps:
71-
- uses: actions/checkout@v5
72-
- name: Setup .NET
73-
uses: actions/setup-dotnet@v5
74-
with:
75-
dotnet-version: |
76-
8.0.x
77-
10.0.x
78-
- name: Restore dependencies
79-
run: dotnet restore
80-
- name: Build
81-
run: dotnet build --configuration Release --no-restore
82-
- name: NugetPush
83-
env:
76+
- uses: actions/checkout@v6
77+
- name: Download build artifacts
78+
uses: actions/download-artifact@v6
79+
with:
80+
name: build-artifacts
81+
- name: NugetPush
82+
env:
8483
NUGET_TOKEN_EXISTS: ${{ secrets.NUGET_TEST_TOKEN }}
85-
if: env.NUGET_TOKEN_EXISTS != ''
86-
run: |
87-
ls ./OpenXmlPowerTools/bin/Release
88-
dotnet nuget push ./OpenXmlPowerTools/bin/Release/*.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TEST_TOKEN}} --source https://apiint.nugettest.org/v3/index.json
89-
90-
- name: Github Prerelease
91-
shell: bash
92-
env:
93-
GITHUB_TOKEN: ${{ github.TOKEN }}
94-
if: env.GITHUB_TOKEN != ''
95-
run: |
96-
gh release create ${{env.CURRENT_VERSION}} ./OpenXmlPowerTools/bin/Release/*.*nupkg --prerelease --generate-notes
84+
if: env.NUGET_TOKEN_EXISTS != ''
85+
run: |
86+
ls
87+
dotnet nuget push *.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TEST_TOKEN}} --source https://apiint.nugettest.org/v3/index.json
88+
- name: Github Prerelease
89+
shell: bash
90+
env:
91+
GITHUB_TOKEN: ${{ github.TOKEN }}
92+
if: env.GITHUB_TOKEN != ''
93+
run: |
94+
gh release create ${{env.CURRENT_VERSION}} *.*nupkg --prerelease --generate-notes

OpenXmlPowerTools.Tests/MarkupSimplifierTests.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ public class MarkupSimplifierTests
1212
{
1313
private const WordprocessingDocumentType DocumentType = WordprocessingDocumentType.Document;
1414

15-
private const string SmartTagDocumentTextValue = "The countries include Algeria, Botswana, and Sri Lanka.";
16-
15+
private const string SmartTagDocumentTextValue = "The countries include Algeria, Botswana, and Sri Lanka. This is privileged information!";
1716
private const string SmartTagDocumentXmlString =
1817
@"<w:document xmlns:w=""http://schemas.openxmlformats.org/wordprocessingml/2006/main"">
1918
<w:body>
@@ -45,7 +44,18 @@ public class MarkupSimplifierTests
4544
</w:smartTag>
4645
</w:smartTag>
4746
<w:r>
48-
<w:t>.</w:t>
47+
<w:t xml:space=""preserve"">. This is </w:t>
48+
</w:r>
49+
<w:smartTag w:uri=""schemas-workshare-com/workshare"" w:element=""confidentialinformationexposure"">
50+
<w:smartTagPr>
51+
<w:attr w:name=""TagType"" w:val=""5""/>
52+
</w:smartTagPr>
53+
<w:r>
54+
<w:t>privileged</w:t>
55+
</w:r>
56+
</w:smartTag>
57+
<w:r>
58+
<w:t xml:space=""preserve""> information!</w:t>
4959
</w:r>
5060
</w:p>
5161
</w:body>

OpenXmlPowerTools.Tests/OpenXmlPowerTools.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88
<ItemGroup>
99
<PackageReference Include="Codeuctivity.HtmlRenderer" Version="4.0.458" />
10-
<PackageReference Include="Codeuctivity.SkiaSharpCompare" Version="3.1.214" />
10+
<PackageReference Include="Codeuctivity.SkiaSharpCompare" Version="3.2.245" />
1111
<PackageReference Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="3.119.1" />
1212
<PackageReference Include="coverlet.collector" Version="6.0.4">
1313
<PrivateAssets>all</PrivateAssets>

OpenXmlPowerTools/MarkupSimplifier.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,20 @@ private static object RemoveCustomXmlAndContentControlsTransform(
191191
{
192192
if (node is XElement element)
193193
{
194-
if (simplifyMarkupSettings.RemoveSmartTags &&
195-
element.Name == W.smartTag)
194+
if (simplifyMarkupSettings.RemoveSmartTags)
196195
{
197-
return element
198-
.Elements()
199-
.Select(e =>
200-
RemoveCustomXmlAndContentControlsTransform(e,
201-
simplifyMarkupSettings));
196+
if (element.Name == W.smartTag)
197+
{
198+
return element
199+
.Elements()
200+
.Select(e =>
201+
RemoveCustomXmlAndContentControlsTransform(e,
202+
simplifyMarkupSettings));
203+
}
204+
if (element.Name == W.smartTagPr)
205+
{
206+
return null;
207+
}
202208
}
203209

204210
if (simplifyMarkupSettings.RemoveContentControls &&

OpenXmlPowerToolsExamples/MarkupSimplifierApp/MarkupSimplifierApp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="System.Configuration.ConfigurationManager" Version="10.0.0" />
12+
<PackageReference Include="System.Configuration.ConfigurationManager" Version="10.0.1" />
1313
</ItemGroup>
1414

1515
<ItemGroup>

0 commit comments

Comments
 (0)