我应该如何制作支持简单标记语言的文本小部件?

How should I make a text widget supporting a simple markup language?

Torque 引擎有一个很好的标记语言 TorqueML(见下文,从 a post in the garagegames forum 复制)。它使得在纯文本中合并一些简单的布局和格式信息成为可能,这些信息可用于在游戏中构建用于帮助或对话框的文本小部件。

我想知道是否有人可以建议一种最有效的方法来 build/get Haxe 中的相同功能(尤其是在 HaxeFlixel 框架中)。

以下是Torque中可用的标记语言信息,供参考:

<font:fontName:fontSize> - sets the font and fontsize as indicated. Example: <font:Arial Bold:20>  
<tag:???> - not sure what this does  
<color:rrggbb> - sets text color in hex format. Example: <color:ff0000> will display red text  
<bitmap:filePath> - displays a bitmap image indicated by the file path. Example: <bitmap:demo/client/ui/seperator>  
<spush> - saves the current text formatting so that temporary changes to formatting can be made. Used with spop.  
<spop> - restores the previously saved text formatting. Used with spush. See the file "3. Gui Editor.hlf" included with the TGE demo for an example of usage.  
<sbreak> - not sure what this does  
<just:left> - left justify  
<just:right> - right justify  
<just:center> - center justify  
<a:ExternalURL>LinkTitle</a> - inserts a hyperlink into the text which will open the user's browser.  
The external URL does not need the "http://" format. Example: <a:www.garagegames.com>Garage Games Website</a>  
<lmargin: ##> - sets the left margin  
<lmargin%: ##> - sets the left margin (not sure what the % does)  
<rmargin: ##> - sets the right margin  
<rmargin%: ##> - sets the right margin (not sure what the % does)  
<clip:> - not sure what this does  
<div:> - not sure what this does  
<tab:##(,##,etc)> - sets the tab stops (multiple tabs are separated by commas)  
 - Breaks the current line and begins a new one.  

作为起点,HaxeFlixel 的 FlxText.hx 中已经提供了一个基本功能,可让您应用简单的标记:

https://github.com/HaxeFlixel/flixel/blob/dev/flixel/text/FlxText.hx#L274