Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
490 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...