erwinmatijsen / django-markdownify

Markdown template filter for Django
MIT License
120 stars 24 forks source link

Headers (#) do not get interpreted as h1,h2,etc. #15

Closed yemarnevets closed 4 years ago

yemarnevets commented 4 years ago

I have some markdown I am rendering to HTML such as my header below (# My Header)

My Header

Problematically, this does not get interpreted as a header, so it is not emphasized, but there are also newline issues. That is, there is no line break after the header.

Can you please on advise on whether I should expect these headers to be rendered as HTML headers?

frennkie commented 4 years ago

I think you need to add h1-6 to your settings as whitelisted:

MARKDOWNIFY_WHITELIST_TAGS = [
    'a',
    'abbr',
    'acronym',
    'b',
    'blockquote',
    'em',
    'h1',
    'h2',
    'h3',
    'h4',
    'h5',
    'h6',
    'i',
    'li',
    'ol',
    'p',
    'strong',
    'ul'
]
erwinmatijsen commented 4 years ago

That's correct, you have to enable them in the settings. The default allowed tags can be found at https://bleach.readthedocs.io/en/latest/clean.html#allowed-tags-tags