Commit 2ff7444a authored by User expired's avatar User expired
Browse files

bib-format: Remove preceding whitespace in fields

Additionally, pre match substitutions with simple patterns for speed.
parent 21105bf7
......@@ -105,11 +105,12 @@ do
sed -i '$s/"}$/}\n}/' "$tmpfile"
sed -i -r 's/^ ([A-Za-z][^={"]*[^ ={"]) = ([^{].*[^},])(,*)$/ \1 = {\2}\3/' "$tmpfile"
# Remove trailing whitespace within fields.
# Remove preceding and trailing whitespace in field contents.
sed -i 's/ *\(},\?\)$/\1/' "$tmpfile"
sed -i -r '/\{ /s/^( [A-Za-z]+ = \{) +/\1/' "$tmpfile"
# Remove double curly brackets around fields.
sed -i -r 's/^( [A-Za-z]+ = *\{)\{(.*)\}(\}[^}]*)$/\1\2\3/' "$tmpfile"
sed -i -r '/\{\{/s/^( [A-Za-z]+ = *\{)\{(.*)\}(\}[^}]*)$/\1\2\3/' "$tmpfile"
# Append single blank line.
sed -i '$G' "$tmpfile"
......
......@@ -121,7 +121,7 @@ testPrintChangesContent() {
}
testWhiteSpace() {
echo ' Field = {one two three } ' > $fileOne
echo ' Field = { one two three } ' > $fileOne
bib-format $fileOne
assertEquals ' Field = {one two three}' "$(cat $fileOne)"
echo ' Field = {one two three }, ' > $fileOne
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment