Markdent::Parser - A markdown parser


Markdent documentation  | view source Contained in the Markdent distribution.

Index


NAME

Top

Markdent::Parser - A markdown parser

VERSION

Top

version 0.17

SYNOPSIS

Top

  my $handler = Markdent::Handler::HTMLStream->new( ... );

  my $parser = Markdent::Parser->new(
      dialect => ...,
      handler => $handler,
  );

  $parse->parse( markdown => $markdown );

DESCRIPTION

Top

This class provides the primary interface for creating a parser. It ties a block and span parser together with a handler.

By default, it will parse the standard Markdown dialect, but you can provide alternate block or span parser classes.

METHODS

Top

This class provides the following methods:

Markdent::Parser->new(...)

This method creates a new parser. It accepts the following parameters:

* dialect => $name

You can use this as a shorthand to pick a block and/or span parser class.

If the dialect parameter does not contain a namespace separator (::), the constructor looks for classes named Markdent::Dialect::${dialect}::BlockParser and Markdent::Dialect::${dialect}::SpanParser.

If the dialect parameter does contain a namespace separator, it is used a prefix - $dialect::BlockParser and $dialect::SpanParser.

If any relevant classes are found, they will be used by the parser.

You can also specify an explicit block or span parser, but if the dialect has its own class of that type, an error will be thrown.

If the dialect only specifies a block or span parser, but not both, then we fall back to using the appropriate parser for the Standard dialect.

* block_parser_class => $class

This default to Markdent::Dialect::Standard::BlockParser, but can be any class which implements the Markdent::Role::BlockParser role.

* span_parser_class => $class

This default to Markdent::Dialect::Standard::SpanParser, but can be any class which implements the Markdent::Role::SpanParser role.

* handler => $handler

This can be any object which implements the Markdent::Role::Handler role. It is required.

$parser->parse( markdown => $markdown )

This method parses the given document. The parsing will cause events to be fired which will be passed to the parser's handler.

ROLES

Top

This class does the Markdent::Role::EventsAsMethods and Markdent::Role::Handler roles.

BUGS

Top

See Markdent for bug reporting details.

AUTHOR

Top

Dave Rolsky <autarch@urth.org>

COPYRIGHT AND LICENSE

Top


Markdent documentation  | view source Contained in the Markdent distribution.