line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
extern "C" { |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
} /* extern "C" */ |
12
|
|
|
|
|
|
|
#endif |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#include <string.h> |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#define NEED_newSVpvn_flags |
17
|
|
|
|
|
|
|
#include "ppport.h" |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#include "../../hoedown/src/markdown.h" |
20
|
|
|
|
|
|
|
#include "../../hoedown/src/html.h" |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#define XS_STRUCT2OBJ(sv, class, obj) \ |
23
|
|
|
|
|
|
|
sv = newSViv(PTR2IV(obj)); \ |
24
|
|
|
|
|
|
|
sv = newRV_noinc(sv); \ |
25
|
|
|
|
|
|
|
sv_bless(sv, gv_stashpv(class, 1)); \ |
26
|
|
|
|
|
|
|
SvREADONLY_on(sv); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#define XS_STATE(type, x) \ |
29
|
|
|
|
|
|
|
INT2PTR(type, SvROK(x) ? SvIV(SvRV(x)) : SvIV(x)) |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#define PUSHBUF(text) \ |
32
|
|
|
|
|
|
|
if (text) { \ |
33
|
|
|
|
|
|
|
mXPUSHp(text->data, text->size); \ |
34
|
|
|
|
|
|
|
} else { \ |
35
|
|
|
|
|
|
|
XPUSHs(&PL_sv_undef); \ |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
#define CB_HEADER(key) \ |
39
|
|
|
|
|
|
|
SV* cb = *rcb; \ |
40
|
|
|
|
|
|
|
\ |
41
|
|
|
|
|
|
|
ENTER; \ |
42
|
|
|
|
|
|
|
SAVETMPS; \ |
43
|
|
|
|
|
|
|
\ |
44
|
|
|
|
|
|
|
PUSHMARK(SP); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
#define CB_FOOTER \ |
47
|
|
|
|
|
|
|
PUTBACK; \ |
48
|
|
|
|
|
|
|
\ |
49
|
|
|
|
|
|
|
int count = call_sv(cb, G_SCALAR); \ |
50
|
|
|
|
|
|
|
\ |
51
|
|
|
|
|
|
|
SPAGAIN; \ |
52
|
|
|
|
|
|
|
\ |
53
|
|
|
|
|
|
|
if (count == 1) { \ |
54
|
|
|
|
|
|
|
SV* ret = POPs; \ |
55
|
|
|
|
|
|
|
if (ret != &PL_sv_undef) { \ |
56
|
|
|
|
|
|
|
STRLEN l; \ |
57
|
|
|
|
|
|
|
char * p = SvPV(ret, l); \ |
58
|
|
|
|
|
|
|
hoedown_buffer_grow(ob, ob->size + l); \ |
59
|
|
|
|
|
|
|
hoedown_buffer_put(ob, p, l); \ |
60
|
|
|
|
|
|
|
} else {\ |
61
|
|
|
|
|
|
|
is_null = 1;\ |
62
|
|
|
|
|
|
|
} \ |
63
|
|
|
|
|
|
|
} \ |
64
|
|
|
|
|
|
|
\ |
65
|
|
|
|
|
|
|
PUTBACK; \ |
66
|
|
|
|
|
|
|
FREETMPS; \ |
67
|
|
|
|
|
|
|
LEAVE; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#include "gen.callback.c" |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
#define TMH_CONST(name) \ |
73
|
|
|
|
|
|
|
newCONSTSUB(stash, #name, newSViv(name)); \ |
74
|
|
|
|
|
|
|
av_push(get_av("Text::Markdown::Hoedown::EXPORT", GV_ADD), newSVpv(#name, 0)); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
MODULE = Text::Markdown::Hoedown PACKAGE = Text::Markdown::Hoedown PREFIX=hoedown_markdown_ |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
BOOT: |
79
|
4
|
|
|
|
|
|
HV* stash = gv_stashpv("Text::Markdown::Hoedown", GV_ADD); |
80
|
|
|
|
|
|
|
|
81
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_NO_INTRA_EMPHASIS); |
82
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_TABLES); |
83
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_FENCED_CODE); |
84
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_AUTOLINK); |
85
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_STRIKETHROUGH); |
86
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_UNDERLINE); |
87
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_SPACE_HEADERS); |
88
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_SUPERSCRIPT); |
89
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_LAX_SPACING); |
90
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_DISABLE_INDENTED_CODE); |
91
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_HIGHLIGHT); |
92
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_FOOTNOTES); |
93
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_QUOTE); |
94
|
|
|
|
|
|
|
|
95
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_HTML_SKIP_HTML); |
96
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_HTML_SKIP_STYLE); |
97
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_HTML_SKIP_IMAGES); |
98
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_HTML_SKIP_LINKS); |
99
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_HTML_EXPAND_TABS); |
100
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_HTML_SAFELINK); |
101
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_HTML_TOC); |
102
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_HTML_HARD_WRAP); |
103
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_HTML_USE_XHTML); |
104
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_HTML_ESCAPE); |
105
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_HTML_PRETTIFY); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
TYPEMAP: <<HERE |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
hoedown_renderer* T_H_RENDERER |
110
|
|
|
|
|
|
|
hoedown_markdown* T_H_MARKDOWN |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
OUTPUT |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
T_H_MARKDOWN |
115
|
|
|
|
|
|
|
sv_setref_pv($arg, \"Text::Markdown::Hoedown::Markdown\", (void*)$var); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
INPUT |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
T_H_MARKDOWN |
120
|
|
|
|
|
|
|
$var = INT2PTR($type, SvROK($arg) ? SvIV(SvRV($arg)) : SvIV($arg)); |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
HERE |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
MODULE = Text::Markdown::Hoedown PACKAGE = Text::Markdown::Hoedown::Markdown |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
hoedown_markdown * |
129
|
|
|
|
|
|
|
new(const char* klass, unsigned int extensions, size_t max_nesting, SV* renderer_sv) |
130
|
|
|
|
|
|
|
CODE: |
131
|
6
|
50
|
|
|
|
|
hoedown_renderer* renderer = XS_STATE(hoedown_renderer*, renderer_sv); |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
132
|
6
|
|
|
|
|
|
RETVAL = hoedown_markdown_new(extensions, max_nesting, renderer); |
133
|
|
|
|
|
|
|
OUTPUT: |
134
|
|
|
|
|
|
|
RETVAL |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
SV* |
137
|
|
|
|
|
|
|
render(hoedown_markdown *self, SV *src_sv) |
138
|
|
|
|
|
|
|
PREINIT: |
139
|
|
|
|
|
|
|
struct hoedown_buffer* ob; |
140
|
|
|
|
|
|
|
const char *src; |
141
|
|
|
|
|
|
|
STRLEN src_len; |
142
|
|
|
|
|
|
|
CODE: |
143
|
6
|
|
|
|
|
|
ob = hoedown_buffer_new(64); |
144
|
6
|
50
|
|
|
|
|
if (!ob) { |
145
|
0
|
|
|
|
|
|
croak("Cannot create new hoedown_buffer(malloc failed)"); |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
6
|
50
|
|
|
|
|
src = SvPV(src_sv, src_len); |
149
|
6
|
|
|
|
|
|
hoedown_markdown_render(ob, src, src_len, self); |
150
|
|
|
|
|
|
|
|
151
|
6
|
|
|
|
|
|
SV* ret = newSVpv(hoedown_buffer_cstr(ob), 0); |
152
|
6
|
100
|
|
|
|
|
if (SvUTF8(src_sv)) { |
153
|
2
|
|
|
|
|
|
SvUTF8_on(ret); |
154
|
|
|
|
|
|
|
} |
155
|
6
|
|
|
|
|
|
hoedown_buffer_free(ob); |
156
|
|
|
|
|
|
|
RETVAL = ret; |
157
|
|
|
|
|
|
|
OUTPUT: |
158
|
|
|
|
|
|
|
RETVAL |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
MODULE = Text::Markdown::Hoedown PACKAGE = Text::Markdown::Hoedown::Renderer::HTML |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
void |
163
|
|
|
|
|
|
|
new(const char* klass, unsigned int render_flags, int nesting_level) |
164
|
|
|
|
|
|
|
PPCODE: |
165
|
5
|
|
|
|
|
|
hoedown_renderer * renderer = hoedown_html_renderer_new( |
166
|
|
|
|
|
|
|
render_flags, nesting_level |
167
|
|
|
|
|
|
|
); |
168
|
5
|
|
|
|
|
|
ST(0) = sv_newmortal(); |
169
|
5
|
|
|
|
|
|
sv_setref_pv(ST(0), "Text::Markdown::Hoedown::Renderer::HTML", (void*)renderer); |
170
|
5
|
|
|
|
|
|
XSRETURN(1); |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
void |
173
|
|
|
|
|
|
|
DESTROY(SV* this) |
174
|
|
|
|
|
|
|
CODE: |
175
|
5
|
50
|
|
|
|
|
hoedown_renderer* self = INT2PTR(hoedown_renderer*, SvROK(this) ? SvIV(SvRV(this)) : SvIV(this)); |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
176
|
5
|
|
|
|
|
|
hoedown_html_renderer_free(self); |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
MODULE = Text::Markdown::Hoedown PACKAGE = Text::Markdown::Hoedown::Renderer::HTMLTOC |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
void |
181
|
|
|
|
|
|
|
new(const char* klass, int nesting_level) |
182
|
|
|
|
|
|
|
PPCODE: |
183
|
1
|
|
|
|
|
|
hoedown_renderer * renderer = hoedown_html_toc_renderer_new( |
184
|
|
|
|
|
|
|
nesting_level |
185
|
|
|
|
|
|
|
); |
186
|
1
|
|
|
|
|
|
ST(0) = sv_newmortal(); |
187
|
1
|
|
|
|
|
|
sv_setref_pv(ST(0), "Text::Markdown::Hoedown::Renderer::HTMLTOC", (void*)renderer); |
188
|
1
|
|
|
|
|
|
XSRETURN(1); |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
void |
191
|
|
|
|
|
|
|
DESTROY(SV* this) |
192
|
|
|
|
|
|
|
CODE: |
193
|
1
|
50
|
|
|
|
|
hoedown_renderer* self = INT2PTR(hoedown_renderer*, SvROK(this) ? SvIV(SvRV(this)) : SvIV(this)); |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
194
|
1
|
|
|
|
|
|
hoedown_html_renderer_free(self); |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
MODULE = Text::Markdown::Hoedown PACKAGE = Text::Markdown::Hoedown::Renderer::Callback |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
void |
199
|
|
|
|
|
|
|
new(const char* klass) |
200
|
|
|
|
|
|
|
PPCODE: |
201
|
|
|
|
|
|
|
hoedown_renderer * renderer; |
202
|
1
|
|
|
|
|
|
Newxz(renderer, 1, hoedown_renderer); |
203
|
1
|
|
|
|
|
|
renderer->opaque = newHV(); |
204
|
1
|
|
|
|
|
|
ST(0) = sv_newmortal(); |
205
|
1
|
|
|
|
|
|
sv_setref_pv(ST(0), "Text::Markdown::Hoedown::Renderer::Callback", (void*)renderer); |
206
|
1
|
|
|
|
|
|
XSRETURN(1); |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
void |
209
|
|
|
|
|
|
|
DESTROY(SV* this) |
210
|
|
|
|
|
|
|
CODE: |
211
|
1
|
50
|
|
|
|
|
hoedown_renderer* self = INT2PTR(hoedown_renderer*, SvROK(this) ? SvIV(SvRV(this)) : SvIV(this)); |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
212
|
1
|
|
|
|
|
|
SvREFCNT_dec(self->opaque); |
213
|
1
|
|
|
|
|
|
Safefree(self); |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
INCLUDE: gen.callback.inc |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
|