diff options
| author | eivanov89 <[email protected]> | 2025-08-29 10:12:02 +0300 |
|---|---|---|
| committer | eivanov89 <[email protected]> | 2025-08-29 10:27:27 +0300 |
| commit | 140ced4d34c422c9f3cbe096f8dd35243b67d6e4 (patch) | |
| tree | b7373341f64151c0ab9839ee692dc919366590d5 /contrib/python/markdown-it-py/markdown_it/parser_core.py | |
| parent | 136471c8b2f3ab8cd7993200c0de0456b7018118 (diff) | |
Add python/textual to YDB
commit_hash:eda16a869229724fec5479fa27fa5cdbccbe0395
Diffstat (limited to 'contrib/python/markdown-it-py/markdown_it/parser_core.py')
| -rw-r--r-- | contrib/python/markdown-it-py/markdown_it/parser_core.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/contrib/python/markdown-it-py/markdown_it/parser_core.py b/contrib/python/markdown-it-py/markdown_it/parser_core.py new file mode 100644 index 00000000000..8f5b921cbd3 --- /dev/null +++ b/contrib/python/markdown-it-py/markdown_it/parser_core.py @@ -0,0 +1,46 @@ +""" +* class Core +* +* Top-level rules executor. Glues block/inline parsers and does intermediate +* transformations. +""" + +from __future__ import annotations + +from collections.abc import Callable + +from .ruler import Ruler +from .rules_core import ( + block, + inline, + linkify, + normalize, + replace, + smartquotes, + text_join, +) +from .rules_core.state_core import StateCore + +RuleFuncCoreType = Callable[[StateCore], None] + +_rules: list[tuple[str, RuleFuncCoreType]] = [ + ("normalize", normalize), + ("block", block), + ("inline", inline), + ("linkify", linkify), + ("replacements", replace), + ("smartquotes", smartquotes), + ("text_join", text_join), +] + + +class ParserCore: + def __init__(self) -> None: + self.ruler = Ruler[RuleFuncCoreType]() + for name, rule in _rules: + self.ruler.push(name, rule) + + def process(self, state: StateCore) -> None: + """Executes core chain rules.""" + for rule in self.ruler.getRules(""): + rule(state) |
