line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#ifdef __cplusplus |
2
|
|
|
|
|
|
|
extern "C" { |
3
|
|
|
|
|
|
|
#endif |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#define PERL_NO_GET_CONTEXT /* we want efficiency */ |
6
|
|
|
|
|
|
|
#include |
7
|
|
|
|
|
|
|
#include |
8
|
|
|
|
|
|
|
#include |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#ifdef __cplusplus |
11
|
|
|
|
|
|
|
} /* extern "C" */ |
12
|
|
|
|
|
|
|
#endif |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#include |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#define NEED_newSVpvn_flags |
17
|
|
|
|
|
|
|
#include "ppport.h" |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#include "../../hoedown/src/document.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_document_ |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
BOOT: |
79
|
4
|
|
|
|
|
|
HV* stash = gv_stashpv("Text::Markdown::Hoedown", GV_ADD); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
/* block-level extensions */ |
82
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_TABLES); |
83
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_FENCED_CODE); |
84
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_FOOTNOTES); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
/* span-level extensions */ |
87
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_AUTOLINK); |
88
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_STRIKETHROUGH); |
89
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_UNDERLINE); |
90
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_HIGHLIGHT); |
91
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_QUOTE); |
92
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_SUPERSCRIPT); |
93
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_MATH); |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
/* other flags */ |
96
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_NO_INTRA_EMPHASIS); |
97
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_SPACE_HEADERS); |
98
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_MATH_EXPLICIT); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
/* negative flags */ |
101
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_EXT_DISABLE_INDENTED_CODE); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
/* HTML */ |
104
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_HTML_SKIP_HTML); |
105
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_HTML_ESCAPE); |
106
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_HTML_HARD_WRAP); |
107
|
4
|
|
|
|
|
|
TMH_CONST(HOEDOWN_HTML_USE_XHTML); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
TYPEMAP: <
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
hoedown_renderer* T_H_RENDERER |
112
|
|
|
|
|
|
|
hoedown_document* T_H_DOCUMENT |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
OUTPUT |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
T_H_DOCUMENT |
117
|
|
|
|
|
|
|
sv_setref_pv($arg, \"Text::Markdown::Hoedown::Markdown\", (void*)$var); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
INPUT |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
T_H_DOCUMENT |
122
|
|
|
|
|
|
|
$var = INT2PTR($type, SvROK($arg) ? SvIV(SvRV($arg)) : SvIV($arg)); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
HERE |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
MODULE = Text::Markdown::Hoedown PACKAGE = Text::Markdown::Hoedown::Markdown |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
hoedown_document * |
131
|
|
|
|
|
|
|
new(const char* klass, unsigned int extensions, size_t max_nesting, SV* renderer_sv) |
132
|
|
|
|
|
|
|
CODE: |
133
|
7
|
50
|
|
|
|
|
hoedown_renderer* renderer = XS_STATE(hoedown_renderer*, renderer_sv); |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
134
|
7
|
|
|
|
|
|
RETVAL = hoedown_document_new(renderer, extensions, max_nesting); |
135
|
|
|
|
|
|
|
OUTPUT: |
136
|
|
|
|
|
|
|
RETVAL |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
SV* |
139
|
|
|
|
|
|
|
render(hoedown_document *self, SV *src_sv) |
140
|
|
|
|
|
|
|
PREINIT: |
141
|
|
|
|
|
|
|
struct hoedown_buffer* ob; |
142
|
|
|
|
|
|
|
const char *src; |
143
|
|
|
|
|
|
|
STRLEN src_len; |
144
|
|
|
|
|
|
|
CODE: |
145
|
7
|
|
|
|
|
|
ob = hoedown_buffer_new(64); |
146
|
7
|
50
|
|
|
|
|
if (!ob) { |
147
|
0
|
|
|
|
|
|
croak("Cannot create new hoedown_buffer(malloc failed)"); |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
7
|
50
|
|
|
|
|
src = SvPV(src_sv, src_len); |
151
|
7
|
|
|
|
|
|
hoedown_document_render(self, ob, src, src_len); |
152
|
|
|
|
|
|
|
|
153
|
7
|
|
|
|
|
|
SV* ret = newSVpv(hoedown_buffer_cstr(ob), 0); |
154
|
7
|
100
|
|
|
|
|
if (SvUTF8(src_sv)) { |
155
|
2
|
|
|
|
|
|
SvUTF8_on(ret); |
156
|
|
|
|
|
|
|
} |
157
|
7
|
|
|
|
|
|
hoedown_buffer_free(ob); |
158
|
|
|
|
|
|
|
RETVAL = ret; |
159
|
|
|
|
|
|
|
OUTPUT: |
160
|
|
|
|
|
|
|
RETVAL |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
MODULE = Text::Markdown::Hoedown PACKAGE = Text::Markdown::Hoedown::Renderer::HTML |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
void |
165
|
|
|
|
|
|
|
new(const char* klass, unsigned int render_flags, int nesting_level) |
166
|
|
|
|
|
|
|
PPCODE: |
167
|
6
|
|
|
|
|
|
hoedown_renderer * renderer = hoedown_html_renderer_new( |
168
|
|
|
|
|
|
|
render_flags, nesting_level |
169
|
|
|
|
|
|
|
); |
170
|
6
|
|
|
|
|
|
ST(0) = sv_newmortal(); |
171
|
6
|
|
|
|
|
|
sv_setref_pv(ST(0), "Text::Markdown::Hoedown::Renderer::HTML", (void*)renderer); |
172
|
6
|
|
|
|
|
|
XSRETURN(1); |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
void |
175
|
|
|
|
|
|
|
DESTROY(SV* this) |
176
|
|
|
|
|
|
|
CODE: |
177
|
6
|
50
|
|
|
|
|
hoedown_renderer* self = INT2PTR(hoedown_renderer*, SvROK(this) ? SvIV(SvRV(this)) : SvIV(this)); |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
178
|
6
|
|
|
|
|
|
hoedown_html_renderer_free(self); |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
MODULE = Text::Markdown::Hoedown PACKAGE = Text::Markdown::Hoedown::Renderer::HTMLTOC |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
void |
183
|
|
|
|
|
|
|
new(const char* klass, int nesting_level) |
184
|
|
|
|
|
|
|
PPCODE: |
185
|
1
|
|
|
|
|
|
hoedown_renderer * renderer = hoedown_html_toc_renderer_new( |
186
|
|
|
|
|
|
|
nesting_level |
187
|
|
|
|
|
|
|
); |
188
|
1
|
|
|
|
|
|
ST(0) = sv_newmortal(); |
189
|
1
|
|
|
|
|
|
sv_setref_pv(ST(0), "Text::Markdown::Hoedown::Renderer::HTMLTOC", (void*)renderer); |
190
|
1
|
|
|
|
|
|
XSRETURN(1); |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
void |
193
|
|
|
|
|
|
|
DESTROY(SV* this) |
194
|
|
|
|
|
|
|
CODE: |
195
|
1
|
50
|
|
|
|
|
hoedown_renderer* self = INT2PTR(hoedown_renderer*, SvROK(this) ? SvIV(SvRV(this)) : SvIV(this)); |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
196
|
1
|
|
|
|
|
|
hoedown_html_renderer_free(self); |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
MODULE = Text::Markdown::Hoedown PACKAGE = Text::Markdown::Hoedown::Renderer::Callback |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
void |
201
|
|
|
|
|
|
|
new(const char* klass) |
202
|
|
|
|
|
|
|
PPCODE: |
203
|
|
|
|
|
|
|
hoedown_renderer * renderer; |
204
|
1
|
|
|
|
|
|
Newxz(renderer, 1, hoedown_renderer); |
205
|
1
|
|
|
|
|
|
renderer->opaque = newHV(); |
206
|
1
|
|
|
|
|
|
ST(0) = sv_newmortal(); |
207
|
1
|
|
|
|
|
|
sv_setref_pv(ST(0), "Text::Markdown::Hoedown::Renderer::Callback", (void*)renderer); |
208
|
1
|
|
|
|
|
|
XSRETURN(1); |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
void |
211
|
|
|
|
|
|
|
DESTROY(SV* this) |
212
|
|
|
|
|
|
|
CODE: |
213
|
1
|
50
|
|
|
|
|
hoedown_renderer* self = INT2PTR(hoedown_renderer*, SvROK(this) ? SvIV(SvRV(this)) : SvIV(this)); |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
214
|
1
|
|
|
|
|
|
SvREFCNT_dec(self->opaque); |
215
|
1
|
|
|
|
|
|
Safefree(self); |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
INCLUDE: gen.callback.inc |
218
|
|
|
|
|
|
|
|