django-markdown-editor icon indicating copy to clipboard operation
django-markdown-editor copied to clipboard

How to embed HTML in Markdown

Open enjoy-software opened this issue 3 years ago • 0 comments

Is there a suggested way to embed HTML in Markdown

截圖 2022-05-10 下午4 23 25

Something like that, but only parse specific tag is better.

For example input:

<div>Hello World</div>
<html><div>Hello World<div></html>

output:

<div>Hello World</div>
Hello World

This is my way to embed HTML

settings.py

# Markdown extensions (default)
MARTOR_MARKDOWN_EXTENSIONS = [
    'markdown.extensions.extra',
    'markdown.extensions.nl2br',
    'markdown.extensions.smarty',
    'markdown.extensions.fenced_code',

    # Custom markdown extensions.
    'martor.extensions.urlize',
    'martor.extensions.del_ins',      # ~~strikethrough~~ and ++underscores++
    'martor.extensions.mention',      # to parse markdown mention
    'martor.extensions.emoji',        # to parse markdown emoji
    'martor.extensions.mdx_video',    # to parse embed/iframe video
    'martor.extensions.escape_html',  # to handle the XSS vulnerabilities
]
# apend md_in_html extension
MARTOR_MARKDOWN_EXTENSIONS.append('markdown.extensions.md_in_html')

enjoy-software avatar May 10 '22 09:05 enjoy-software