Text::Markdown::Discount
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

45 lines
1001 B

#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
#include <string.h>
#include <mkdio.h>
MODULE = Text::Markdown::Discount PACKAGE = Text::Markdown::Discount PREFIX = TextMarkdown_
PROTOTYPES: DISABLE
SV *
TextMarkdown__markdown(text)
char *text;
PREINIT:
SV* r = &PL_sv_undef;
int flags = MKD_NOHEADER|MKD_NOPANTS;
char *html = NULL;
int szhtml;
MMIOT *doc;
CODE:
if ( (doc = mkd_string(text, strlen(text), flags)) == 0 ) {
croak("failed at mkd_string");
}
if ( !mkd_compile(doc, flags) ) {
Safefree(doc);
croak("failed at mkd_compile");
}
if ( (szhtml = mkd_document(doc, &html)) == EOF ) {;
Safefree(doc);
croak("failed at mkd_document");
}
r = newSVpvn(html, szhtml);
sv_catpv(r, "\n");
Safefree(html);
Safefree(doc);
RETVAL = r;
OUTPUT:
RETVAL