Commit 3dc4d4ac authored by User expired's avatar User expired
Browse files

Revert "Fix for field names with dashes or underscores"

This reverts commit 2a1a33e8.
parent e3a1a4cb
Pipeline #70041 failed with stage
in 1 minute and 6 seconds
......@@ -65,7 +65,7 @@ s/^ ([A-Za-z][A-Za-z_-]*) = ([^{].*[^},])(,*)$/ \1 = {\2}\3/
function merge_lines() { # merge_lines bibfilename
sed -i ':a # Label with name a.
/{$/s//& / # Blank to match opening bracket at line end in the next row.
/^ [A-Za-z][A-Za-z_-]* = {.*\([^},]\|[^}] *,$\)$/N # Append line if incomplete.
/^ [A-Z][a-z]* = {.*\([^},]\|[^}] *,$\)$/N # Append line to incomplete field.
s/{[\n \t]*/{/ # At left curly bracket remove newline and whitespace.
s/[ \t]*\n[ \t]*}/}/ # At right curly bracket remove whitespace and newline.
s/[ \t]*\n[ \t]*/ /g # At other places replace space+newline by single space.
......@@ -127,8 +127,8 @@ do
sed -i -r 's/^[ \t]*([A-Za-z][^={"]*[^ ={"])[ \t]*=[ \t]*/ \1 = /' "$tmpfile"
# Title case entry types.
sed -i -r 's/^@([A-Za-z][A-Za-z_-]*) *\{/@\L\u\1{/' "$tmpfile"
sed -i -r 's/^ ([A-Za-z][A-Za-z_-]*) = / \L\u\1 = /' "$tmpfile"
sed -i -r 's/^@([A-Za-z]+) *\{/@\L\u\1{/' "$tmpfile"
sed -i -r 's/^ ([A-Za-z]+) = / \L\u\1 = /' "$tmpfile"
# Use curly brackets {} instead of double quotes "" or no quotes.
sed -i 's/"} *$/"\n}/' "$tmpfile" # Closing brace on separate line.
......@@ -137,12 +137,12 @@ do
# Remove preceding and trailing whitespace in field contents.
sed -i 's/ *\(},\?\)$/\1/' "$tmpfile"
sed -i -r '/\{ /s/^( [A-Za-z][A-Za-z_-]* = \{) +/\1/' "$tmpfile"
sed -i -r '/\{ /s/^( [A-Za-z]+ = \{) +/\1/' "$tmpfile"
# Remove double curly brackets around fields (but not "{{...} ... {...}}").
sed -i -r '/\{\{/{
/^ [A-Za-z][A-Za-z_-]* = *\{\{([^{}]*)(\{[^{}]*\}[^{}]*)*\}\}[^}]*$/{
s/^( [A-Za-z][A-Za-z_-]* = *\{)\{(.*)\}(\}[^}]*)$/\1\2\3/
/^ [A-Za-z]+ = *\{\{([^{}]*)(\{[^{}]*\}[^{}]*)*\}\}[^}]*$/{
s/^( [A-Za-z]+ = *\{)\{(.*)\}(\}[^}]*)$/\1\2\3/
}
}' "$tmpfile"
......@@ -258,7 +258,7 @@ do
fi
# Remove emptry entries.
sed -i '/^ [A-Za-z][A-Za-z_-]* = ,$/d' "$tmpfile"
sed -i '/^ [A-Z][a-z]* = ,$/d' "$tmpfile"
# Exceptions from title case keys (at last, title case is expected above).
sed -i -r 's/^ Issn = / ISSN = /' "$tmpfile"
......
......@@ -255,11 +255,6 @@ testMergeLinesWithBraces() {
text}' > $fileOne
bib-format $fileOne
assertEquals ' Field = {some text}' "$(cat $fileOne)"
# Exotic field names
echo ' Field-with_more = {some
text}' > $fileOne
bib-format $fileOne
assertEquals ' Field-with_more = {some text}' "$(cat $fileOne)"
# Brackets with own line
echo ' Field = {
some text
......
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