예제 #1
0
파일: renderer.py 프로젝트: zrr1999/PyTex
 def block_code(self, code, info=None):
     html = '\\begin{python}\n'
     if info is not None:
         info = info.strip()
     if info:
         lang = info.split(None, 1)[0]
         lang = escape_html(lang)
     return html + escape(code) + '\\end{python}\n'
예제 #2
0
    def image(self, src, alt="", title=None):
        src = self._safe_url(src)
        html = f'<img class="pure-img" src="{src}" alt="{alt}" '

        if title:
            title = mistune.escape_html(title)
            html = f'{html} title="{title}" '

        return f"{html} />"
예제 #3
0
 def text(self, text):
     text = escape_html(text)
     text = USERNAME_RE.sub(r' <a href="/user/\1/">@\1</a>', text)
     return text
예제 #4
0
 def youtube(self, src, alt="", title=None):
     youtube_match = YOUTUBE_RE.match(src)
     youtube_id = escape_html(youtube_match.group(1) or "")
     return f'<a href="{escape_html(src)}"><span class="ratio-16-9 video-preview" ' \
            f'style="background-image: url(\'https://img.youtube.com/vi/{escape_html(youtube_id)}/0.jpg\');">' \
            f'</span></a><br>{escape_html(title or "")}'