diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 6afeebdf..def4e78c 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -5,92 +5,90 @@ env: on: push: + pull_request: jobs: build: + if: | + github.event_name == 'push' || + (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository) runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] steps: - - uses: actions/checkout@v5 - - name: Setup .NET - uses: actions/setup-dotnet@v5 - with: - dotnet-version: | - 8.0.x - 10.0.x - - name: Restore dependencies - run: dotnet restore - - name: Build - run: dotnet build --configuration Release --no-restore - - name: Test - run: dotnet test --no-build --verbosity normal --configuration Release --logger "trx;LogFileName=${{ runner.workspace }}/OpenXmlPowerTools/TestResult/test_results.trx" - - name: Publish Unit Test Results - uses: actions/upload-artifact@v5 - if: failure() - with: - name: TestResult - path: "TestResult/**/*" + - uses: actions/checkout@v6 + - name: Setup .NET + uses: actions/setup-dotnet@v5 + with: + dotnet-version: | + 8.0.x + 10.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --configuration Release --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal --configuration Release --logger "trx;LogFileName=${{ runner.workspace }}/OpenXmlPowerTools/TestResult/test_results.trx" + - name: Upload build artifacts + uses: actions/upload-artifact@v6 + if: matrix.os == 'ubuntu-latest' + with: + name: build-artifacts + path: | + OpenXmlPowerTools/bin/Release/ + - name: Publish Unit Test Results + uses: actions/upload-artifact@v6 + if: failure() + with: + name: TestResult + path: "TestResult/**/*" deployRelease: - if: github.ref == 'refs/heads/release' + if: github.event_name == 'push' && github.ref == 'refs/heads/release' runs-on: ubuntu-latest - needs: build + needs: build steps: - - uses: actions/checkout@v5 - - name: Setup .NET - uses: actions/setup-dotnet@v5 - with: - dotnet-version: | - 8.0.x - 10.0.x - - name: Restore dependencies - run: dotnet restore - - name: Build - run: dotnet build --configuration Release --no-restore - - name: NugetPush - env: + - uses: actions/checkout@v6 + - name: Download build artifacts + uses: actions/download-artifact@v6 + with: + name: build-artifacts + - name: NugetPush + env: NUGET_TOKEN_EXISTS: ${{ secrets.NUGET_TOKEN }} - if: env.NUGET_TOKEN_EXISTS != '' - run: | - dotnet nuget push ./OpenXmlPowerTools/bin/Release/*.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TOKEN}} --source https://api.nuget.org/v3/index.json - - name: Github Release - shell: bash - env: - GITHUB_TOKEN: ${{ github.TOKEN }} - if: env.GITHUB_TOKEN != '' - run: | - gh release create ${{env.CURRENT_VERSION}} ./OpenXmlPowerTools/bin/Release/*.*nupkg --generate-notes + if: env.NUGET_TOKEN_EXISTS != '' + run: | + dotnet nuget push *.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TOKEN}} --source https://api.nuget.org/v3/index.json + - name: Github Release + shell: bash + env: + GITHUB_TOKEN: ${{ github.TOKEN }} + if: env.GITHUB_TOKEN != '' + run: | + gh release create ${{env.CURRENT_VERSION}} *.*nupkg --generate-notes deployTest: - if: github.ref == 'refs/heads/main' + if: github.event_name == 'push' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest - needs: build + needs: build steps: - - uses: actions/checkout@v5 - - name: Setup .NET - uses: actions/setup-dotnet@v5 - with: - dotnet-version: | - 8.0.x - 10.0.x - - name: Restore dependencies - run: dotnet restore - - name: Build - run: dotnet build --configuration Release --no-restore - - name: NugetPush - env: + - uses: actions/checkout@v6 + - name: Download build artifacts + uses: actions/download-artifact@v6 + with: + name: build-artifacts + - name: NugetPush + env: NUGET_TOKEN_EXISTS: ${{ secrets.NUGET_TEST_TOKEN }} - if: env.NUGET_TOKEN_EXISTS != '' - run: | - ls ./OpenXmlPowerTools/bin/Release - dotnet nuget push ./OpenXmlPowerTools/bin/Release/*.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TEST_TOKEN}} --source https://apiint.nugettest.org/v3/index.json - - - name: Github Prerelease - shell: bash - env: - GITHUB_TOKEN: ${{ github.TOKEN }} - if: env.GITHUB_TOKEN != '' - run: | - gh release create ${{env.CURRENT_VERSION}} ./OpenXmlPowerTools/bin/Release/*.*nupkg --prerelease --generate-notes + if: env.NUGET_TOKEN_EXISTS != '' + run: | + ls + dotnet nuget push *.nupkg --skip-duplicate --api-key ${{secrets.NUGET_TEST_TOKEN}} --source https://apiint.nugettest.org/v3/index.json + - name: Github Prerelease + shell: bash + env: + GITHUB_TOKEN: ${{ github.TOKEN }} + if: env.GITHUB_TOKEN != '' + run: | + gh release create ${{env.CURRENT_VERSION}} *.*nupkg --prerelease --generate-notes diff --git a/OpenXmlPowerTools.Tests/MarkupSimplifierTests.cs b/OpenXmlPowerTools.Tests/MarkupSimplifierTests.cs index 5bc7ab7b..71408483 100644 --- a/OpenXmlPowerTools.Tests/MarkupSimplifierTests.cs +++ b/OpenXmlPowerTools.Tests/MarkupSimplifierTests.cs @@ -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 = @" @@ -45,7 +44,18 @@ public class MarkupSimplifierTests - . + . This is + + + + + + + privileged + + + + information! diff --git a/OpenXmlPowerTools.Tests/OpenXmlPowerTools.Tests.csproj b/OpenXmlPowerTools.Tests/OpenXmlPowerTools.Tests.csproj index 414e9273..66430a32 100644 --- a/OpenXmlPowerTools.Tests/OpenXmlPowerTools.Tests.csproj +++ b/OpenXmlPowerTools.Tests/OpenXmlPowerTools.Tests.csproj @@ -7,7 +7,7 @@ - + all diff --git a/OpenXmlPowerTools/MarkupSimplifier.cs b/OpenXmlPowerTools/MarkupSimplifier.cs index 1240e78b..a6f4dabb 100644 --- a/OpenXmlPowerTools/MarkupSimplifier.cs +++ b/OpenXmlPowerTools/MarkupSimplifier.cs @@ -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 && diff --git a/OpenXmlPowerToolsExamples/MarkupSimplifierApp/MarkupSimplifierApp.csproj b/OpenXmlPowerToolsExamples/MarkupSimplifierApp/MarkupSimplifierApp.csproj index 2378dfaa..c9e62b42 100644 --- a/OpenXmlPowerToolsExamples/MarkupSimplifierApp/MarkupSimplifierApp.csproj +++ b/OpenXmlPowerToolsExamples/MarkupSimplifierApp/MarkupSimplifierApp.csproj @@ -9,7 +9,7 @@ - +