Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ionen-angewandte-physik
AG-Wester
bibtools
Commits
3dc4d4ac
Commit
3dc4d4ac
authored
Apr 04, 2022
by
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
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
12 deletions
+7
-12
bin/bib-format
bin/bib-format
+7
-7
test/bib-format_test
test/bib-format_test
+0
-5
No files found.
bin/bib-format
View file @
3dc4d4ac
...
...
@@ -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-Z
a-z][A-Z
a-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-Z
a-z][A-Z
a-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
"
...
...
test/bib-format_test
View file @
3dc4d4ac
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment