Commit 13c7cfd4 authored by User expired's avatar User expired
Browse files

Multi line tests and fix for '{' at end of line

parent 8e84bf91
Pipeline #40141 failed with stage
in 54 seconds
......@@ -37,8 +37,9 @@ done
# Function to merge lines.
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-Z][a-z]* = {.*[^},]$/N # If bib field is incomplete, append next line.
s/{\n[ \t]*/{/ # At left curly bracket remove newline and whitespace.
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.
/[^},]$/N # If bib field is still incomplete, append next line.
......
......@@ -229,11 +229,38 @@ testCurlyBracketsInField() {
assertEquals ' Field = {start text {end}}' "$(cat $fileOne)"
}
testMergLines() {
testMergeLinesWithBraces() {
# Simple one
echo ' Field = {some
text}' > $fileOne
bib-format $fileOne
assertEquals ' Field = {some text}' "$(cat $fileOne)"
# Brackets with own line
echo ' Field = {
some text
},' > $fileOne
bib-format $fileOne
assertEquals ' Field = {some text},' "$(cat $fileOne)"
# Only first line without content
echo ' Field = {
some text},' > $fileOne
bib-format $fileOne
assertEquals ' Field = {some text},' "$(cat $fileOne)"
# Over three lines
echo ' Field = {some
text over
three lines }' > $fileOne
bib-format $fileOne
assertEquals ' Field = {some text over three lines}' "$(cat $fileOne)"
# Within a record
echo '@Article{,
Field = {some
text}
}' > $fileOne
bib-format $fileOne
assertEquals '@Article{,
Field = {some text}
}' "$(cat $fileOne)"
}
testUnchangedUrls() {
......
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