John Chambers wrote:
>So, are there any good ideas out there for how to correct for damaged
>ABC like the above?
>
First idea : remove _all_ linebreaks and put them back in the right
places.
1. Locate the first line of the tune.
2. Remove all newlines from there on.
3. Replace newlines on every fourth bar line, unless it's a :|2, in which
case the newline goes on the next bar line.
4. Locate any in-tune fields and fix them, either by inlining or
by putting newlines before and after.
5. Remove any backslashes at the start of lines.
Problems:
It's going to screw up some carefully-composited abc, especially
abcs with more or less than 4 bars per line.
3. :|2 can also be :|[2 or :| [2 or...
4. This is the hard one. It can be difficult to locate the ends of
fields; almost impossible in the case of w: N: T: or any other
field which can contain text of arbitrary length.
Next idea : Locate the spurious line breaks and remove them.
Symptoms of spurious line breaks include:
Lines of length 72 chars followed by a short line.
Lines which end in illegal abc such as <, >, /, :, (, [, {.
Lines which start with illegal abc such as numerals, \, /, ), ], }.
Linebreaks which separate some paired symbols "", [], {}
(but not (), since slurs can cross line breaks).
It's not going to be easy to make this water-tight. In fact,
considering that it only takes four mouse clicks and four keystrokes
to fix the original manually, is it really worth writing all the
code necessary to fix it automatically?
Phil Taylor
To subscribe/unsubscribe, point your browser to: http://www.tullochgorm.com/lists.html