1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330
|
# vim: set ts=2 sts=2 sw=2 expandtab smarttab:
use strict;
use warnings;
use lib 't/lib';
use MarkdownTests tests => 1;
my $parser = Pod::Markdown->new(
perldoc_url_prefix => 'pod://',
# Just return the raw fragment so we know that it isn't unexpectedly mangled.
perldoc_fragment_format => sub { $_ },
markdown_fragment_format => sub { $_ },
);
my $pod_prefix = $parser->perldoc_url_prefix;
$parser->parse_from_filehandle(\*DATA);
my $markdown = $parser->as_markdown;
my $expect = <<'EOMARKDOWN';
# POD
pod2markdown - Convert POD text to Markdown
# SYNOPSIS
$ pod2markdown < POD_File > Markdown_File
# DESCRIPTION
This program uses [Pod::Markdown](pod://Pod::Markdown) to convert POD into Markdown sources. It is
a filter that expects POD on STDIN and outputs Markdown on STDOUT.
FTP is at [ftp://ftp.univie.ac.at/foo/bar](ftp://ftp.univie.ac.at/foo/bar).
HTTP is at [http://univie.ac.at/baz/](http://univie.ac.at/baz/).
# SEE ALSO
This program is strongly based on `pod2mdwn` from [Module::Build::IkiWiki](pod://Module::Build::IkiWiki).
And see ["foobar"](#foobar) as well.
> Quote some poetry
> or say something special.
# MORE TESTS
## _Italics_, **Bold**, `Code`, and [Links](pod://Links) should work in headers
_Italics_, **Bold**, `Code`, and [Links](pod://Links) should work in body text.
**Nested `codes`** work, too
## \_Other\_ \*Characters\* \[Should\](Be) \`Escaped\` in headers
Inline `code _need not_ be escaped`.
Inline [link \*should\* \\\_ be\_escaped](#or\\things\(can\)go\\*wrong).
Inline `filename_should_not_be_escaped` because it is a code span.
### Heading `code _need not_ be escaped, either`.
**Nested `c*des` \_should\_ be escaped** (but not code).
non-breaking space: foo bar.
non-breaking code: `$x ? $y : $z` foo `bar` baz
verbatim para B<with> C<< E<verbar> >> codes
A `` code span with `backticks` inside ``.
A ```` code span with triple ``` inside ````.
- This
- is
- a
basic
- bulleted
item
- list
- test
- and _Italics_, **Bold**, `Code`, and [Links](pod://Links) should work in list item
# Links
[Formatting `C`odes](pod://Links#L<...>)
[back \`tick](pod://inside#a link)
# \*Special\* characters
foo_bar is the result of 4 * 4
Regular characters like \*asterisks\* and \_\_underscores\_\_
should be escaped in regular text paragraphs.
Also \[brackets\],
lists:
\+ a
\+ b
\- a
\- b
\* A line that starts with an asterisk
\*should\* be escaped to avoid incorrectly interpreting
the line as a list item.
\# fake headings
\### fake headings ###
Setext fake
===========
Another fake
\------------
\> Quote
\> blocks
\> 1. with
\> 2. lists
1996\. A year.
\* Bird
\* Magic
\* List item
`code` block
Hr's:
\---
\* \* \*
Inline \`code\`;
Links: \[Foo\] \[1\], \[Bar\](/baz)
An image: !\[image\](/foo)
backslash \\
From http://daringfireball.net/projects/markdown/syntax:
\\ backslash
\` backtick
\* asterisk
\_ underscore
{} curly braces
\[\] square brackets
() parentheses
\# hash mark
\+ plus sign
\- minus sign (hyphen)
. dot
! exclamation mark
EOMARKDOWN
eq_or_diff $markdown, $expect, "this file's POD as markdown";
__DATA__
=head1 POD
pod2markdown - Convert POD text to Markdown
=head1 SYNOPSIS
$ pod2markdown < POD_File > Markdown_File
=head1 DESCRIPTION
This program uses L<Pod::Markdown> to convert POD into Markdown sources. It is
a filter that expects POD on STDIN and outputs Markdown on STDOUT.
FTP is at L<ftp://ftp.univie.ac.at/foo/bar>.
HTTP is at L<http://univie.ac.at/baz/>.
=head1 SEE ALSO
This program is strongly based on C<pod2mdwn> from L<Module::Build::IkiWiki>.
And see L</foobar> as well.
=over
Quote some poetry
or say something special.
=back
=head1 MORE TESTS
=head2 I<Italics>, B<Bold>, C<Code>, and L<Links> should work in headers
I<Italics>, B<Bold>, C<Code>, and L<Links> should work in body text.
B<< Nested C<codes> >> work, too
=head2 _Other_ *Characters* [Should](Be) `Escaped` in headers
Inline C<< code _need not_ be escaped >>.
Inline L<< link *should* \_ be_escaped|/or\things(can)go\*wrong >>.
Inline F<< filename_should_not_be_escaped >> because it is a code span.
=head3 Heading C<< code _need not_ be escaped, either >>.
B<< Nested C<c*des> _should_ be escaped >> (but not code).
non-breaking space: S<foo bar>.
non-breaking code: S<C<$x ? $y : $z>> S<foo C<bar> baz>
verbatim para B<with> C<< E<verbar> >> codes
A C<< code span with `backticks` inside >>.
A C<< code span with triple ``` inside >>.
=over 4
=item *
This
=item * is
=item * a
basic
=item *
bulleted
item
=item *
list
=item * test
=item * and I<Italics>, B<Bold>, C<Code>, and L<Links> should work in list item
=back
=head1 Links
L<<< FormattZ<>ing C<C>odes|Links/"LE<lt>...E<gt>" >>>
L<<< back `tick|inside/"a link" >>>
=head1 *Special* characters
foo_bar is the result of 4 * 4
Regular characters like *asterisks* and __underscores__
should be escaped in regular text paragraphs.
Also [brackets],
lists:
+ a
+ b
- a
- b
* A line that starts with an asterisk
*should* be escaped to avoid incorrectly interpreting
the line as a list item.
# fake headings
### fake headings ###
Setext fake
===========
Another fake
------------
> Quote
> blocks
> 1. with
> 2. lists
1996. A year.
* Bird
* Magic
* List item
`code` block
Hr's:
---
* * *
Inline `code`;
Links: [Foo] [1], [Bar](/baz)
An image: 
backslash \
From http://daringfireball.net/projects/markdown/syntax:
\ backslash
` backtick
* asterisk
_ underscore
{} curly braces
[] square brackets
() parentheses
# hash mark
+ plus sign
- minus sign (hyphen)
. dot
! exclamation mark
|