On Nov 18 at 08:55 +0100, Peter Bienstman wrote:
> On Friday, November 18, 2011 03:50:37 AM Murray James Morrison wrote:
> > Timothy Bourke's excellent FastFormat plugin does not currently work with
> > Chinese text. eg. `你好` , shows up as plain black text and `` quotation
> > marks, instead of in red font like it is set to.
> 
> Tim, this might be caused by an interaction with 'increase size of non-latin 
> characters'.

That's spot on Peter.

The FastFormat plugin breaks the text up into a stream of html tags
and text, the regular expressions are then matched against each text
element in isolation.

So:
    `你好`

is treated as a single text element which becomes:
    <font color="red">你好</font> 

But (the result of increasing the size of non-latin characters):
    `<font style="font-size:20pt">你好</font>`

is first broken up into five elements:
    `                                       (text)
    <font style="font-size:20pt">           (tag)
    你好                                    (text)
    </font>                                 (tag)
    `                                       (text)

and the regular expression does not match any of them individually.

The most accurate solution is probably to introduce a notion of
'opening' and 'closing' matches, to parse the html using a proper
library, and to rewrite the algorithm to match openings and closings
across the same branch level of the html tree.

I don't really have the time to implement and debug this at the
moment, and I like the simplicity of just matching with regular
expressions, so I've implemented a simpler solution for the 2.x
version of the plugin: regular expressions are matched across the
entire card text.

This should work well provided that '=' and '"' are not used in format
strings (they are used in html tags), and provided that care is also
taken when matching with ASCII letters and digits.

An updated version can be found at:
    http://www.mnemosyne-proj.org/node/156

Tim.
 

Attachment: signature.asc
Description: Digital signature

Reply via email to