这让我无法入睡,我在这里添加了我的测试应用程序。只需复制并粘贴以测试应用程序将格式良好的 html 文本添加到文本区域单击“添加”然后单击“执行”我将此 html 文本移到另一个文本区域,我看到文本已更改标签获取的格式糊涂了。
我的最终目标是将 html 文本正则表达式转换为另一个界面的另一种格式。然而,这种混乱的标签让我很头疼。
任何防止或纠正这种情况的解决方案将不胜感激。
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="init()" xmlns:ns1="com.tree.*">
<mx:Script>
<![CDATA[
private function init():void {
originalTA.text='<TEXTFORMAT LEADING="-2">'+ '<P ALIGN="JUSTIFY">'+ '<FONT SIZE="26" COLOR="#9B0000" LETTERSPACING="0" KERNING="0"> some text </FONT> '+ '<FONT SIZE="26" COLOR="#BEBEBE"> some text </FONT> '+ '<FONT SIZE="26" COLOR="#9B0000" LETTERSPACING="0" KERNING="0"> some text </FONT>'+ '</P>'+ '</TEXTFORMAT>';
}
private function add():void {
viewDTA.htmlText=originalTA.text;
}
private function go():void {
htmlTA.text=viewDTA.htmlText;
}
]]>
</mx:Script>
<mx:HBox width="100%" height="100%">
<mx:Label text="input"/>
<mx:TextArea id="originalTA" height="100%" width="100%"/>
<mx:Button label="add" click="add()"/>
<mx:Label text="view"/>
<mx:TextArea id="viewDTA" height="100%" width="100%"/>
<mx:Button label="go" click="go()"/>
</mx:HBox>
<mx:HBox width="100%" height="100%">
<mx:Label text="html"/>
<mx:TextArea id="htmlTA" height="100%" width="100%"/>
</mx:HBox>
</mx:Application>