Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fetching latest commit…
Cannot retrieve the latest commit at this time.
|Failed to load latest commit information.|
NAME Markup::Unified - A simple, unified interface for Textile, Markdown and BBCode. SYNOPSIS use Markup::Unified; my $o = Markup::Unified->new(); my $text = 'h1. A heading'; $o->format($text, 'textile'); print $o->formatted; # produces "<h1>A heading</h1>" print $o->unformatted; # produces "h1. A heading" # you can also just say: print $o; # same as "print $o->formatted;" DESCRIPTION This module provides a simple, unified interface for the Text::Textile, Text::Markdown and HTML::BBCode markup languages modules. This module is primarily meant to provide a simple way for application developers to deal with texts that use different markup languages, for example, a message board where users have the ability to post with their preferred markup language. Please note that this module expects your texts to be UTF-8. In order for this module to be useful at any way, at least one of the three parsing modules (Text::Textile, Text::Markdown or HTML::BBCode) must be installed. None of these are required, but if you try to parse a text formatted in any of these markup languages without the respective module being installed on your system, then the text will be returned unformatted, and no errors will be raised. METHODS new() Creates a new, empty instance of Markup::Unified. format( $text, $markup_lang ) Formats the provided text with the provided markup language. $markup_lang must be one of 'bbcode', 'textile' or 'markdown' (case insensitive); otherwise the text will remain unprocessed (which is also true if the appropriate markup module is not installed on your system). formatted() Returns the formatted text of the object, with whatever markup language it was set. This module also provides the ability to print the formatted version of an object without calling "formatted()" explicitly, so you can just use "print $obj". unformatted() Returns the unformatted text of the object. truncate([ $length_str, $ellipsis ]) NOTE: This feature requires the presence of the HTML::Truncate module. If it is not installed, this method will simply return the output of the formatted() method without raising any errors. This method returns the formatted text of the object, truncated according to the provided length string. This string should be a number followed by one of the characters 'c' or '%'. For example, "$length_str = '250c'" will return 250 characters from the object's text. "$length_str = '10%'" will return 10% of the object's text (characterwise). If a length string is not provided, the text will be truncated to 250 characters by default. This is useful when you wish to display just a sample of the text, such as in a list of blog posts, where every listing displays a portion of the post's text with a "Read More" link to the full text in the end. If an $ellipsis is provided, it will be used as the text that will be appended to the truncated HTML (i.e. "Read More"). Read HTML::Truncate's documentation for more info. Defaults to … (HTML entity for the '...' ellipsis character). supports( $markup_lang ) Returns a true value if the requested markup language is supported by this module (which basically means the appropriate module is installed and loaded). $markup_lang must be one of 'textile', 'bbcode' or 'markdown' (case insensitive). Returns a false value if the requested language is not supported. DIAGNOSTICS This module does not throw any exceptions (by itself). CONFIGURATION AND ENVIRONMENT "Markup::Unified" requires no configuration files or environment variables. DEPENDENCIES "Markup::Unified" depends on the following CPAN modules: * Module::Load::Conditional "Markup::Unified" needs one or more of these modules to actually be of any function: * Text::Textile * Text::Markdown * HTML::BBCode * HTML::Truncate INCOMPATIBILITIES WITH OTHER MODULES None reported. BUGS AND LIMITATIONS No bugs have been reported. Please report any bugs or feature requests to "bug-Markup-Unified@rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Markup-Unified>. AUTHOR Ido Perlmuter <ido at ido50 dot net> LICENSE AND COPYRIGHT Copyright (c) 2009-2015, Ido Perlmuter "ido at ido50 dot net". This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either version 5.8.1 or any later version. See perlartistic and perlgpl. The full text of the license can be found in the LICENSE file included with this module. DISCLAIMER OF WARRANTY 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.