line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Markdown::Hoedown; |
2
|
4
|
|
|
4
|
|
107180
|
use 5.008005; |
|
4
|
|
|
|
|
18
|
|
|
4
|
|
|
|
|
175
|
|
3
|
4
|
|
|
4
|
|
24
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
174
|
|
4
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
27
|
|
|
4
|
|
|
|
|
169
|
|
5
|
4
|
|
|
4
|
|
4654
|
use parent qw(Exporter); |
|
4
|
|
|
|
|
1760
|
|
|
4
|
|
|
|
|
23
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = "1.01"; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our @EXPORT = qw( |
10
|
|
|
|
|
|
|
markdown |
11
|
|
|
|
|
|
|
markdown_toc |
12
|
|
|
|
|
|
|
); |
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
345
|
use XSLoader; |
|
4
|
|
|
|
|
146
|
|
|
4
|
|
|
|
|
1104
|
|
15
|
|
|
|
|
|
|
XSLoader::load(__PACKAGE__, $VERSION); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub markdown { |
18
|
4
|
|
|
4
|
1
|
1342
|
my $str = shift; |
19
|
4
|
|
|
|
|
21
|
my %args = ( |
20
|
|
|
|
|
|
|
html_options => 0, |
21
|
|
|
|
|
|
|
extensions => 0, |
22
|
|
|
|
|
|
|
max_nesting => 16, |
23
|
|
|
|
|
|
|
toc_nesting_lvl => 99, |
24
|
|
|
|
|
|
|
@_, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
4
|
|
|
|
|
28
|
my $renderer = Text::Markdown::Hoedown::Renderer::HTML->new( |
28
|
|
|
|
|
|
|
$args{html_options}, |
29
|
|
|
|
|
|
|
$args{toc_nesting_lvl}, |
30
|
|
|
|
|
|
|
); |
31
|
4
|
|
|
|
|
42
|
my $md = Text::Markdown::Hoedown::Markdown->new( |
32
|
|
|
|
|
|
|
$args{extensions}, |
33
|
|
|
|
|
|
|
$args{max_nesting}, |
34
|
|
|
|
|
|
|
$renderer |
35
|
|
|
|
|
|
|
); |
36
|
4
|
|
|
|
|
129
|
return $md->render($str); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub markdown_toc { |
40
|
1
|
|
|
1
|
1
|
7
|
my $str = shift; |
41
|
1
|
|
|
|
|
5
|
my %args = ( |
42
|
|
|
|
|
|
|
nesting_level => 6, |
43
|
|
|
|
|
|
|
extensions => 0, |
44
|
|
|
|
|
|
|
max_nesting => 16, |
45
|
|
|
|
|
|
|
@_, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
34
|
my $renderer = Text::Markdown::Hoedown::Renderer::HTMLTOC->new( |
49
|
|
|
|
|
|
|
$args{nesting_level}, |
50
|
|
|
|
|
|
|
); |
51
|
1
|
|
|
|
|
23
|
my $md = Text::Markdown::Hoedown::Markdown->new( |
52
|
|
|
|
|
|
|
$args{extensions}, |
53
|
|
|
|
|
|
|
$args{max_nesting}, |
54
|
|
|
|
|
|
|
$renderer, |
55
|
|
|
|
|
|
|
); |
56
|
1
|
|
|
|
|
65
|
return $md->render($str); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
__END__ |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=for stopwords sundown hoedown markdown subtree |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=encoding utf-8 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 NAME |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Text::Markdown::Hoedown - hoedown for Perl5 |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SYNOPSIS |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
use Text::Markdown::Hoedown; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
print markdown(<<'...'); |
75
|
|
|
|
|
|
|
# foo |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
bar |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
* hoge |
80
|
|
|
|
|
|
|
* fuga |
81
|
|
|
|
|
|
|
... |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 DESCRIPTION |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Text::Markdown::Hoedown is binding library for hoedown. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
hoedown is a forking project from sundown. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 FUNCTIONS |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=over 4 |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item C< my $out = markdown($src :Str, %options) :Str > |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Rendering markdown. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Options are following: |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over 4 |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item toc_nesting_lvl |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Nesting levels for TOC generation. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
(Default: 99) |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item extensions |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This is bit flag. You can use the flags by '|' operator. |
110
|
|
|
|
|
|
|
Values are following: |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
enum hoedown_extensions { |
113
|
|
|
|
|
|
|
HOEDOWN_EXT_NO_INTRA_EMPHASIS = (1 << 0), |
114
|
|
|
|
|
|
|
HOEDOWN_EXT_TABLES = (1 << 1), |
115
|
|
|
|
|
|
|
HOEDOWN_EXT_FENCED_CODE = (1 << 2), |
116
|
|
|
|
|
|
|
HOEDOWN_EXT_AUTOLINK = (1 << 3), |
117
|
|
|
|
|
|
|
HOEDOWN_EXT_STRIKETHROUGH = (1 << 4), |
118
|
|
|
|
|
|
|
HOEDOWN_EXT_UNDERLINE = (1 << 5), |
119
|
|
|
|
|
|
|
HOEDOWN_EXT_SPACE_HEADERS = (1 << 6), |
120
|
|
|
|
|
|
|
HOEDOWN_EXT_SUPERSCRIPT = (1 << 7), |
121
|
|
|
|
|
|
|
HOEDOWN_EXT_LAX_SPACING = (1 << 8), |
122
|
|
|
|
|
|
|
HOEDOWN_EXT_DISABLE_INDENTED_CODE = (1 << 9), |
123
|
|
|
|
|
|
|
HOEDOWN_EXT_HIGHLIGHT = (1 << 10), |
124
|
|
|
|
|
|
|
HOEDOWN_EXT_FOOTNOTES = (1 << 11), |
125
|
|
|
|
|
|
|
HOEDOWN_EXT_QUOTE = (1 << 12) |
126
|
|
|
|
|
|
|
}; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item html_options |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This is bit flag. You can use the flags by '|' operator. |
131
|
|
|
|
|
|
|
Values are following: |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
typedef enum { |
134
|
|
|
|
|
|
|
HOEDOWN_HTML_SKIP_HTML = (1 << 0), |
135
|
|
|
|
|
|
|
HOEDOWN_HTML_SKIP_STYLE = (1 << 1), |
136
|
|
|
|
|
|
|
HOEDOWN_HTML_SKIP_IMAGES = (1 << 2), |
137
|
|
|
|
|
|
|
HOEDOWN_HTML_SKIP_LINKS = (1 << 3), |
138
|
|
|
|
|
|
|
HOEDOWN_HTML_EXPAND_TABS = (1 << 4), |
139
|
|
|
|
|
|
|
HOEDOWN_HTML_SAFELINK = (1 << 5), |
140
|
|
|
|
|
|
|
HOEDOWN_HTML_TOC = (1 << 6), |
141
|
|
|
|
|
|
|
HOEDOWN_HTML_HARD_WRAP = (1 << 7), |
142
|
|
|
|
|
|
|
HOEDOWN_HTML_USE_XHTML = (1 << 8), |
143
|
|
|
|
|
|
|
HOEDOWN_HTML_ESCAPE = (1 << 9), |
144
|
|
|
|
|
|
|
HOEDOWN_HTML_PRETTIFY = (1 << 10) |
145
|
|
|
|
|
|
|
} hoedown_html_render_mode; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item max_nesting |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
I don't know what this do. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=back |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item C<< markdown_toc($src:Str, %opts) :Str >> |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Generate TOC HTML from C<$str>. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Options are following: |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=over 4 |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item nesting_level |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Maximum nesting level for TOC. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item extensions |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Same as above. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item max_nesting |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Same as above. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=back |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
All C<HOEDOWN_*> constants are exported by default. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=back |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 TODO |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=over 4 |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item Document about low level APIs |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=back |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 HACKING |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
C<hoedown/> directory is managed by git subtree. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
You can pull the modifications from upstream by following command: |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
git subtree pull --prefix=hoedown git@github.com:hoedown/hoedown.git master |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 LICENSE |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Copyright (C) tokuhirom. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
200
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head1 AUTHOR |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
tokuhirom E<lt>tokuhirom@gmail.comE<gt> |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=cut |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
|