Python markdown to make grammar restrictions

Source: Internet
Author: User
Tags in python

Before I used the MARKDOWN2, not why, casually picked, the last two days I raised a question in Segmentfault: What is the difference between markdown and Markdown2 in Python? , it is said Misaka quickly, because is CPython, tried, not too much feeling, I want is simple, performance has not been considered in the interim.

By markdown the extension to del out of the specified syntax on the line, as follows:

The code is as follows Copy Code

Import Markdown

Class Mymarkdownextension (markdown. Extension):

def extendmarkdown (self, MD, md_globals):
Del md.parser.blockprocessors[' Hashheader ']

My_markdown_extension = Mymarkdownextension ()

Raw_text = ' #this H1 ~ ~ ~ ~

Print Markdown.markdown (Raw_text, [my_markdown_extension], Safe_mode = ' escape ')

Output <p> #this H1 ~~~</p>, this is the effect, of course, there are other can be deleted.

Here is the key that all Md.inlinepatterns contains:

  code is as follows copy code

' Backtick '
' Escape '
' reference '
' link '
' image_link '
' image_reference '
' short_reference '
' autolink '
' Automail '
' linebreak2 '
' linebreak '
' html '
' entity '
' Not_strong '
' strong_em '
' strong '
' Emphasis '
' emphasis2 '


If what you want is not on top, look at the md.parser.blockprocessors:

' indent '
' code '
' Hashheader '
' setextheader '
' hr '
' olist '
' ulist '
' quote '
' paragraph '

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.