Text::Markdown::TreeBuilder -- parse Markdown and generate (DOM like) Tree
use strict; use warnings; use Text::Markdown::TreeBuilder; my $tb=Text::Markdown::TreeBuilder->new(utf8=>1); $tb->parse(<<'TXT'); AT&T has an ampersand in their name. ===================================== AT&T is another way to write it. ------------------------------------ This & that. TXT print $tb->as_HTML();
Parser for markdown formated Documents
ToPeG
the Markdown types are converted to:
markdown types: perlclass: list_plain -> HTML::Element "ul" list_count -> HTML::Element "ol" list_entry -> HTML::Element "li" h1..h6 -> HTML::Element "h1..h6" hr -> HTML::Element "hr" link/linkref -> HTML::Element "a" image/imageref -> HTML::Element "img" page -> HTML::Element "p" code -> HTML::Element "pre" => HTML::Element "code" inlinecode -> HTML::Element "code" html -> HTML::Element ( HTML::TreeBuilder ->look_down('body')->content->[0] ) inlinehtml -> HTML::Element ( HTML::TreeBuilder ->look_down('body')->content->[0] ) quote -> HTML::Element "blockquote" strong -> HTML::Element "strong" em -> HTML::Element "em" break -> HTML::Element "br" comment -> IGNORED link_def -> IGNORED (only used in Text::Markdown::Parser to Determin imageref and linkref)
all delivered Methods from HTML::Element are usable
create a new Parser Object
returns a Text::Markdown::TreeBuilder Object
type_attr => { type=>{...} } default: type_attr => { inlinecode => {style => "border:0.1em solid gray;" }, code => {style => "border:0.1em solid gray; margin-left:2em;" }, quote => {style => "border-left:0.3em solid blue; padding-left:0.3em; margin-left:0.6em;" }, }set attributes for HTML-Tags
parserset your own parser
parser_tabwidth => <int> (default 4)set the amount of spaces for one tab
parser_grep_exessive => 1/0 (default 0)if this option is true, linlinehtml will gab as mutch as possible text
set/get parser-opject
set/get UTF-8 conversion
set the HTML-Attributes for a markdown type
see type_attr in "new"
parse data from a File or Filehandle. See Text::Markdown::Parser
Parse Makdown formated Text. See Text::Markdown::Parser
unkown
- optional warnings
- store/export comments
Tobias Grönhagen <markdown@topeg.de>
Version 0.01 1 January 2011
Copyright (c) Tobias Grönhagen. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms and conditions as Perl itself.
This means that you can, at your option, redistribute it and/or modify it under either the terms the GNU Public License (GPL) version 2 or later, or under the Perl Artistic License.
See http://dev.perl.org/licenses/
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Use of this software in any way or in any form, source or binary, is not allowed in any country which prohibits disclaimers of any implied warranties of merchantability or fitness for a particular purpose or any disclaimers of a similar nature.
IN NO EVENT SHALL I BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION (INCLUDING, BUT NOT LIMITED TO, LOST PROFITS) EVEN IF I HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE