notes on smart quote implementation


Subject: notes on smart quote implementation
From: WJCarpenter (bill-abisource@carpenter.ORG)
Date: Tue Aug 22 2000 - 10:29:07 CDT


[[These notes are a companion to smart quotes patch sent in a separate
message.]]

The algorithm for smart quotes is only slightly modified from the one
I proposed here some weeks ago. You can find it documented in the
comments in src/text/fmt/xp/fl_DocLayout.cpp (and also in this patch,
of course).

Because the Unix implementation (and maybe some others) don't include
fonts with smart quote characters, and because the default action of
remapGlyphs in such cases is to map back to straight ASCII quotes, you
may need to set the following preference item:

  RemapGlyphsTable="‘<’>“«”»"

That preference item maps quotes to single or double angle brackets,
so at least you can see what's going on. In the stored *.abw file, of
course, the original UCS smart quote characters are present.

I admit that this algorithm is still Anglo-centric, but it would be a
straightforward matter for an interested party to extend it to handle
smart quoting rules for different locales (either the default locale
for the user or, should they ever materialize, the locale tag for the
piece of text in which the quote character appears). The bulk of the
algorithm is table-driven, and there are a few
character-classification functions that would have to be made
locale-savvy. If anyone undertakes that job, I'd be happy to answer
questions or whatever. I probably won't get to it myself, but I think
this would be a very cool feature for Abiword to have.

The promotion of characters to smart quotes is recorded in change
records for UNDO. It would be cool if you could just UNDO after a
smart quote promotion happened to force a straight quote in a
particular place, but the UNDO also moves the insertion point, and you
would be likely to get the character re-promoted by moving the
insertion point back where you want it. The only good way to force
straight quotes is to know a bit about the rules and trick the
algorithm. So, to get a straight opening quote, type the sequence:

        whatever space quote space backspace whatever

To get a straight closing quote, type the sequence:

        whatever quote slash backspace whatever

The above trick works because the algorithm notices quote characters
when they are typed (or pasted) and only has a single-character
memory. So, the algorithm hits a rule that says "don't convert this
one", and then it forgets the character exists. (After all that
earlier stuff about background checks, it turns out I didn't use it
for smart quotes after all. Oh well.)

-- 
bill@carpenter.ORG (WJCarpenter)    PGP 0x91865119
38 95 1B 69 C9 C6 3D 25    73 46 32 04 69 D6 ED F3



This archive was generated by hypermail 2b25 : Tue Aug 22 2000 - 11:54:39 CDT