runrev html to correct html with css-conform syntax + Q: conversion of pasted text in field

runrev at animabit.de runrev at animabit.de
Thu Apr 30 03:42:58 CDT 2009


Hello,

I often have the problem to export the htmltext of field xyz to HTML correctly displayed in modern browsers.

The following code does what I need. Perhaps anyone has something more elegant and complex then I would be interested in a better code.


Question:
If I paste text of winword or excel into a field in runrev and within the original text is text formatted in color or as a html link in the "#0000ff" notation
the resulting htmltext in runrev is correct but the color wrongly displayed.
blue (#0000ff) is like a lila violet, yellow is like turkis ...
Why?

And the htmltagging seems not to be correct in runrev after import of winword etc.:

<font face="Garamond" size="11"><b>Internet </font><font face="Garamond" size="11" color="#0000FF"><u>www.animabit.de</b></u></font>

As you see:           font b /font font u /b /u /font
correct would be:    b font /font font u /u /font /b 

Is this a wrongly behavior of the conversion after pasting text into a runrev text field?

regards

Mit freundlichen Grüßen
Franz Böhmisch

boehmisch at animabit.de
http://www.animabit.de
GF Animabit Multimedia Software GmbH
Am Sonnenhang 22
D-94136 Thyrnau
Tel +49 (0)8501-8538
Fax +49 (0)8501-8537



put the htmltext of field xyz into feldinhalt
replace quote with "'" in feldinhalt
put true into entscheider
repeat while entscheider = true
put "(<font .*?>)" into regex
put matchtext(feldinhalt,regex,schriftentag) into entscheider
if schriftentag <> empty then
--answer schriftentag
get matchtext(schriftentag,"size='(\d+)'", schriftgröße)
if schriftgröße <> empty then
put "font-size:" & schriftgröße & "px;" into schriftgrößekomponente
else
put empty into schriftgrößekomponente
end if
get matchtext(schriftentag,"face='(.*?)'", schriftart)
if schriftart <> empty then
put "font-family:" & schriftart & ";" into schriftartkomponente
else
put empty into schriftartkomponente
end if
get matchtext(schriftentag,"color='([0-9A-F#]+?)'", schriftfarbe)
if schriftfarbe <> empty then
put "color:" & schriftfarbe & ";" into schriftfarbekomponente
else
put empy into schriftfarbekomponente
end if
--answer (schriftgröße & cr & schriftart & cr & schriftfarbe)
replace schriftentag with ("<§font style='" && schriftartkomponente && schriftfarbekomponente && schriftgrößekomponente & "'>") in feldinhalt
--replace schriftentag with ("<§font style='font-size:" & schriftgröße & "px'>") in feldinhalt
--put empty into entscheider
put empty into schriftentag
end if
end repeat
replace "<§font" with "<font" in feldinhalt

To: use-revolution at lists.runrev.com
Cc: boehmisch at animabit.de





More information about the use-livecode mailing list