[文档]classOptionsDict(dict):"""A dictionary, with attribute access to core markdownit configuration options."""@propertydefmaxNesting(self)->int:"""Internal protection, recursion limit."""returnself["maxNesting"]@maxNesting.setterdefmaxNesting(self,value:int):self["maxNesting"]=value@propertydefhtml(self)->bool:"""Enable HTML tags in source."""returnself["html"]@html.setterdefhtml(self,value:bool):self["html"]=value@propertydeflinkify(self)->bool:"""Enable autoconversion of URL-like texts to links."""returnself["linkify"]@linkify.setterdeflinkify(self,value:bool):self["linkify"]=value@propertydeftypographer(self)->bool:"""Enable smartquotes and replacements."""returnself["typographer"]@typographer.setterdeftypographer(self,value:bool):self["typographer"]=value@propertydefquotes(self)->str:"""Quote characters."""returnself["quotes"]@quotes.setterdefquotes(self,value:str):self["quotes"]=value@propertydefxhtmlOut(self)->bool:"""Use '/' to close single tags (<br />)."""returnself["xhtmlOut"]@xhtmlOut.setterdefxhtmlOut(self,value:bool):self["xhtmlOut"]=value@propertydefbreaks(self)->bool:"""Convert newlines in paragraphs into <br>."""returnself["breaks"]@breaks.setterdefbreaks(self,value:bool):self["breaks"]=value@propertydeflangPrefix(self)->str:"""CSS language prefix for fenced blocks."""returnself["langPrefix"]@langPrefix.setterdeflangPrefix(self,value:str):self["langPrefix"]=value@propertydefhighlight(self)->Optional[Callable[[str,str,str],str]]:"""Highlighter function: (content, langName, langAttrs) -> escaped HTML."""returnself["highlight"]@highlight.setterdefhighlight(self,value:Optional[Callable[[str,str,str],str]]):self["highlight"]=value
ifTYPE_CHECKING:AttrDict=Anyelse:
[文档]classAttrDict(dict):def__init__(self,*args,**kwargs):super(AttrDict,self).__init__(*args,**kwargs)self.__dict__=self# recursively apply to all nested dictionariesforkey,iteminlist(self.items()):ifisinstance(item,dict):self[key]=AttrDict(item)
def_removesuffix(string:str,suffix:str)->str:"""Remove a suffix from a string. Replace this with str.removesuffix() from stdlib when minimum Python version is 3.9. """ifsuffixandstring.endswith(suffix):returnstring[:-len(suffix)]returnstring