'Wd1UddlmZddlmZmZmZmZmZddlm Z ddl m Z m Z m Z ddlmZmZddlmZmZddlmZdd lmZdd lmZdd lmZmZdd lmZdd lm Z ddlm!Z!m"Z"m#Z#m$Z$ ddl%Z%ejNjQejRjQejTjQejVjQejXjQdZ-de.d<GddZ/y#e&$rdZ%YwxYw)) annotations)Callable GeneratorIterableMappingMutableMapping)contextmanager)AnyLiteraloverload)helperspresets) normalize_urlutils) ParserBlock) ParserCore) ParserInline) RendererHTMLRendererProtocol) StateCore)Token)EnvType OptionsDict OptionsType PresetTypeN)defaultz js-defaultzero commonmarkzgfm-likezdict[str, PresetType]_PRESETScreZdZ ded ddZddZeddZeddZed dZed!dZed"d Zd"d Zd#d Z d$ d%d Z d&d Z d&dZ d' d(dZ d' d(dZ ed)dZ d* d+dZ d,dZd$d-dZd$d.dZd$d-dZd$d.dZd/dZd0dZd1dZy)2 MarkdownItN) renderer_clscNt|_t|_t|_t |_t |_|||_trtjnd|_ |rt|tstd|d|j||y)a6Main parser class :param config: name of configuration to load or a pre-defined dictionary :param options_update: dictionary that will be merged into ``config["options"]`` :param renderer_cls: the class to load as the renderer: ``self.renderer = renderer_cls(self) Nz$options_update should be a mapping: z4 (Perhaps you intended this to be the renderer_cls?))options_update)rrrinlinerblockrcorerenderer linkify_it LinkifyItlinkify isinstancer TypeError configure)selfconfigr%r#s 2/usr/lib/python3/dist-packages/markdown_it/main.py__init__zMarkdownIt.__init__!s  #n  ] L $T* 1;z++-  *^W"E6~6FGH  vn=cb|jjd|jjdS)N.z()) __class__ __module____name__)r0s r2__repr__zMarkdownIt.__repr__Cs+..++,Adnn.E.E-FbIIr4cyNr0names r2 __getitem__zMarkdownIt.__getitem__F r4cyr<r=r>s r2r@zMarkdownIt.__getitem__JrAr4cyr<r=r>s r2r@zMarkdownIt.__getitem__NrAr4cyr<r=r>s r2r@zMarkdownIt.__getitem__RrAr4cyr<r=r>s r2r@zMarkdownIt.__getitem__VrAr4cf|j|j|j|jd|S)Nr&r'r(r)rGr>s r2r@zMarkdownIt.__getitem__Zs2kkZZII    r4c$t||_y)aSet parser options (in the same format as in constructor). Probably, you will never need it, but you can change options after constructor call. __Note:__ To achieve the best possible performance, don't modify a `markdown-it` instance options on the fly. If you need multiple configurations it's best to create multiple instances and initialize each with separate config. N)roptions)r0rIs r2setzMarkdownIt.setbs#7+ r4ct|tr!|tvrtd|dt|}n|}|s t d|j dixsi}|ri||}|j |d|vr|djD]j\}}|j dd}|r||jj||j dd}|sM||jj|l|S) aBatch load of all options and component settings. This is an internal method, and you probably will not need it. But if you will - see available presets and data structure [here](https://github.com/markdown-it/markdown-it/tree/master/lib/presets) We strongly recommend to use presets instead of direct config loads. That will give better compatibility with next versions. zWrong `markdown-it` preset 'z ', check namez*Wrong `markdown-it` config, can't be emptyrI componentsrulesNrules2) r-strr KeyError ValueErrorgetrJitemsruler enableOnlyruler2) r0rr%r1rIr? componentrMrNs r2r/zMarkdownIt.configurels gs #h&!=gYmTUUg&FFIJ J**Y+1r 33N3G  6 !#),#7#=#=#? 9i! gt4J$$//6"x6J%%008  9 r4cdDcic] }|||jj"}}|jjj|d<|Scc}wz%Return the names of all active rules.r(r'r&inline2)rT get_all_rulesr&rVr0chainrMs r2r\zMarkdownIt.get_all_rulessb5  4;$$224 4   ;;--;;=i  %AcdDcic] }|||jj"}}|jjj|d<|Scc}wrY)rTget_active_rulesr&rVr]s r2razMarkdownIt.get_active_rulessb5  4;$$557 7   ;;-->>@i  r_cZg}t|tr|g}dD]0}|j||jj |d2|j|j j j |d|Dcgc] }||vs| }}|r|std||Scc}w)aEnable list or rules. (chainable) :param names: rule name or list of rule names to enable. :param ignoreInvalid: set `true` to ignore errors when rule not found. It will automatically find appropriate components, containing rules with given names. If rule not found, and `ignoreInvalid` not set - throws exception. Example:: md = MarkdownIt().enable(['sub', 'sup']).disable('smartquotes') rZTz.MarkdownIt. Failed to enable unknown rule(s): )r-rOextendrTenabler&rVrQr0names ignoreInvalidresultr^r?misseds r2rdzMarkdownIt.enables" eS !GE0 AE MM$u+++225$? @ A dkk((//t<=#(?4D,>$?? -MfXVW W @  B(B(cZg}t|tr|g}dD]0}|j||jj |d2|j|j j j |d|Dcgc] }||vs| }}|r|std||Scc}w)zThe same as [[MarkdownIt.enable]], but turn specified rules off. (chainable) :param names: rule name or list of rule names to disable. :param ignoreInvalid: set `true` to ignore errors when rule not found. rZTz/MarkdownIt. Failed to disable unknown rule(s): )r-rOrcrTdisabler&rVrQres r2rlzMarkdownIt.disables eS !GE0 BE MM$u+++33E4@ A B dkk((00=>#(?4D,>$?? -NvhWX X @rjc#K|j}d|jD])\}}|dk7s ||jj|+|jj j|dyw)zEA context manager, that will reset the current enabled rules on exit.Nr[)rarSrTrUr&rV)r0 chain_rulesr^rMs r2 reset_ruleszMarkdownIt.reset_rulesst++-  '--/ 4LE5 !U !!,,U3 4 %%k)&<=s 0A<A A<c|jj|k(r3|j|j|jj|<yy)ztAdd a rule for rendering a particular Token type. Only applied when ``renderer.__output__ == fmt`` N)r) __output____get__rM)r0r?functionfmts r2add_render_rulezMarkdownIt.add_render_rules> == # #s *(0(8(8(GDMM   % +r4c||g|i||S)aoLoad specified plugin with given params into current parser instance. (chainable) It's just a sugar to call `plugin(md, params)` with curring. Example:: def func(tokens, idx): tokens[idx].content = tokens[idx].content.replace('foo', 'bar') md = MarkdownIt().use(plugin, 'foo_replace', 'text', func) r=)r0pluginparamsrIs r2usezMarkdownIt.uses t(f(( r4c|in|}t|tstdt|t|tstdt|t |||}|j j||jS)a.Parse the source string to a token stream :param src: source string :param env: environment sandbox Parse input string and return list of block tokens (special token type "inline" will contain list of inline tokens). `env` is used to pass data between "distributed" rules and return additional metadata like reference info, needed for the renderer. It also can be used to inject data in specific cases. Usually, you will be ok to pass `{}`, and then pass updated object to renderer. z+Input data should be a MutableMapping, not #Input data should be a string, not ) r-rr.typerOrr(processtokensr0srcenvstates r2parsezMarkdownIt.parses{KbS#~.I$s)UV V#s#A$s)MN N#tS) % ||r4c||in|}|jj|j|||j|S)a}Render markdown string into html. It does all magic for you :). :param src: source string :param env: environment sandbox :returns: The output of the loaded renderer `env` can be used to inject additional metadata (`{}` by default). But you will not need it with high probability. See also comment in [[MarkdownIt.parse]]. )r)renderrrIr0rrs r2rzMarkdownIt.renders7KbS}}##DJJsC$8$,,LLr4c |in|}t|tstdt|t|tstdt|t |||}d|_|jj||jS)a=The same as [[MarkdownIt.parse]] but skip all block rules. :param src: source string :param env: environment sandbox It returns the block tokens list with the single `inline` element, containing parsed inline tokens in `children` property. Also updates `env` object. z,Input data should be an MutableMapping, not r{T) r-rr.r|rOr inlineModer(r}r~rs r2 parseInlinezMarkdownIt.parseInline%sKbS#~.J4PS9+VW W#s#A$s)MN N#tS) % ||r4c||in|}|jj|j|||j|S)aSimilar to [[MarkdownIt.render]] but for single paragraph content. :param src: source string :param env: environment sandbox Similar to [[MarkdownIt.render]] but for single paragraph content. Result will NOT be wrapped into `

