diff --git a/.github/workflows/batch-check.yaml b/.github/workflows/batch-check.yaml index 4753b9d8..641fc427 100644 --- a/.github/workflows/batch-check.yaml +++ b/.github/workflows/batch-check.yaml @@ -118,3 +118,60 @@ jobs: run: | $files = Get-ChildItem test-cases\check-switch-tests\*tex foreach ($file in $files) {perl latexindent.pl --check -s $file} + cjk-windows-exe-test: + needs: check-pm-files-changed + if: ${{fromJSON(needs.check-pm-files-changed.outputs.anychanged)}} + name: 'create Windows executable latexindent.exe using Strawberry Perl 5.32 on Windows' + runs-on: 'windows-latest' + steps: + # + # checkout github.com/cmhughes/latexindent.pl + # https://github.com/actions/checkout + # + - name: load the "base actions/checkout" so as to access latexindent.pl + uses: actions/checkout@v4 + # + # https://github.com/marketplace/actions/setup-perl-environment + # + - name: install Strawberry Perl + uses: shogo82148/actions-setup-perl@v1 + with: + perl-version: '5.32' + distribution: strawberry + - name: install Perl modules using cpan + run: | + wmic os get osarchitecture + cpanm -f PAR::Packer + cpanm YAML::Tiny + cpanm File::HomeDir + cpanm Unicode::GCString + - name: preparations for PAR packer + run: | + sed -i'.bak' -r 's,eval\s\"use\sUnicode::GCString\"\sif\s\$switches\{GCString\},use Unicode::GCString,' latexindent.pl + SET PAR_VERBATIM=1 + # + # https://metacpan.org/pod/pp + # https://github.com/plk/biber/blob/dev/dist/MSWIN64/build.bat + # + - name: create latexindent.exe using PAR Packer + run: >- + pp + --addfile="defaultSettings.yaml;lib/LatexIndent/defaultSettings.yaml" + --cachedeps=scancache + --output latexindent.exe + latexindent.pl + - name: latexindent.exe help + run: | + ./latexindent.exe --help + - name: latexindent.exe replacement test, issue 503 + # https://github.com/cmhughes/latexindent.pl/issues/503 + run: | + cd test-cases/replacements/ + ./latexindent.exe -l issue-503b.yaml -r issue-503a.tex + cat indent.log + - name: latexindent.exe cjk test, issue 505 + # https://github.com/cmhughes/latexindent.pl/issues/505 + run: | + cd ../../test-cases/back-up-tests/ + ./latexindent.exe -w 新建.tex -y 'onlyOneBackUp:1' + cat indent.log diff --git a/LatexIndent/Replacement.pm b/LatexIndent/Replacement.pm index c1df5db1..a261c4dc 100644 --- a/LatexIndent/Replacement.pm +++ b/LatexIndent/Replacement.pm @@ -71,7 +71,7 @@ sub make_replacements { # my $this = quotemeta( ${$_}{this} ); my $that = ( defined ${$_}{that} ) ? qq{${$_}{that}} : q(); - ${$self}{body} = join( $that, split( $this, ${$self}{body} ) ); + ${$self}{body} = join( $that, split( /$this/, ${$self}{body}, -1 ) ); } else { # diff --git a/test-cases/back-up-tests/back-up-tests.sh b/test-cases/back-up-tests/back-up-tests.sh index 80ea25d9..adfff97b 100755 --- a/test-cases/back-up-tests/back-up-tests.sh +++ b/test-cases/back-up-tests/back-up-tests.sh @@ -18,7 +18,7 @@ latexindent.pl -s -wd -l backup2.yaml -g three.log myfile cp three.log backup-info3.txt perl -p0i -e 's/.*?(INFO:\s*\-wd)/$1/s' backup-info3.txt -latexindent.pl -w 新建.tex -g issue-505.log -y 'onlyOneBackUp:1' +latexindent.pl -s -w 新建.tex -g issue-505.log -y 'onlyOneBackUp:1' cp issue-505.log issue-505.txt perl -p0i -e 's/.*?(INFO:\s*Backup)/$1/s' issue-505.txt