Skip to content

Commit 6aac964

Browse files
committed
Ported test/cmark.py fixes from jgm/cmark.
Set options for conversion, set library paths in a more cross-platform way.
1 parent cadb331 commit 6aac964

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

test/cmark.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from ctypes import CDLL, c_char_p, c_long
55
from subprocess import *
66
import platform
7+
import os
78

89
def 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):
1314
def 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

1819
class 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

Comments
 (0)