def pipe_through_prog(prog, text): p1 = Popen(prog.split(), stdout=PIPE, stdin=PIPE, stderr=PIPE) [result, err] = p1.communicate(input=text.encode('utf-8')) return [p1.returncode, result, err] if prog: self.to_html = lambda x: pipe_through_prog(prog, x) else: sysname = platform.system() if sysname == 'Darwin': libname = "libcmark.dylib" elif sysname == 'Windows': libname = "cmark.dll" else: libname = "libcmark.so" if library_dir: libpath = os.path.join(library_dir, libname) else: libpath = os.path.join("build", "src", libname) def use_library(lib, text): textbytes = text.encode('utf-8') textlen = len(textbytes) return [0, lib(textbytes, textlen, 0), '']