| 1 | ## no critic (Moose::RequireMakeImmutable) | ||
| 2 | package Markdent; | ||
| 3 | |||
| 4 | use 5.010; | ||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | |||
| 8 | # The first version that completely worked with newer versions of Specio. | ||
| 9 | use Moose 2.1802 (); | ||
| 10 | |||
| 11 | our $VERSION = '0.39'; | ||
| 12 | |||
| 13 | 1; | ||
| 14 | |||
| 15 | # ABSTRACT: An event-based Markdown parser toolkit | ||
| 16 | |||
| 17 | __END__ | ||
| 18 | |||
| 19 | =pod | ||
| 20 | |||
| 21 | =encoding UTF-8 | ||
| 22 | |||
| 23 | =head1 NAME | ||
| 24 | |||
| 25 | Markdent - An event-based Markdown parser toolkit | ||
| 26 | |||
| 27 | =head1 VERSION | ||
| 28 | |||
| 29 | version 0.39 | ||
| 30 | |||
| 31 | =head1 SYNOPSIS | ||
| 32 | |||
| 33 | use Markdent::Simple::Document; | ||
| 34 | |||
| 35 | my $parser = Markdent::Simple::Document->new; | ||
| 36 | my $html = $parser->markdown_to_html( | ||
| 37 | title => 'My Document', | ||
| 38 | markdown => $markdown, | ||
| 39 | ); | ||
| 40 | |||
| 41 | =head1 DESCRIPTION | ||
| 42 | |||
| 43 | This distribution provides a toolkit for parsing Markdown (and Markdown | ||
| 44 | variants, aka dialects). Unlike the other Markdown Perl tools, this module can | ||
| 45 | be used for more than just generating HTML. The core parser generates events | ||
| 46 | (like XML's SAX), making it easy to analyze a Markdown document in any number | ||
| 47 | of ways. | ||
| 48 | |||
| 49 | If you're only interested in converting Markdown to HTML, you can use the | ||
| 50 | L<Markdent::Simple::Document> class to do this, although you can just as well | ||
| 51 | use better battle-tested tools like L<Text::Markdown>. | ||
| 52 | |||
| 53 | See L<Markdent::Manual> for more details on how Markdent works and how you can | ||
| 54 | use it. | ||
| 55 | |||
| 56 | =head1 QUICK MARKDOWN TO HTML CONVERSION | ||
| 57 | |||
| 58 | If you just want to do some quick Markdown to HTML conversion use either the | ||
| 59 | L<Markdent::Simple::Document> or L<Markdent::Simple::Fragment> class. | ||
| 60 | |||
| 61 | This distribution also ships with a command line tool called | ||
| 62 | L<markdent-html>. See that tool's documentation for details on how to use it. | ||
| 63 | |||
| 64 | =head1 PROCESSING PIPELINES | ||
| 65 | |||
| 66 | If you want to create a Markdown processing pipeline, start by looking at the | ||
| 67 | various handler classes: | ||
| 68 | |||
| 69 | =over 4 | ||
| 70 | |||
| 71 | =item * L<Markdent::Handler::HTMLStream::Document> | ||
| 72 | |||
| 73 | =item * L<Markdent::Handler::HTMLStream::Fragment> | ||
| 74 | |||
| 75 | =item * L<Markdent::Handler::HTMLStream::Multiplexer> | ||
| 76 | |||
| 77 | =item * L<Markdent::Handler::HTMLStream::HTMLFilter> | ||
| 78 | |||
| 79 | =item * L<Markdent::Handler::HTMLStream::CaptureEvents> | ||
| 80 | |||
| 81 | =back | ||
| 82 | |||
| 83 | You will probably also want to write your own handler class as part of the | ||
| 84 | pipeline. This will need to implement the L<Markdent::Role::Handler> role. | ||
| 85 | |||
| 86 | To do that you'll need to review the many C<Markdent::Event::*> classes. Each | ||
| 87 | event represents something seen by the parse, such as a piece of the start or | ||
| 88 | end of a piece of block (paragraph, header) or span markup (strong, link) or | ||
| 89 | some text. | ||
| 90 | |||
| 91 | The start of a pipeline will generally be either the L<Markdent::Parser> or | ||
| 92 | L<Markdent::CapturedEvents> class. | ||
| 93 | |||
| 94 | =head1 CUSTOM DIALECTS | ||
| 95 | |||
| 96 | You may also want to implement a custom dialect to add some additional | ||
| 97 | features to the parser. Your parser classes will need to consume either the | ||
| 98 | L<Markdent::Role::Dialect::BlockParser> or the | ||
| 99 | L<Markdent::Role::Dialect::SpanParser> role. The best way to understand how a | ||
| 100 | dialect is implemented is to look at one of the existing dialect classes: | ||
| 101 | |||
| 102 | =over 4 | ||
| 103 | |||
| 104 | =item * L<Markdent::Dialect::GitHub::BlockParser> | ||
| 105 | |||
| 106 | =item * L<Markdent::Dialect::GitHub::SpanParser> | ||
| 107 | |||
| 108 | =item * L<Markdent::Dialect::Theory::BlockParser> | ||
| 109 | |||
| 110 | =item * L<Markdent::Dialect::Theory::SpanParser> | ||
| 111 | |||
| 112 | =back | ||
| 113 | |||
| 114 | You'll also need to dig into the core L<Markdent::Parser::BlockParser> and | ||
| 115 | L<Markdent::Parser::SpanParser> classes in order to see how these dialects | ||
| 116 | interact with the core parser. | ||
| 117 | |||
| 118 | =head1 DONATIONS | ||
| 119 | |||
| 120 | If you'd like to thank me for the work I've done on this module, | ||
| 121 | please consider making a "donation" to me via PayPal. I spend a lot of | ||
| 122 | free time creating free software, and would appreciate any support | ||
| 123 | you'd care to offer. | ||
| 124 | |||
| 125 | Please note that B<I am not suggesting that you must do this> in order | ||
| 126 | for me to continue working on this particular software. I will | ||
| 127 | continue to do so, inasmuch as I have in the past, for as long as it | ||
| 128 | interests me. | ||
| 129 | |||
| 130 | Similarly, a donation made in this way will probably not make me work | ||
| 131 | on this software much more, unless I get so many donations that I can | ||
| 132 | consider working on free software full time, which seems unlikely at | ||
| 133 | best. | ||
| 134 | |||
| 135 | To donate, log into PayPal and send money to autarch@urth.org or use | ||
| 136 | the button on this page: | ||
| 137 | L<http://www.urth.org/~autarch/fs-donation.html> | ||
| 138 | |||
| 139 | =head1 BUGS | ||
| 140 | |||
| 141 | Please report any bugs or feature requests to C<bug-markdent@rt.cpan.org>, | ||
| 142 | or through the web interface at L<http://rt.cpan.org>. I will be | ||
| 143 | notified, and then you'll automatically be notified of progress on | ||
| 144 | your bug as I make changes. | ||
| 145 | |||
| 146 | Bugs may be submitted at L<https://github.com/houseabsolute/Markdent/issues>. | ||
| 147 | |||
| 148 | I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>. | ||
| 149 | |||
| 150 | =head1 SOURCE | ||
| 151 | |||
| 152 | The source code repository for Markdent can be found at L<https://github.com/houseabsolute/Markdent>. | ||
| 153 | |||
| 154 | =head1 DONATIONS | ||
| 155 | |||
| 156 | If you'd like to thank me for the work I've done on this module, please | ||
| 157 | consider making a "donation" to me via PayPal. I spend a lot of free time | ||
| 158 | creating free software, and would appreciate any support you'd care to offer. | ||
| 159 | |||
| 160 | Please note that B<I am not suggesting that you must do this> in order for me | ||
| 161 | to continue working on this particular software. I will continue to do so, | ||
| 162 | inasmuch as I have in the past, for as long as it interests me. | ||
| 163 | |||
| 164 | Similarly, a donation made in this way will probably not make me work on this | ||
| 165 | software much more, unless I get so many donations that I can consider working | ||
| 166 | on free software full time (let's all have a chuckle at that together). | ||
| 167 | |||
| 168 | To donate, log into PayPal and send money to autarch@urth.org, or use the | ||
| 169 | button at L<https://www.urth.org/fs-donation.html>. | ||
| 170 | |||
| 171 | =head1 AUTHOR | ||
| 172 | |||
| 173 | Dave Rolsky <autarch@urth.org> | ||
| 174 | |||
| 175 | =head1 CONTRIBUTORS | ||
| 176 | |||
| 177 | =for stopwords Andrew Speer Denis Ibaev Jason McIntosh Jonas Smedegaard Konrad Bucheli Polina Shubina Shlomi Fish Stefan Hornburg (Racke) Tom Hukins | ||
| 178 | |||
| 179 | =over 4 | ||
| 180 | |||
| 181 | =item * | ||
| 182 | |||
| 183 | Andrew Speer <andrew.speer@isolutions.com.au> | ||
| 184 | |||
| 185 | =item * | ||
| 186 | |||
| 187 | Denis Ibaev <dionys@gmail.com> | ||
| 188 | |||
| 189 | =item * | ||
| 190 | |||
| 191 | Jason McIntosh <jmac@appleseed-sc.com> | ||
| 192 | |||
| 193 | =item * | ||
| 194 | |||
| 195 | Jonas Smedegaard <dr@jones.dk> | ||
| 196 | |||
| 197 | =item * | ||
| 198 | |||
| 199 | Konrad Bucheli <konrad.bucheli@gmx.ch> | ||
| 200 | |||
| 201 | =item * | ||
| 202 | |||
| 203 | Polina Shubina <925043@mai.com> | ||
| 204 | |||
| 205 | =item * | ||
| 206 | |||
| 207 | Shlomi Fish <shlomif@shlomifish.org> | ||
| 208 | |||
| 209 | =item * | ||
| 210 | |||
| 211 | Stefan Hornburg (Racke) <racke@linuxia.de> | ||
| 212 | |||
| 213 | =item * | ||
| 214 | |||
| 215 | Tom Hukins <tom@eborcom.com> | ||
| 216 | |||
| 217 | =back | ||
| 218 | |||
| 219 | =head1 COPYRIGHT AND LICENSE | ||
| 220 | |||
| 221 | This software is copyright (c) 2021 by Dave Rolsky. | ||
| 222 | |||
| 223 | This is free software; you can redistribute it and/or modify it under | ||
| 224 | the same terms as the Perl 5 programming language system itself. | ||
| 225 | |||
| 226 | The full text of the license can be found in the | ||
| 227 | F<LICENSE> file included with this distribution. | ||
| 228 | |||
| 229 | =cut |