Add replace-listings
This commit is contained in:
parent
4a476b45d9
commit
7813884bb7
|
@ -21,6 +21,10 @@ let
|
|||
remove-special-characters = pkgs.writeScriptBin
|
||||
"remove-special-characters"
|
||||
"${builtins.readFile ./remove_special_characters.sh}";
|
||||
|
||||
replace-listings = pkgs.writeScriptBin
|
||||
"replace-listings"
|
||||
"${builtins.readFile ./replace-listings.sh}";
|
||||
in
|
||||
{
|
||||
environment.systemPackages = [
|
||||
|
@ -28,6 +32,7 @@ in
|
|||
files-to-lowercase
|
||||
heif-to-jpeg
|
||||
remove-special-characters
|
||||
replace-listings
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/env bash
|
||||
function replace-listings(){
|
||||
sed -i -e 's/end{lstlisting}/end{sexylisting}/g' $1
|
||||
for fn in `grep 'begin{lstlisting}' $1`; do
|
||||
caption=$(grep -m 1 -B 1 -P 'begin{lstlisting}' $1 |
|
||||
grep -oP 'caption={\K[^\}]+')
|
||||
sed -i "0,/begin{lstlisting}/ s/{lstlisting}/{sexylisting}{$caption}/" $1
|
||||
done
|
||||
}
|
||||
replace-listings $1
|
||||
exit 0
|
Loading…
Reference in New Issue