matchChunk to find fontNames
Eric Chatonet
eric.chatonet at sosmartsoftware.com
Thu Jun 23 02:01:32 EDT 2005
Hi Claudi,
I would not use matchText but would go straight on with 2 repeat
loops to parse the html text:
one with the fontNames: if tFont is in tText...
Another one with tag styles: if "<i>" is in tText...
Less, less elegant :-( but should do the job :-)
Best Regards from Paris,
Eric Chatonet.
Le 23 juin 05 à 00:29, Claudi Cornaz a écrit :
> I am trying to implement a text menu and need to find all the
> fontNames
> and text attributes in the selectedChunk first to update my menu
> and afterwards
> to handle the choice.
> As long as all the text has all the same attributes (bold / italic
> etc) it's no problem
> but I need also to find all the attributes when it's mixed.
>
> I have been trying to get the instances of <font face=" xxxx xxx -
> xxx" [Size="yy"] [color="#ZZZZZZ"]>
> to extract all the parts like, the fontname, the size and the color
> if applicable with matchChunk.
>
> I start to understand regex a little bit, but I still did not got
> it to work just right.
>
> Here is what I got sofar to get the whole font face tag:
> matchChunk(tText, "(<font face=\"[A-z\- ]+\">)", tStart, tEnd)
>
> Some fontNames have spaces or - in theire name but if I add them to
> the regex like in the above example
> the end goes on to far like: Stone Sans OS ITC TT-Bold"
> color="#FF0000">zeker</font> . . . . . . etc
>
> I tried to change the regex part with a $ at the end so it should
> stop at the ">" char.
> matchChunk(tText, "(<font face=\"[A-z\- ]+\">$)", tStart, tEnd)
>
> Well, no dice, now it finds nothing no more so obviously I am doing
> something wrong.
> How should this be done?
>
> Sugestions for a better way to find all the style runs are of
> course very welcome as well,
> since I just "thought" of this way to do it, in fact after quite
> some thought this came as "best" solution
> to my mind, but wether this is the best way to do it, well
> probably not.
>
> Anyway much thanks in advance and all help appreciated
----------------------------------------------------------------
So Smart Software
For institutions, companies and associations
Built-to-order applications: management, multimedia, internet, etc.
Windows, Mac OS and Linux... With the French touch
Free plugins and tutorials on my website
----------------------------------------------------------------
Web site http://www.sosmartsoftware.com/
Email eric.chatonet at sosmartsoftware.com/
Phone 33 (0)1 43 31 77 62
Mobile 33 (0)6 20 74 50 86
----------------------------------------------------------------
More information about the use-livecode
mailing list