OK - my 2p.  (Non-sterling readers substitute the currency of your choice).

If you don't want to damage carefully constructed ABC with deliberately
placed line-breaks then just do a subset of the suggested remedies:

Within the header, between X; (or T: ??) and K: delete any CR or LF
characters that are not followed by <letter><colon>

After that, if any line ends in ! (this requires a 2-pass strategy) then it
must be from abcwin, so remove all line-ends and then replace ! with
line-end.

Otherwise delete line-ends which are
1. Inside quotes (if the file had unmatched quotes then it had probably been
mangled by more than just line-ends and is beyond simple automatic repair).
2. in the middle of a numeric string (but these are rare anyway)
3. lie within compound symbols :|: :| |: etc.
and at this point the arguments start.  I have seen files which had lines
where :|: was split across lines and which obviously were created that way
by hand to place the new line at the repeat mark, being also end of phrase
and a sensible musical length of line.  I would chose to convert such into
:| <linend> |:
4? inside {} (questionable - what about a really long string of grace
notes - I've seen a whole octave scale of acciacaturas)
5? after > or < (very questionable - Why is it illegal to split a broken
rhythm pair across lines?)
6? / (very questionable indeed!  I see no reason not to end a line on a
quaver half note).
7. Within a note (I think the only argument here is that it needs a fairly
full parse to detect this.  Furthermore the parse is a bit funny because we
need to essentially parse what we'd get if all the line-ends were deleted
first, but certain symbols are only legal immediately following a line-end).

Laurie
----- Original Message -----
From: Phil Taylor <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, October 21, 2000 1:31 AM
Subject: Re: [abcusers] Egregious example of line wrapping


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


To subscribe/unsubscribe, point your browser to: http://www.tullochgorm.com/lists.html

Reply via email to