Text-markup 0.01

Text::Markup is a small library for parsing and emitting marked-up text.

https://github.com/martindemello/text-markup

Details:

Text::Markup defines a common representation (Text::Markup::Tree) for
marked-up text. A set of modules deal with conversion to and from this
representation of a variety of “marked-up text” formats.

  • Current modules: ANSI (parse and emit) and HTML (emit)

  • Currently supported markup attributes are bold, italics, underline,
    strikethrough, fgcolor and bgcolor.

Quick example from the README:

require ‘text/markup/ansi’
require ‘text/markup/html’

ansi = “\e[1m\e[31mBold red text\e[44mon blue\n\e[21m\e[32mGreen
text\e[0mnone\n”
tree = Text::Markup::ANSI.parse(ansi)
html = Text::Markup::HTML.format(tree)
puts html

Bold red texton blue
Green
text
none

The stream->tree parser currently fixes badly nested tags, but does
not make any attempt to optimise the resulting tree via node
rearrangement. (On the TODO list, patches welcome. Should be a fun
problem. e.g. texttext
could be transformed to texttext
and a smart formatter could drop the )

TODO:

Version 0.02 will add a port of perl’s Tk::TextANSIColor
http://search.cpan.org/~tjenness/Tk-TextANSIColor-0.15/TextANSIColor.pm

Comments, requests and patches all welcome.

martin