Exemplo n.º 1
0
    def save(self, *args, **kwargs):
        self.formatted_content = markdown.markdown(self.origin_content,
                                                   extensions=[
                                                       'markdown.extensions.extra',
                                                       'markdown.extensions.abbr',
                                                       'markdown.extensions.attr_list',
                                                       'markdown.extensions.def_list',
                                                       'markdown.extensions.fenced_code',
                                                       'markdown.extensions.footnotes',
                                                       'markdown.extensions.tables',
                                                       'markdown.extensions.smart_strong',
                                                       'markdown.extensions.admonition',
                                                       'markdown.extensions.codehilite',
                                                       'markdown.extensions.headerid',
                                                       'markdown.extensions.meta',
                                                       'markdown.extensions.nl2br',
                                                       'markdown.extensions.sane_lists',
                                                       'markdown.extensions.smarty',
                                                       'markdown.extensions.toc',
                                                       'markdown.extensions.wikilinks',
                                                       RelativeImageExtension({
                                                           'base_urls': [
                                                               MEDIA_URL_PREFIX
                                                           ]
                                                       })
                                                   ], lazy_ol=False)

        super(BookDetail, self).save(*args, **kwargs)
Exemplo n.º 2
0
 def save(self, *args, **kwargs):
     self.formatted_content = markdown.markdown(
         self.origin_content,
         extensions=[
             'markdown.extensions.extra', 'markdown.extensions.codehilite',
             'markdown.extensions.toc',
             RelativeImageExtension({'base_urls': [MEDIA_URL_PREFIX]})
         ])
     super(MaterialCommentDetail, self).save(*args, **kwargs)
Exemplo n.º 3
0
 def save(self, *args, **kwargs):
     self.formatted_content = bleach.clean(
         markdown.markdown(
             self.origin_content,
             extensions=[
                 'markdown.extensions.extra',
                 'markdown.extensions.codehilite',
                 'markdown.extensions.toc',
                 RelativeImageExtension({'base_urls': [MEDIA_URL_PREFIX]})
             ]), ALLOWED_TAGS, ALLOWED_ATTRIBUTES, ALLOWED_STYLES,
         ALLOWED_PROTOCOLS, False, False)
     super(MaterialCommentDetail, self).save(*args, **kwargs)
Exemplo n.º 4
0
 def save(self, *args, **kwargs):
     self.formatted_content = bleach.clean(
         markdown.markdown(
             self.origin_content,
             extensions=[
                 'markdown.extensions.extra', 'markdown.extensions.abbr',
                 'markdown.extensions.attr_list',
                 'markdown.extensions.def_list',
                 'markdown.extensions.fenced_code',
                 'markdown.extensions.footnotes',
                 'markdown.extensions.tables',
                 'markdown.extensions.smart_strong',
                 'markdown.extensions.admonition',
                 'markdown.extensions.codehilite',
                 'markdown.extensions.headerid', 'markdown.extensions.meta',
                 'markdown.extensions.nl2br',
                 'markdown.extensions.sane_lists',
                 'markdown.extensions.smarty', 'markdown.extensions.toc',
                 'markdown.extensions.wikilinks',
                 RelativeImageExtension({'base_urls': [MEDIA_URL_PREFIX]})
             ],
             lazy_ol=False), ALLOWED_TAGS, ALLOWED_ATTRIBUTES,
         ALLOWED_STYLES, ALLOWED_PROTOCOLS, False, False)
     super(CommentDetail, self).save(*args, **kwargs)
Exemplo n.º 5
0
    'markdown.extensions.smarty', 'markdown.extensions.toc',
    'markdown.extensions.wikilinks'
]

# python markdown extension pymdownx
MARKDOWN_EXTENSIONS_PYMDOWNX = [
    'pymdownx.extra', 'pymdownx.superfences', 'pymdownx.magiclink',
    'pymdownx.tilde', 'pymdownx.emoji', 'pymdownx.tasklist',
    'pymdownx.superfences', 'pymdownx.details', 'pymdownx.highlight',
    'pymdownx.inlinehilite', 'pymdownx.keys', 'pymdownx.progressbar',
    'pymdownx.critic', 'pymdownx.arithmatex'
]

# python markdown extension custom
MARKDOWN_EXTENSIONS_CUSTOM = [
    RelativeImageExtension({'base_urls': [MEDIA_URL_PREFIX]}),
    SpanTableExtension()
]

MARKDOWN_EXTENSIONS = MARKDOWN_EXTENSIONS_DEFAULT + MARKDOWN_EXTENSIONS_PYMDOWNX + MARKDOWN_EXTENSIONS_CUSTOM

MARKDOWN_EXTENSION_CONFIGS = {
    'pymdownx.superfences': {
        'global_toolsbar':
        """
            {
                "shownum": {
                    "class": "shownum-class ivu-icon",
                    "id": "button-shownum",
                    "title": "显示或隐藏行号",
                    "text": "",