def markdown(text, sanitize=True, linkify=True): html = _markdown(text) if sanitize: html = html.replace("<!-- markdown -->", "") html = sanitize_html(html, linkify=linkify) return html
def markdown(*args, **kwargs): """기존 마크다운 모듈을 깃허브 스타일로 바꿔주는 wrapper 입니다.""" try: extras = kwargs.pop("extras") except KeyError: extras = [] extras.extend([ "code-friendly", "fenced-code-blocks", "metadata", "nofollow", "spoiler", "tables", "target-blank-links", ]) return _markdown(*args, extras=extras, **kwargs)
def md_to_html(markdown_text): from markdown2 import markdown as _markdown, MarkdownError extras = { 'fenced-code-blocks': None, 'tables': None, 'header-ids': None, 'toc': None, 'highlightjs-lang': None, 'html-classes': { 'table': 'table table-bordered', 'img': 'screenshot' } } html = None try: html = UnicodeWithAttrs(_markdown(markdown_text or '', extras=extras)) except MarkdownError: pass return html
def markdown(text, **kwargs): return smart_text(_markdown(text, **kwargs).strip())
def markdown(value): return mark_safe(_markdown(value))