Term::Emit::Format::HTML - Formats Term::Emit output into HTML
This document describes Term::Emit::Format::HTML version 0.0.2
use Term::Emit::Format::HTML 'format_html'; my $out = "some output from Term::Emit"; my $html = format_html($out);
This module reformats the output from an application that uses Term::Emit into a chunk of HTML, which you can embed in a web page.
This module is handy if you write Web UIs that wrap a command line utility and show the output from that utility on a web page.
Suppose you have a utility that produces this output:
Quobalating all frizzles... We operate on only the first and second frizzles in this step. Merfubbing primary frizzle.......... [OK] Xylokineting secondary frizzle...... [WARN] Quobalating all frizzles.............. [DONE]
This module can parse that output and convert it into this:
<h1 class="done">Quobalating all frizzles</h1> <p>We operate on only the first and second frizzles in this step.</p> <h2 class="ok">Merfubbing primary frizzle</h2> <h2 class="warn">Xylokineting secondary frizzle</h2>
Note how the steps that have completed with a status, such as [OK] or [DONE], get tagged in the resulting HTML with a class. This simple hook allows you to do some fancy CSS so you can associate images, colors, and so forth with the output to really spiff up your web page.
This function parses the given STRING and returns an HTML string. The input STRING is presumed to be the captured output of some other application that uses Term::Emit.
Term::Emit::Format::HTML requires no configuration files or environment variables.
This is ALPHA code! It is not yet complete, but it's working well enough for simple, non-demanding cases. Use at your own risk!
The heuristic this module uses is rather simple-minded, and relies upon indentation to figure out nesting depths. If you set the indentation -step to 0 in Term::Emit, then this module will not be able to properly parse the string, even with bullets enabled. I hope to make it smarter in a future release (so it can tell nesting depth from the bullets, too).
No bugs have been reported.
Please report any bugs or feature requests to
email@example.com, or through the web interface at http://rt.cpan.org.
Copyright (c) 2009, Steve Roscio
<firstname.lastname@example.org>. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
Because this software is licensed free of charge, there is no warranty for the software, to the extent permitted by applicable law. Except when otherwise stated in writing the copyright holders and/or other parties provide the software "as is" without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the software is with you. Should the software prove defective, you assume the cost of all necessary servicing, repair, or correction.
In no event unless required by applicable law or agreed to in writing will any copyright holder, or any other party who may modify and/or redistribute the software as permitted by the above licence, be liable to you for damages, including any general, special, incidental, or consequential damages arising out of the use or inability to use the software (including but not limited to loss of data or data being rendered inaccurate or losses sustained by you or third parties or a failure of the software to operate with any other software), even if such holder or other party has been advised of the possibility of such damages.