44from ctypes import CDLL , c_char_p , c_long
55from subprocess import *
66import platform
7+ import os
78
89def pipe_through_prog (prog , text ):
910 p1 = Popen (prog .split (), stdout = PIPE , stdin = PIPE , stderr = PIPE )
@@ -13,7 +14,7 @@ def pipe_through_prog(prog, text):
1314def use_library (lib , text ):
1415 textbytes = text .encode ('utf-8' )
1516 textlen = len (textbytes )
16- return [0 , lib (textbytes , textlen ).decode ('utf-8' ), '' ]
17+ return [0 , lib (textbytes , textlen , 0 ).decode ('utf-8' ), '' ]
1718
1819class CMark :
1920 def __init__ (self , prog = None , library_dir = None ):
@@ -22,17 +23,16 @@ def __init__(self, prog=None, library_dir=None):
2223 self .to_html = lambda x : pipe_through_prog (prog , x )
2324 else :
2425 sysname = platform .system ()
25- libname = "libcmark"
2626 if sysname == 'Darwin' :
27- libname + = ".dylib"
27+ libname = "libcmark .dylib"
2828 elif sysname == 'Windows' :
2929 libname = "cmark.dll"
3030 else :
31- libname + = ".so"
31+ libname = "libcmark .so"
3232 if library_dir :
33- libpath = library_dir + "/" + libname
33+ libpath = os . path . join ( library_dir , libname )
3434 else :
35- libpath = "build/ src/" + libname
35+ libpath = os . path . join ( "build" , " src" , libname )
3636 cmark = CDLL (libpath )
3737 markdown = cmark .cmark_markdown_to_html
3838 markdown .restype = c_char_p
0 commit comments