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

15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
15 years ago
  1. #include "EXTERN.h"
  2. #include "perl.h"
  3. #include "XSUB.h"
  4. #include "ppport.h"
  5. #include <string.h>
  6. #include <mkdio.h>
  7. MODULE = Text::Markdown::Discount PACKAGE = Text::Markdown::Discount PREFIX = TextMarkdown_
  8. PROTOTYPES: DISABLE
  9. SV *
  10. TextMarkdown__markdown(text)
  11. char *text;
  12. PREINIT:
  13. SV* r = &PL_sv_undef;
  14. int flags = MKD_NOHEADER|MKD_NOPANTS;
  15. char *html = NULL;
  16. int szhtml;
  17. MMIOT *doc;
  18. CODE:
  19. if ( (doc = mkd_string(text, strlen(text), flags)) == 0 ) {
  20. croak("failed at mkd_string");
  21. }
  22. if ( !mkd_compile(doc, flags) ) {
  23. Safefree(doc);
  24. croak("failed at mkd_compile");
  25. }
  26. if ( (szhtml = mkd_document(doc, &html)) == EOF ) {;
  27. Safefree(doc);
  28. croak("failed at mkd_document");
  29. }
  30. r = newSVpvn(html, szhtml);
  31. sv_catpv(r, "\n");
  32. Safefree(html);
  33. Safefree(doc);
  34. RETVAL = r;
  35. OUTPUT:
  36. RETVAL