I'm using python-markdown for Django template tag to render markdown text to HTML.
However, I really don't want the numbering for the headings in the rendered HTML.(ie. 1.1. , 2,13.1. )
One way I figured out is to remove heading numbers by re.sub()
like below
from django import template
from django.template.defaultfilters import stringfilter
import markdown as md
import re
register = template.Library()
@register.filter()
@stringfilter
def markdown(value):
text = md.markdown(value, extensions=['markdown.extensions.extra'])
text = re.sub('SOME-REGEX', '', text)
return text
and the part of current HTML rendered by md.markdown()
is like below.
<h2 id="section1">1. h2 Heading</h2>
<h3 id="section1.1">1.1. h3 Heading</h3>
<h4 id="section1.1.1">1.1.1. h4 Heading</h4>
What regex would remove those (1. ,1.1., 1.1.1. ...) things?
question from:https://stackoverflow.com/questions/65649269/how-to-remove-python-markdown-heading-numbering-with-regex