diff src/plugins/plugin_misc_text_syntaxes.py @ 841:831f208b4ea3

plugin text_syntaxes: html2text was breaking the long URLs
author souliane <souliane@mailoo.org>
date Thu, 13 Feb 2014 12:29:14 +0100
parents 2cc0201b4613
children 4cc55e05266d
line wrap: on
line diff
--- a/src/plugins/plugin_misc_text_syntaxes.py	Thu Feb 13 10:42:29 2014 +0100
+++ b/src/plugins/plugin_misc_text_syntaxes.py	Thu Feb 13 12:29:14 2014 +0100
@@ -104,7 +104,12 @@
         self.addSyntax(self.SYNTAX_TEXT, lambda text: escape(text), lambda xhtml: self._removeMarkups(xhtml), [TextSyntaxes.OPT_HIDDEN])
         try:
             import markdown, html2text
-            self.addSyntax(self.SYNTAX_MARKDOWN, markdown.markdown, html2text.html2text, [TextSyntaxes.OPT_DEFAULT])
+
+            def _html2text(html, baseurl=''):
+                h = html2text.HTML2Text(baseurl=baseurl)
+                h.body_width = 0  # do not truncate the lines, it breaks the long URLs
+                return h.handle(html)
+            self.addSyntax(self.SYNTAX_MARKDOWN, markdown.markdown, _html2text, [TextSyntaxes.OPT_DEFAULT])
         except ImportError:
             warning("markdown or html2text not found, can't use Markdown syntax")
         host.bridge.addMethod("syntaxConvert", ".plugin", in_sign='sssbs', out_sign='s',