Skip to content

Commit

Permalink
perf(import): Use parallel to multi-thread normalizing lots of files
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Aug 19, 2024
1 parent 42ee8a5 commit 4691d1f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions scripts/split_chapters.zsh.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ source "$CASILEDIR/scripts/functions.zsh"
alias pandoc="@PANDOC@"
alias sed="@SED@"
alias mkdir="@MKDIR_P@"
alias parallel="@PARALLEL@"

splitlevels=$1
test -n $splitlevels
Expand Down Expand Up @@ -65,14 +66,14 @@ done
sed -i -n -e '/^\[\^1\]: /,$p' $src

# Put footnotes in all files, renumber, and generally cleanup
for file in $files; do
>> $file < $src
normalize_pandoc < $file |
sponge $file
track $file
done
function cleanup_split () {
alias sponge="@SPONGE@"
normalize_pandoc < $1 < $src | sponge $1
}
F=$(functions cleanup_split normalize_pandoc)
parallel @ZSH@ -c "$F; src=$src; cleanup_split" ::: ${files[@]}

track $bookid.md
track $bookid.md ${files[@]}
commit "Split $bookid up into chapters and sections"

"$CASILEDIR/scripts/normalize_files.zsh" $bookid

0 comments on commit 4691d1f

Please sign in to comment.