diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-01-24 21:35:03 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-01-24 21:39:07 -0800 |
commit | 829b089c80895d9a78938c5bc7747aea1cd48eb6 (patch) | |
tree | 53bd534741a90c547c5d87039efa5ee625da8081 /test/cmark.py | |
parent | 5ef31853d5161d4b5a2dfc0df94e6eaaeb3215d0 (diff) |
Removed implementation-specific material from repository.
The C and JS implementations are being split off into
different repositories.
This repository will just have the spec itself.
Diffstat (limited to 'test/cmark.py')
-rw-r--r-- | test/cmark.py | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/test/cmark.py b/test/cmark.py deleted file mode 100644 index 253e3a8..0000000 --- a/test/cmark.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -from ctypes import CDLL, c_char_p, c_long -from subprocess import * -import platform - -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.decode('utf-8'), err] - -def use_library(lib, text): - textbytes = text.encode('utf-8') - textlen = len(textbytes) - return [0, lib(textbytes, textlen).decode('utf-8'), ''] - -class CMark: - def __init__(self, prog=None, library_dir=None): - self.prog = prog - if prog: - self.to_html = lambda x: pipe_through_prog(prog, x) - else: - sysname = platform.system() - libname = "libcmark" - if sysname == 'Darwin': - libname += ".dylib" - elif sysname == 'Windows': - libname = "cmark.dll" - else: - libname += ".so" - if library_dir: - libpath = library_dir + "/" + libname - else: - libpath = "build/src/" + libname - cmark = CDLL(libpath) - markdown = cmark.cmark_markdown_to_html - markdown.restype = c_char_p - markdown.argtypes = [c_char_p, c_long] - self.to_html = lambda x: use_library(markdown, x) |