示例#1
0
 def __init__(self, article, request, *args, **kwargs):
     kwargs = settings.MARKDOWN_KWARGS
     kwargs['extensions'] = kwargs.get('extensions', [])
     kwargs['extensions'] += plugin_registry.get_markdown_extensions()
     markdown.Markdown.__init__(self, *args, **kwargs)
     self.article = article
     self.request = request
示例#2
0
    def locate_section(self, article, text):
        """Search for the header self.location (which is not deeper than settings.MAX_LEVEL)
        in text, compare the header text with self.header_id, and return the start position
        and the end position+1 of the complete section started by the header.
        """
        text = text.replace("\r\n", " \n").replace("\r", "\n") + "\n\n"
        text_len = len(text)

        headers = []
        pos = 0
        while pos < text_len:
            # Get meta information and start position of the next section
            header = FindHeader(text, pos)
            pos = header.pos
            if pos >= text_len:
                break
            if header.level > settings.MAX_LEVEL:
                continue
            headers.append(header)

        for e in get_markdown_extensions():
            if isinstance(e, EditSectionExtension):
                e.config["headers"] = headers
                e.config["location"] = self.location
                e.config["header_id"] = self.header_id
                article_markdown(text, article)
                return e.config["location"]
        return None
示例#3
0
 def render(self, preview_content=None):
     if not self.current_revision:
         return ""
     if preview_content:
         content = preview_content
     else:
         content = self.current_revision.content
     extensions = plugin_registry.get_markdown_extensions()
     extensions += settings.MARKDOWN_EXTENSIONS
     return mark_safe(article_markdown(content, self, extensions=extensions))
示例#4
0
 def render(self, preview_content=None):
     if not self.current_revision:
         return ""
     if preview_content:
         content = preview_content
     else:
         content = self.current_revision.content
     extensions = plugin_registry.get_markdown_extensions()
     extensions += settings.MARKDOWN_EXTENSIONS
     return mark_safe(article_markdown(content, self, extensions=extensions))
示例#5
0
 def get_markdown_extensions(self):
     kwargs = settings.MARKDOWN_KWARGS
     extensions = kwargs.get('extensions', [])
     
     extensions += self.core_extensions()
     extensions += plugin_registry.get_markdown_extensions()
     
     """ Where Base URL has been specified, use that"""
     if settings.WIKI_BASEURL != None:
         extensions += [WikiLinkExtension(base_url=settings.WIKI_BASEURL)]
         
     return extensions
示例#6
0
 def get_markdown_extensions(self):
     kwargs = settings.MARKDOWN_KWARGS
     extensions = kwargs.get('extensions', [])
     extensions += self.core_extensions()
     extensions += plugin_registry.get_markdown_extensions()
     # add our wikicodinglink plugin
     extensions += [wikicodinglinks.WikiLinkExtension()]
     # add our wikicodingindent plugin
     extensions += [wikicodingindent.WikiIndentExtension()]
     # add our reddit-hn-top template
     extensions += [template_reddit_hn.RedditHNtoptenExtension()]
     return extensions
示例#7
0
 def __init__(self, article, *args, **kwargs):
     kwargs = settings.MARKDOWN_KWARGS
     kwargs['extensions'] = kwargs.get('extensions', [])
     kwargs['extensions'] += plugin_registry.get_markdown_extensions()
     markdown.Markdown.__init__(self, *args, **kwargs)
     self.article = article
示例#8
0
 def get_markdown_extensions(self):
     kwargs = settings.MARKDOWN_KWARGS
     extensions = list(kwargs.get('extensions', []))
     extensions += self.core_extensions()
     extensions += plugin_registry.get_markdown_extensions()
     return extensions
示例#9
0
 def get_markdown_extensions(self):
     extensions = list(settings.MARKDOWN_KWARGS.get("extensions", []))
     extensions += self.core_extensions()
     extensions += plugin_registry.get_markdown_extensions()
     return extensions