uhnomoli / hoep Goto Github PK
View Code? Open in Web Editor NEWA Python binding for the Hoedown Markdown library.
License: Other
A Python binding for the Hoedown Markdown library.
License: Other
hoedown is currently at version 3.0.1, the version included with hoep is version 2.0.0
The title pretty much says it all; this simple test case:
import hoep as h
from xml.sax.saxutils import escape
class MyHoep (h.Hoep):
def block_code(self, code, lang):
return '<pre>' + escape(code) + '</pre>'
p = MyHoep(h.EXT_FENCED_CODE, h.HTML_SMARTYPANTS)
p.render('''```
test
```''')
triggers a segmentation fault (as of commit 8def993). Same thing happens when using indented code blocks instead of fenced ones; either removing the block_code
method or specifying a language "fixes" the problem.
(I'm using CPython 3.4, if that's important.)
Hi, I get the following error installing on Windows. I poked around stackoverflow for possible explanatations and found these two links:
http://stackoverflow.com/questions/6985109/how-to-compile-c-code-from-cython-with-gcc
Compiling c is all a bit beyond my understanding, any ideas on how to solve this?
Thanks.
Console print out...
.................................
creating build\lib.win32-2.7
C:\MinGW\bin\gcc.exe -mno-cygwin -shared -s build\temp.win32-2.7\Release\ext\py2k\hoep.o build\temp.win32-2.7\Release\ext\py2k\wrapper.o build\temp.win32-2.7\Release\ext\hoedown\autolink.o build\temp.win32-2.7\Release\ext\hoedown\buffer.o build\temp.win32-2.7\Release\ext\hoedown\document.o build\temp.win32-2.7\Release\ext\hoedown\escape.o build\temp.win32-2.7\Release\ext\hoedown\html.o build\temp.win32-2.7\Release\ext\hoedown\html_blocks.o build\temp.win32-2.7\Release\ext\hoedown\html_smartypants.o build\temp.win32-2.7\Release\ext\hoedown\stack.o build\temp.win32-2.7\Release\ext\hoedown\version.o build\temp.win32-2.7\Release\ext\py2k\hoep.def -LC:\Python27\libs -LC:\Python27\PCbuild -lpython27 -lmsvcr90 -o build\lib.win32-2.7\hoep.pyd
build\temp.win32-2.7\Release\ext\py2k\hoep.o:hoep.c:(.text+0x420): undefined reference to `_imp__PyExc_TypeError'
build\temp.win32-2.7\Release\ext\py2k\wrapper.o:wrapper.c:(.text+0x9c): undefined reference to `_imp__PyExc_TypeError'
build\temp.win32-2.7\Release\ext\py2k\wrapper.o:wrapper.c:(.text+0x203): undefined reference to `_imp___Py_NoneStruct'
build\temp.win32-2.7\Release\ext\py2k\wrapper.o:wrapper.c:(.text+0x6f0): undefined reference to `_imp___Py_TrueStruct'
build\temp.win32-2.7\Release\ext\py2k\wrapper.o:wrapper.c:(.text+0x6f8): undefined reference to `_imp___Py_ZeroStruct'
build\temp.win32-2.7\Release\ext\py2k\wrapper.o:wrapper.c:(.text+0x93f): undefined reference to `_imp___Py_TrueStruct'
build\temp.win32-2.7\Release\ext\py2k\wrapper.o:wrapper.c:(.text+0x947): undefined reference to `_imp___Py_ZeroStruct'
build\temp.win32-2.7\Release\ext\py2k\wrapper.o:wrapper.c:(.text+0x9b2): undefined reference to `_imp___Py_TrueStruct'
build\temp.win32-2.7\Release\ext\py2k\wrapper.o:wrapper.c:(.text+0x9ba): undefined reference to `_imp___Py_ZeroStruct'
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
Cleaning up...
Removing temporary dir c:\users\andrew\appdata\local\temp\pip_build_Andrew...
Command C:\Python27\python2.7.exe -c "import setuptools;file='c:\users\andrew\appdata\local\temp\pip_build_Andrew\hoep\setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record c:\users\andrew\appdata\local\temp\pip-vahqak-record\install-record.txt --single-version-externally-managed failed with error code 1 in c:\users\andrew\appdata\local\temp\pip_build_Andrew\hoep
Exception information:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\pip\basecommand.py", line 134, in main
status = self.run(options, args)
File "C:\Python27\lib\site-packages\pip\commands\install.py", line 241, in run
requirement_set.install(install_options, global_options, root=options.root_path)
File "C:\Python27\lib\site-packages\pip\req.py", line 1298, in install
requirement.install(install_options, global_options, _args, *_kwargs)
File "C:\Python27\lib\site-packages\pip\req.py", line 625, in install
cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
File "C:\Python27\lib\site-packages\pip\util.py", line 670, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command C:\Python27\python2.7.exe -c "import setuptools;file='c:\users\andrew\appdata\local\temp\pip_build_Andrew\hoep\setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record c:\users\andrew\appdata\local\temp\pip-vahqak-record\install-record.txt --single-version-externally-managed failed with error code 1 in c:\users\andrew\appdata\local\temp\pip_build_Andrew\hoep
Greetings. First I want to thank you for this great package.
I've found one thing that has no easy workaround. Say I'm writing a custom renderer:
class MyRenderer(h.Hoep):
def header(self, text, level):
if text.count('foo'):
return ''
else:
return # I need this to fall back to the original behavior.
# (ie as if there's no header callback at all)
I've looked over the docs and seems there's no mentioning about this feature. I think one option is to let returning None
trigger original behavior should be quite reasonable.
Thanks in advance.
FYI. I've did a benchmark for all Markdown Parsers in Python. Hoep is included now.
Hi, I'm on Arch Linux with python 3.4.0, and pip install hoep
results in the following compilation errors:
Downloading/unpacking hoep
Running setup.py (path:/tmp/pip_build_nh/hoep/setup.py) egg_info for package hoep
warning: no previously-included files matching '*.pyc' found anywhere in distribution
Installing collected packages: hoep
Running setup.py install for hoep
building 'hoep' extension
gcc -pthread -Wno-unused-result -Werror=declaration-after-statement -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -fPIC -I/usr/include/python3.4m -c ext/py3k/hoep.c -o build/temp.linux-x86_64-3.4/ext/py3k/hoep.o
ext/py3k/hoep.c: In function ‘render’:
ext/py3k/hoep.c:35:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
hoedown_renderer *renderer = hoedown_html_renderer_new(render_flags, 0);
^
ext/py3k/hoep.c:48:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
Py_ssize_t sp_size;
^
ext/py3k/hoep.c: In function ‘Hoep_init’:
ext/py3k/hoep.c:79:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
hoedown_html_renderer_state *state = self->renderer->opaque;
^
ext/py3k/hoep.c:82:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
void **hd_callbacks = (void **) self->renderer;
^
ext/py3k/hoep.c: In function ‘Hoep_render’:
ext/py3k/hoep.c:115:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
Py_ssize_t md_size;
^
ext/py3k/hoep.c:129:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
Py_ssize_t sp_size;
^
ext/py3k/hoep.c:152:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
PyObject *message = PyUnicode_FromFormat("must return str, %s received", Py_TYPE(html)->tp_name);
^
cc1: some warnings being treated as errors
error: command 'gcc' failed with exit status 1
Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_nh/hoep/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-p0e8uzn1-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 'hoep' extension
creating build
creating build/temp.linux-x86_64-3.4
creating build/temp.linux-x86_64-3.4/ext
creating build/temp.linux-x86_64-3.4/ext/py3k
creating build/temp.linux-x86_64-3.4/ext/hoedown
gcc -pthread -Wno-unused-result -Werror=declaration-after-statement -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -fPIC -I/usr/include/python3.4m -c ext/py3k/hoep.c -o build/temp.linux-x86_64-3.4/ext/py3k/hoep.o
ext/py3k/hoep.c: In function ‘render’:
ext/py3k/hoep.c:35:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
hoedown_renderer *renderer = hoedown_html_renderer_new(render_flags, 0);
^
ext/py3k/hoep.c:48:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
Py_ssize_t sp_size;
^
ext/py3k/hoep.c: In function ‘Hoep_init’:
ext/py3k/hoep.c:79:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
hoedown_html_renderer_state *state = self->renderer->opaque;
^
ext/py3k/hoep.c:82:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
void **hd_callbacks = (void **) self->renderer;
^
ext/py3k/hoep.c: In function ‘Hoep_render’:
ext/py3k/hoep.c:115:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
Py_ssize_t md_size;
^
ext/py3k/hoep.c:129:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
Py_ssize_t sp_size;
^
ext/py3k/hoep.c:152:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
PyObject *message = PyUnicode_FromFormat("must return str, %s received", Py_TYPE(html)->tp_name);
^
cc1: some warnings being treated as errors
error: command 'gcc' failed with exit status 1
----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_nh/hoep/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-p0e8uzn1-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_nh/hoep
Storing debug log for failure in /home/nh/.pip/pip.log
GCC version:
: gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc/src/gcc-4.8-20140206/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-cloog-backend=isl --disable-cloog-version-check --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --disable-multilib --disable-werror --enable-checking=release
Thread model: posix
gcc version 4.8.2 20140206 (prerelease) (GCC)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.