Skip to content

Commit 6a12db3

Browse files
committed
Modified changelog parser to deal with special chars
Namely added additional replacements for anything in a html tag (like <code> </code>) and used powershell to help remove any `!` and `<`/`>` characters which were messing things up
1 parent 53b83ac commit 6a12db3

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

batch encoder.bat

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@echo off
22
setlocal enabledelayedexpansion
33

4-
set CurrentVersion=v1.7.0
4+
set CurrentVersion=v1.7.1
55
cls
66

77
set "icongray="
@@ -125,13 +125,17 @@ if defined par_updated-from (
125125
set "UpdateVersion=v%ver:~1%"
126126

127127
>%TEMP%\batch_update.tmp findstr "body" %updateFileName%
128-
<%TEMP%\batch_update.tmp set /p "entry_body="
129-
set "changelog=%entry_body:~11,-1%"
128+
set "pwsh_replace=-replace '^!' -replace '^<\/\S*?^>', '#[FORMEND]#' -replace '^<\S*?^>', '#[FORM]#' -replace '^<', '(less)' -replace '^>', '(more)'"
129+
for /F "tokens=*" %%g in ('powershell -Command "(Get-Content $env:TEMP\batch_update.tmp) !pwsh_replace! "') do (set entry_body=%%g)
130+
set "changelog=%entry_body:~9,-1%"
131+
set "changelog=%changelog:#[FORM]#=%"
132+
set "changelog=%changelog:#[FORMEND]#=!formatend!%"
130133
set "changelog=%changelog:\n#=\n\r\n#%"
131134
set "changelog=%changelog:#=#%"
132135
set "changelog=%changelog:\r=!formatend!\r%"
133136
set "changelog=%changelog: `= %"
134137
set "changelog=%changelog:` =!formatend! %"
138+
135139
>%TEMP%\batch_update.tmp echo %changelog%
136140
for %%? in (%TEMP%\batch_update.tmp) do (set /A strlength=%%~z? - 2)
137141
if %strlength% gtr 1000 (set "changelog=%changelog:~0,1000%... %textgray%[More]%formatend%")
@@ -167,6 +171,7 @@ if defined par_updated-from (
167171
echo %iconyellow% ^^! %formatend% Differing version found^^! ^(%textred%%CurrentVersion%%formatend% -^> %textgreen%%UpdateVersion%%formatend%^)
168172
echo Proceeding with update in 5 seconds; close window to cancel.
169173
)
174+
:: ... anim
170175
echo. & echo 
171176
for /l %%x in (1, 1, 6) do (
172177
timeout /nobreak /t 1 > nul

0 commit comments

Comments
 (0)