line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "EXTERN.h" |
2
|
|
|
|
|
|
|
#include "perl.h" |
3
|
|
|
|
|
|
|
#include "XSUB.h" |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#include "ppport.h" |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
#include |
8
|
|
|
|
|
|
|
#include |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
MODULE = Text::Markdown::Discount PACKAGE = Text::Markdown::Discount PREFIX = TextMarkdown_ |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
PROTOTYPES: DISABLE |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
BOOT: |
15
|
5
|
|
|
|
|
|
HV* stash = gv_stashpvn("Text::Markdown::Discount", strlen("Text::Markdown::Discount"), TRUE); |
16
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_NOLINKS", newSViv(MKD_NOLINKS)); |
17
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_NOIMAGE", newSViv(MKD_NOIMAGE)); |
18
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_NOPANTS", newSViv(MKD_NOPANTS)); |
19
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_NOHTML", newSViv(MKD_NOHTML)); |
20
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_STRICT", newSViv(MKD_STRICT)); |
21
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_TAGTEXT", newSViv(MKD_TAGTEXT)); |
22
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_NO_EXT", newSViv(MKD_NO_EXT)); |
23
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_CDATA", newSViv(MKD_CDATA)); |
24
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_NOSUPERSCRIPT", newSViv(MKD_NOSUPERSCRIPT)); |
25
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_NORELAXED", newSViv(MKD_NORELAXED)); |
26
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_NOTABLES", newSViv(MKD_NOTABLES)); |
27
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_NOSTRIKETHROUGH", newSViv(MKD_NOSTRIKETHROUGH)); |
28
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_TOC", newSViv(MKD_TOC)); |
29
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_1_COMPAT", newSViv(MKD_1_COMPAT)); |
30
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_AUTOLINK", newSViv(MKD_AUTOLINK)); |
31
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_SAFELINK", newSViv(MKD_SAFELINK)); |
32
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_NOHEADER", newSViv(MKD_NOHEADER)); |
33
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_TABSTOP", newSViv(MKD_TABSTOP)); |
34
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_NODIVQUOTE", newSViv(MKD_NODIVQUOTE)); |
35
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_NOALPHALIST", newSViv(MKD_NOALPHALIST)); |
36
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_NODLIST", newSViv(MKD_NODLIST)); |
37
|
5
|
|
|
|
|
|
newCONSTSUB(stash, "MKD_EXTRA_FOOTNOTE", newSViv(MKD_EXTRA_FOOTNOTE)); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
SV * |
40
|
|
|
|
|
|
|
TextMarkdown__markdown(sv_str, flags) |
41
|
|
|
|
|
|
|
SV *sv_str |
42
|
|
|
|
|
|
|
int flags; |
43
|
|
|
|
|
|
|
PREINIT: |
44
|
13
|
|
|
|
|
|
bool is_utf8 = SvUTF8(sv_str) != 0; // SvUTF8 doesn't typecast consistently to bool across various archs |
45
|
13
|
50
|
|
|
|
|
char *text = SvPV_nolen(sv_str); |
46
|
13
|
|
|
|
|
|
SV* r = &PL_sv_undef; |
47
|
13
|
|
|
|
|
|
char *html = NULL; |
48
|
|
|
|
|
|
|
int szhtml; |
49
|
|
|
|
|
|
|
MMIOT *doc; |
50
|
|
|
|
|
|
|
CODE: |
51
|
13
|
50
|
|
|
|
|
if ( (doc = mkd_string(text, strlen(text), flags)) == 0 ) { |
52
|
0
|
|
|
|
|
|
croak("failed at mkd_string"); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
13
|
50
|
|
|
|
|
if ( !mkd_compile(doc, flags) ) { |
56
|
0
|
|
|
|
|
|
mkd_cleanup(doc); |
57
|
0
|
|
|
|
|
|
croak("failed at mkd_compile"); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
13
|
50
|
|
|
|
|
if ( (szhtml = mkd_document(doc, &html)) == EOF ) {; |
61
|
0
|
|
|
|
|
|
mkd_cleanup(doc); |
62
|
0
|
|
|
|
|
|
croak("failed at mkd_document"); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
13
|
|
|
|
|
|
r = newSVpvn(html, szhtml); |
66
|
13
|
|
|
|
|
|
sv_catpv(r, "\n"); |
67
|
13
|
100
|
|
|
|
|
if (is_utf8) { |
68
|
3
|
|
|
|
|
|
sv_utf8_decode(r); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
13
|
|
|
|
|
|
mkd_cleanup(doc); |
72
|
13
|
|
|
|
|
|
RETVAL = r; |
73
|
|
|
|
|
|
|
OUTPUT: |
74
|
|
|
|
|
|
|
RETVAL |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
void |
77
|
|
|
|
|
|
|
TextMarkdown_with_html5_tags() |
78
|
|
|
|
|
|
|
CODE: |
79
|
1
|
|
|
|
|
|
mkd_with_html5_tags(); |