Hi all,
in my bst file, i would like to remove the "." at the end of the entry title when it is present. I think that i must use the function substring$ but i do not know how to proceed. Could you help me please.
thanks by advance
regards
Stergann
BibTeX, biblatex and biber ⇒ Problem with bst file (bibliography style)
Problem with bst file (bibliography style)
Here is one solution:
This solution is a bit ugly since it mixes substring$, which treats each character in the string as is, with text.prefix$, which takes into consideration bibtex's special characters.
A nicer solution, which uses the string.length function from Tame the BeaST:Here all characters are treated in the same way.
Note that these functions only removes a period if it is the very last character in the string (at brace depth zero). So a period protected by braces, as in the second example in the test function, will not be removed. I think doing that would be much harder.
Olof
Code: Select all
ENTRY {} {} {}
FUNCTION {remove.period.at.end} {
duplicate$
#-1 #1 substring$
"." =
{ duplicate$ text.length$ #1 - text.prefix$ }
'skip$
if$
}
READ
FUNCTION {test} {
"Abc." remove.period.at.end top$
"{Abc.}" remove.period.at.end top$
"Abcd" remove.period.at.end top$
}
EXECUTE {test}
A nicer solution, which uses the string.length function from Tame the BeaST:
Code: Select all
ENTRY {} {} {}
FUNCTION {not}
{ { #0 }
{ #1 }
if$
}
INTEGERS{ l }
FUNCTION{ string.length } {
#1 'l :=
{duplicate$ duplicate$ #1 l substring$ = not}
{l #1 + 'l :=}
while$
pop$ l
}
FUNCTION {remove.period.at.end} {
duplicate$
#-1 #1 substring$
"." =
{ duplicate$ string.length #1 - #1 swap$ substring$ }
'skip$
if$
}
READ
FUNCTION {test} {
"Abc." remove.period.at.end top$
"{Abc.}" remove.period.at.end top$
"Abcd" remove.period.at.end top$
}
EXECUTE {test}
Note that these functions only removes a period if it is the very last character in the string (at brace depth zero). So a period protected by braces, as in the second example in the test function, will not be removed. I think doing that would be much harder.
Olof