aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-07-07 14:36:33 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2015-07-07 14:38:29 -0700
commit6aac96474d622a634989daa3afcae1e958082707 (patch)
tree1e2f81e9b4fc12c4778a7887a686e4f0b86fbc1c /test
parentcadb331c47d430f5bf09b81d9c806ac29a36dc03 (diff)
Ported `test/cmark.py` fixes from jgm/cmark.
Set options for conversion, set library paths in a more cross-platform way.
Diffstat (limited to 'test')
-rw-r--r--test/cmark.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/test/cmark.py b/test/cmark.py
index 253e3a8..1110860 100644
--- a/test/cmark.py
+++ b/test/cmark.py
@@ -4,6 +4,7 @@
from ctypes import CDLL, c_char_p, c_long
from subprocess import *
import platform
+import os
def pipe_through_prog(prog, text):
p1 = Popen(prog.split(), stdout=PIPE, stdin=PIPE, stderr=PIPE)
@@ -13,7 +14,7 @@ def pipe_through_prog(prog, text):
def use_library(lib, text):
textbytes = text.encode('utf-8')
textlen = len(textbytes)
- return [0, lib(textbytes, textlen).decode('utf-8'), '']
+ return [0, lib(textbytes, textlen, 0).decode('utf-8'), '']
class CMark:
def __init__(self, prog=None, library_dir=None):
@@ -22,17 +23,16 @@ class CMark:
self.to_html = lambda x: pipe_through_prog(prog, x)
else:
sysname = platform.system()
- libname = "libcmark"
if sysname == 'Darwin':
- libname += ".dylib"
+ libname = "libcmark.dylib"
elif sysname == 'Windows':
libname = "cmark.dll"
else:
- libname += ".so"
+ libname = "libcmark.so"
if library_dir:
- libpath = library_dir + "/" + libname
+ libpath = os.path.join(library_dir, libname)
else:
- libpath = "build/src/" + libname
+ libpath = os.path.join("build", "src", libname)
cmark = CDLL(libpath)
markdown = cmark.cmark_markdown_to_html
markdown.restype = c_char_p