| 1 | package Text::Markup::Markdown; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use 5.8.1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use Text::Markup; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use File::BOM qw(open_bom); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Text::Markdown::Discount; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | our $VERSION = '0.43'; | |||||||||
| 11 | |||||||||||
| 12 | 3 | ▶ | sub import { | ||||||||
|
Subroutine
import: called CC=2 SCAR=6.9
| |||||||||||
| 13 | # Replace the regex if passed one. | ||||||||||
| 14 | 3 | ▶ | Text::Markup->register( markdown => $_[1] ) if $_[1]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | } | ||||||||||
| 16 | |||||||||||
| 17 | 2 | ▶ | sub parser { | ||||||||
|
Subroutine
parser: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||
| 18 | 2 | my ($file, $encoding, $opts) = @_; | |||||||||
| 19 | 2 | my %params = @{ $opts }; | |||||||||
| 20 | |||||||||||
| 21 | 2 | ▶ | unless (defined $params{flags}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | 2 | $params{flags} = Text::Markdown::Discount::MKD_NOHEADER | |||||||||
| 23 | | Text::Markdown::Discount::MKD_TOC | ||||||||||
| 24 | | Text::Markdown::Discount::MKD_DLEXTRA | ||||||||||
| 25 | | Text::Markdown::Discount::MKD_FENCEDCODE | ||||||||||
| 26 | | Text::Markdown::Discount::MKD_EXTRA_FOOTNOTE | ||||||||||
| 27 | | Text::Markdown::Discount::MKD_IDANCHOR; | ||||||||||
| 28 | } | ||||||||||
| 29 | 2 | open_bom my $fh, $file, ":encoding($encoding)"; | |||||||||
| 30 | 2 | my $html = Text::Markdown::Discount::markdown(join('', <$fh>), $params{flags}); | |||||||||
| 31 | 2 | ▶ | return unless $html =~ /\S/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 1 | utf8::encode($html); | |||||||||
| 33 | 1 | ▶ | return $html if $params{raw}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 1 | return qq{<html> | |||||||||
| 35 | <head> | ||||||||||
| 36 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | ||||||||||
| 37 | </head> | ||||||||||
| 38 | <body> | ||||||||||
| 39 | $html | ||||||||||
| 40 | </body> | ||||||||||
| 41 | </html> | ||||||||||
| 42 | }; | ||||||||||
| 43 | |||||||||||
| 44 | } | ||||||||||
| 45 | |||||||||||
| 46 | 1 | 1; | |||||||||
| 47 | __END__ | ||||||||||