Return to Snippet

Revision: 16901
at August 18, 2009 17:34 by deepsoul


Initial Code
# shell functions save a lot of typing...
function fixbbl()
{
  # This will overwrite the target file in-place
  sed -i ':s
/%$/{
  N 
  bs
} 
s/%\n//g' "$1"
}

# usage:
fixbbl document.bbl

Initial URL
http://lists.debian.org/debian-user/2000/11/msg00692.html

Initial Description
The tetex implementation of BibTeX, LaTeX's bibliography tool, forcibly breaks lines above a certain length (79 chars) by inserting % signs and line feeds, unless they can be broken between words.  This is a problem when URLs are referenced, or if control sequences without spaces between them are used.

The following solution using sed improves on the one given in the post above in that it works if a line is broken twice or more times.  It can be used as an example on how to concatenate lines ending with a specific character indicating continuation.

Initial Title
Fix BibTeX URLs and long lines

Initial Tags
url

Initial Language
Bash