` tags. )r)rrrIrs r2 renderInlinezMarkdownIt.renderInline9s9KbS}}##D$4$4S#$> cRRr4c,tj|S)a'Validate if the URL link is allowed in output. This validator can prohibit more than really needed to prevent XSS. It's a tradeoff to keep code simple and to be secure by default. Note: the url should be normalized at this point, and existing entities decoded. )r validateLinkr0urls r2rzMarkdownIt.validateLinkGs))#..r4c,tj|S)zNormalize destination URLs in links :: [label]: destination 'title' ^^^^^^^^^^^ )r normalizeLinkrs r2rzMarkdownIt.normalizeLinkQs**3//r4c,tj|S)zbNormalize autolink content :: ~~~~~~~~~~~ )rnormalizeLinkText)r0links r2rzMarkdownIt.normalizeLinkText[s..t44r4)rN)r1str | PresetTyper%Mapping[str, Any] | Noner#z(Callable[[MarkdownIt], RendererProtocol])returnrO)r?zLiteral['inline']rr)r?zLiteral['block']rr)r?zLiteral['core']rr)r?zLiteral['renderer']rr)r?rOrr )rIrrNoner<)rrr%rrr")rzdict[str, list[str]])F)rfzstr | Iterable[str]rgboolrr")rzGenerator[None, None, None])html)r?rOrszCallable[..., Any]rtrOrr)rwzCallable[..., None]rxr rIr rr")rrOrEnvType | Nonerz list[Token])rrOrrrr )rrOrr)rrOrrO)rrOrrO)r9r8 __qualname__rr3r:r r@rJr/r\rardrlr roruryrrrrrrrr=r4r2r"r" s$037 > BN >  >1 > ? >DJ          ,UY$'$9Q$ $LAF(9= BAF(9= .>>CIHH#5Hrs"RR%))(%#'4,@@ ##%$$))+ LL   $$))+  %%' # C5C5Js)C==DD