Exemple #1
0
 def make_emoji(m):
     name = m.group(1)
     if name not in _emoji_list:
         return ':%s:' % name
     tpl = ('<img class="emoji" title="%(name)s" alt="%(name)s" height="20"'
            ' width="20" src="%(url)s%(name)s.png" align="top">')
     return tpl % {'name': name, 'url': options.emoji_url}
Exemple #2
0
 def make_emoji(m):
     name = m.group(1)
     if name not in _emoji_list:
         return ':%s:' % name
     tpl = ('<img class="emoji" title="%(name)s" alt="%(name)s" height="20"'
            ' width="20" src="%(url)s%(name)s.png" align="top">')
     return tpl % {'name': name, 'url': emoji_url}
Exemple #3
0
 def _parse_template(self, m):
     # templates in {{VALUES}} form
     if not m:
         return ""
     parts = m.group(1).split("|")
     try:
         return getattr(self, "_" + parts[0])(parts)
     except:
         return self._write_template_error(parts)
Exemple #4
0
def markdown(raw):
    raw = _unicode(raw)
    formatted_text = ignore_trailing_newlines(markdown_parser.render(raw))
    thumbs = get_thumbs(raw)
    return formatted_text, thumbs


###
# Simple MoinMoin-like formatter. Legacy.
###


bnwtypes = (
    ("emph", rec(ur'(?<!:)//'), lambda m: ()),
    ("strong", rec(ur'\*\*'), lambda m: ()),
    ("namedlink", rec(ur'''\[\[\s*(?P<link_target>.+?)\s*[|]\s*(?P<link_text>.+?)\s*]]'''), lambda m: (m.group('link_target'),m.group('link_text'))),
    ("source", rec(ur'''{{{(?:#!(\w+)\s+)?(.*?)}}}''', re.MULTILINE|re.DOTALL), lambda m: (m.group(1),m.group(2))),
)


formatting_tags = {
    'emph': ('<i>', '</i>'),
    'strong': ('<b>', '</b>'),
}


parser = LinkParser(types=bnwtypes + shittypes)


def moinmoin(text):
    text = _unicode(xhtml_escape(text))
Exemple #5
0
 def _highlightcode(m):
     '''Function for replace liquid style code highlight to github style
     '''
     return "```%s\n%s\n```" % (m.group(1), m.group(2))
Exemple #6
0
def parse(content):
    # return meta, content
    m = CALI_CONTENT_PATTERN.match(content)
    return m.group(1), content[len(m.group(0)):]