andreikop / enki

A text editor for programmers
http://enki-editor.org
GNU General Public License v2.0
161 stars 38 forks source link

No fallback if loading of python-markdown failed #61

Closed vi closed 11 years ago

vi commented 11 years ago

Trying "bin/enki README.md" in recent(3d843eb8e4) master: crashes. Installing python-markdown using Debian package manager: also crashes.

/usr/local/lib/python2.6/dist-packages/Markdown-2.0.3-py2.6.egg/markdown/__init__.py:114: MarkdownWarning: Failed loading extension 'nl2br' from 'markdown.extensions.nl2br' or 'mdx_nl2br'
  warnings.warn(text, MarkdownWarning)
CRITICAL:root:Traceback (most recent call last):
  File "/mnt/sda8/src/git/enki/bin/../enki/plugins/preview/preview.py", line 102, in run
    html = self._getHtml(self._language, self._text)
  File "/mnt/sda8/src/git/enki/bin/../enki/plugins/preview/preview.py", line 41, in _getHtml
    return self._convertMarkdown(text)
  File "/mnt/sda8/src/git/enki/bin/../enki/plugins/preview/preview.py", line 75, in _convertMarkdown
    return markdown.markdown(text, ['fenced_code', 'nl2br', _StrikeThroughExtension(), 'mathjax'])
  File "/usr/local/lib/python2.6/dist-packages/Markdown-2.0.3-py2.6.egg/markdown/__init__.py", line 595, in markdown
    md = Markdown(extensions=load_extensions(extensions),
  File "/usr/local/lib/python2.6/dist-packages/Markdown-2.0.3-py2.6.egg/markdown/__init__.py", line 554, in load_extensions
    extension = load_extension(ext_name)
  File "/usr/local/lib/python2.6/dist-packages/Markdown-2.0.3-py2.6.egg/markdown/__init__.py", line 518, in load_extension
    pos = ext_name.find("(") # find the first "("
AttributeError: _StrikeThroughExtension instance has no attribute 'find'
QObject::setParent: Cannot set parent, new parent is in a different thread
QObject::setParent: Cannot set parent, new parent is in a different thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread

Segmentation fault

Expected result: Continue without markdown preview (as stated in the readme: * markdown. (Optional, for Markdown preview)), also continue without some Markdown extensions if they cannot be loaded.

vi commented 11 years ago

Make there should be a choice between old markdown engine and new one?

andreikop commented 11 years ago

Thank you for response!

There are no "new" engine, I continue using python-markdown.

It is problem with markdown API - I use feature, which appeared in 2.1.0, but you are using 2.0.3. I added check for installed version. Now strikethrough works on >= 2.1, and is silently ignored on older versions.

Install markdown from pip, and strikethought should work for you.

vi commented 11 years ago

Works. The preview is rendered even when strike-though is not available.