Mercurial > kallithea
diff rhodecode/lib/markup_renderer.py @ 1818:cf51bbfb120e beta
auto white-space removal
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 29 Dec 2011 07:35:51 +0200 |
parents | 025f3333c769 |
children | 89efedac4e6c |
line wrap: on
line diff
--- a/rhodecode/lib/markup_renderer.py Thu Dec 29 06:59:07 2011 +0200 +++ b/rhodecode/lib/markup_renderer.py Thu Dec 29 07:35:51 2011 +0200 @@ -3,9 +3,9 @@ rhodecode.lib.markup_renderer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - + Renderer for markup languages with ability to parse using rst or markdown - + :created_on: Oct 27, 2011 :author: marcink :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> @@ -33,18 +33,18 @@ class MarkupRenderer(object): RESTRUCTUREDTEXT_DISALLOWED_DIRECTIVES = ['include', 'meta', 'raw'] - + MARKDOWN_PAT = re.compile(r'md|mkdn?|mdown|markdown',re.IGNORECASE) RST_PAT = re.compile(r're?st',re.IGNORECASE) PLAIN_PAT = re.compile(r'readme',re.IGNORECASE) - + def __detect_renderer(self, source, filename=None): """ runs detection of what renderer should be used for generating html from a markup language - + filename can be also explicitly a renderer name - + :param source: :param filename: """ @@ -66,7 +66,7 @@ Renders a given filename using detected renderer it detects renderers based on file extension or mimetype. At last it will just do a simple html replacing new lines with <br/> - + :param file_name: :param source: """ @@ -130,10 +130,9 @@ @classmethod def rst_with_mentions(cls, source): mention_pat = re.compile(r'(?:^@|\s@)(\w+)') - + def wrapp(match_obj): uname = match_obj.groups()[0] return ' **@%(uname)s** ' % {'uname':uname} mention_hl = mention_pat.sub(wrapp, source).strip() return cls.rst(mention_hl) -