text2xhtml

mtwin.text.Text2Xhtml

As its name implies, Text2Xhtml is a little tools which tranforms plain text into XHTML.

Many web application like wiki, blogs, news systems, forums, etc... requires this kind of tools.

To quickly get some advanced features in your application whithout getting your hands dirty, you can use the Text2Xhtml tranformer which support common things like :

  • titles
  • ordered and unordered lists (no sub level yet)
  • preformatted text
  • links
  • raw html insertion
  • haxe syntax highlight
  • strong and emphased
  • citations
  • images insertion
  • swf insertion
  • well formed xml validation (throws exceptions)

=== Usage : ===

// use default transformation parameters (every features)
var xhtml = mtwin.text.Text2Xhtml.transform(myInputString);

// custom transformer to disable features
var t = new mtwin.Text.Text2Xhtml();
t.htmlEnabled = false; // no raw html
t.codeEnabled = false; // no haxe code
t.swfEnabled = false; // no swf inclusion
var xhtml = t.transform(myInputString);

=== Plain text syntax : ===

h1 : at least 4 * after the title
****

or

*** h1 : line starts with 3 *

h2 : at least 4 = after the title
====

or

=== h2 : line starts with 3 =

h3 : at least 4 - after the title
----

or

--- h3 : line starts with 3 -

- list item 1
- list item 2
- no sub level at this time

* ordered item 1
* ordered item 2
* no sub level at this time

[pre]
some preformatted code
[/pre]

Will generate a link : http://www.google.com.

Will generate a [link with name:http://www.google.com].

Some //emphased text// and some *strong text*.

Now insert an image : @img http://www.foo.com/foo.jpg@

Inserting a Swf is easy : 

@swf WxHxV http://path/to/my/swf.swf@ 

where W means width, H means Height and V means flash Version, 
this feature uses the SWFObject javascript class to display the 
specified swf.

[html]
<p>This is some raw html you may like to insert manually to add 
some specific data like
javascript or other stuff.</p>
<p>Raw html may produce parse exceptions thrown by the T
ext2Xhtml.transform(src) method.</p>
[/html]

You can also insert [cite]some citations[/cite] !

That's almost everything for now :)

Ah i almost forgot the haxe colorizer :

[haxe]
class Foo {
    // some comment
    public function new(){
    }

    // ...
    public static function foo(){
    }
}
[/haxe]
version #4129, modified 2008-08-29 01:37:48 by baurel