def get_markdown_instance(inline=False, js_support=False, ping_url=None): """ Provide a pre-configured markdown parser. :param bool inline: If `True`, configure parser to parse only inline content. :return: A ZMarkdown parser. """ if not settings.ZDS_APP['comment']['enable_pings']: ping_url = None zdsext = ZdsExtension(inline=inline, emoticons=smileys, js_support=js_support, ping_url=ping_url) # Generate parser markdown = Markdown( extensions=(zdsext, ), inline=inline, # Parse only inline content. ) return markdown
def get_markdown_instance(Inline=False): zdsext = ZdsExtension({"inline": Inline, "emoticons": {"TOTOTO":"truc"}, "js_support": True}) # Generate parser md = markdown.Markdown(extensions=(zdsext,), safe_mode = 'escape', # Protect use of html by escape it enable_attributes = False, # Disable the conversion of attributes. # This could potentially allow an # untrusted user to inject JavaScript # into documents. tab_length = 4, # Length of tabs in the source. # This is the default value output_format = 'html5', # html5 output # This is the default value smart_emphasis = True, # Enable smart emphasis for underscore syntax lazy_ol = True, # Enable smart ordered list start support ) return md
def get_markdown_instance(inline=False, js_support=False): """ Provide a pre-configured markdown parser. :param bool inline: If `True`, configure parser to parse only inline content. :return: A ZMarkdown parser. """ zdsext = ZdsExtension(inline=inline, emoticons=smileys, js_support=js_support) # Generate parser markdown = Markdown( extensions=(zdsext,), safe_mode='escape', # Protect use of html by escape it inline=inline, # Parse only inline content. enable_attributes=False, # Disable the conversion of attributes. # This could potentially allow an untrusted user to inject JavaScript into documents. tab_length=4, # Length of tabs in the source (default value). output_format='html5', # HTML5 output (default value). smart_emphasis=True, # Enable smart emphasis for underscore syntax lazy_ol=True, # Enable smart ordered list start support ) return markdown
from markdown import Markdown from markdown.extensions.zds import ZdsExtension from zested.smileys import smileys from PySide import QtCore ZDS_EXTENSION_CONFIG = {"inline": False, "emoticons": smileys} MARKDOWN_OPTIONS = { "extensions": [ZdsExtension(ZDS_EXTENSION_CONFIG)], "safe_mode": 'escape', "inline": False, "enable_attributes": False, "smart_emphasis": True, "lazy_ol": True, } class MarkdownRenderThread(QtCore.QThread): done = QtCore.Signal() def __init__(self, text, css): QtCore.QThread.__init__(self) self.text = text self.css = css def run(self): md = Markdown(**MARKDOWN_OPTIONS) self.html = '<style type="text/css">' self.html += self.css