Test::Markdent - High level test functions for Markdent
version 0.16
use Test::Markdent; my $text = <<'EOF'; Some %*em text*% EOF my $expect = [ { type => 'paragraph' }, [ { type => 'text', text => 'Some %', }, { type => 'emphasis', }, [ { type => 'text', text => 'em text', }, ], { type => 'text', text => "%\n", }, ], ]; parse_ok( $text, $expect, 'emphasis markup surrounded by brackets' );
This module provides some helper functions for testing Markdent at a higher-level. In particular, it helps generate parse trees or HTML output from a parse.
This class exports the following functions:
This function takes some Markdown text, an expected output tree, and a description of the test.
The tree is generated by using Markdent::Handler::MinimalTree, and then using Tree::Simple::Visitor::ToNestedArray to covert the tree to a data structure.
You can use the tree_from_handler function to get the tree. You may want to use Data::Dumper to examine a few trees to understand exactly what this looks like.
tree_from_handler
You can also pass an optional hash reference as the first parameter to this function. This hash reference will be used as parameters when creating the Markdent::Parser object.
This hash reference can also include a "handler_class" parameter, which you can use to override the default of Markdent::Handler::MinimalTree.
If you set the MARKDENT_TEST_VERBOSE environment variable to a true value, then this function will use Data::Dumper to output the tree with Test::More::diag().
MARKDENT_TEST_VERBOSE
Test::More::diag()
This function takes some Markdown text, the expected HTML output, and a description of the test.
Internally, this function uses HTML::Tidy to tidy both the Markdent-generated HTML and the HTML you pass in. This ensures that the test is comparing the HTML on a semantic level.
The comparison itself is done using eq_or_diff from Test::Differences.
eq_or_diff
If you set the MARKDENT_TEST_VERBOSE environment variable to a true value, then this function will output the generated html (before tidying) with Test::More::diag().
Given a Markdent::Handler::MinimalTree object, this function returns a data structure built using Tree::Simple::Visitor::ToNestedArray.
Dave Rolsky <autarch@urth.org>
This software is copyright (c) 2010 by Dave Rolsky.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Markdent, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Markdent
CPAN shell
perl -MCPAN -e shell install Markdent
For more information on module installation, please visit the detailed CPAN module installation guide.