diff options
author | Norbert Preining <norbert@preining.info> | 2020-01-18 03:01:23 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-01-18 03:01:23 +0000 |
commit | 22d3a7ddeb2b2637308cf883f9bd3590e649aa20 (patch) | |
tree | e5887f868c532734a8cac1c7833f5492370effb5 /macros/latex/contrib/thorshammer/system-scripts/standalone/mkcfg.ps1 | |
parent | e71ffee2103e3f137bbc9ee526858bc277e95908 (diff) |
CTAN sync 202001180301
Diffstat (limited to 'macros/latex/contrib/thorshammer/system-scripts/standalone/mkcfg.ps1')
-rw-r--r-- | macros/latex/contrib/thorshammer/system-scripts/standalone/mkcfg.ps1 | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/macros/latex/contrib/thorshammer/system-scripts/standalone/mkcfg.ps1 b/macros/latex/contrib/thorshammer/system-scripts/standalone/mkcfg.ps1 new file mode 100644 index 0000000000..53d6794689 --- /dev/null +++ b/macros/latex/contrib/thorshammer/system-scripts/standalone/mkcfg.ps1 @@ -0,0 +1,71 @@ +# Make a complete cfg for thorshammer package from a csv list +# accepted list delimiters: , or ;. Spaces ar not allowed! Replace all german umlauts +# with ue, oe, ae, ss to avoid problems with thorshammer package +# +$classPath="C:\Users\dpstory\Desktop\Test Folder\target\myClass" +$instrPath="C:\Users\dpstory\Desktop\Test Folder\target\_Thor" +# Example list: +# First Name|Last Name|Folder +# Anton;Müller;AM29914M +#\classMember{Anton}{Mueller}{AM299/instructor-name} +# Anton;Müller;*C:/.../AM299 +#\classMember{Anton}{Mueller}*{C:/.../AM299/instructor-name} +# +If ( $args.Length -eq 0 ) { + Write-Host "A CSV file of the class members is required," ` + "see documentation" + exit +} else { + $listName=$args[0] + if(Test-Path -Path ./$listName.csv) { + } else { + Write-Host "Cannot find the file `"$listName.csv`" in the current folder," ` + "check the spelling, do not include the extension." + exit + } +} +get-content "$listName.csv" | foreach { +"\classMember{" + $_ ` ++ "/_Thor}" ` +-Replace ";", "}{" ` +-Replace ",","}{" ` +-Replace "{\*", "*{" } | Set-Content "convertedList.cfg" + +# Store convertedList.cfg in a variable +$convertedListCfg = get-content .\convertedList.cfg -Raw + +# function to replace umlauts +# https://www.datenteiler.de/powershell-umlaute-ersetzen/ +function Replace-Umlaute ([string]$s) { + $UmlautObject = New-Object PSObject | Add-Member -MemberType NoteProperty -Name Name -Value $s -PassThru + + # hash tables are by default case insensitive + # we have to create a new hash table object for case sensitivity + + $characterMap = New-Object system.collections.hashtable + $characterMap.ä = "ae" + $characterMap.ö = "oe" + $characterMap.ü = "ue" + $characterMap.ß = "ss" + $characterMap.Ä = "Ae" + $characterMap.Ü = "Ue" + $characterMap.Ö = "Oe" + + foreach ($property in "Name") { + foreach ($key in $characterMap.Keys) { + $UmlautObject.$property = $UmlautObject.$property -creplace $key,$characterMap[$key] + } + } + $UmlautObject +} + +# replace umlauts in .cfg and make a correctedListCfg +$correctedListCfg = Replace-Umlaute "$convertedListCfg" +$correctedListCfg.Name + +# Finally append correctedListCfg to desired +# cfg file, usually 00-class.cfg +add-content "00-class.cfg" "\classPath{$classPath)" +add-content "00-class.cfg" "\instrPath{$instrPath}" +add-content "00-class.cfg" $correctedListCfg.Name +Remove-Item convertedList.cfg |