aboutsummaryrefslogtreecommitdiff
path: root/wrappers/wrapper.py
blob: 52cbfc75aa4cb37c6a29e1b88a0982f51757398b (plain)
  1. #!/usr/bin/env python
  2. # Example for using the shared library from python
  3. from ctypes import CDLL, c_char_p, c_long
  4. import sys
  5. import platform
  6. sysname = platform.system()
  7. if sysname == 'Darwin':
  8. cmark = CDLL("build/src/libcmark.dylib")
  9. else:
  10. cmark = CDLL("build/src/libcmark.so")
  11. markdown = cmark.cmark_markdown_to_html
  12. markdown.restype = c_char_p
  13. markdown.argtypes = [c_char_p, c_long]
  14. def md2html(text):
  15. return markdown(text, len(text))
  16. sys.stdout.write(md2html(sys.stdin.read()))