From 12e8343068b906f8b2afddc5569968a8a91fa5b0 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 29 Apr 2024 06:24:24 +0200 Subject: Adding upstream version 2.1.0. Signed-off-by: Daniel Baumann --- markdown_it/parser_core.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 markdown_it/parser_core.py (limited to 'markdown_it/parser_core.py') diff --git a/markdown_it/parser_core.py b/markdown_it/parser_core.py new file mode 100644 index 0000000..32209b3 --- /dev/null +++ b/markdown_it/parser_core.py @@ -0,0 +1,32 @@ +""" + * class Core + * + * Top-level rules executor. Glues block/inline parsers and does intermediate + * transformations. +""" +from __future__ import annotations + +from .ruler import RuleFunc, Ruler +from .rules_core import block, inline, linkify, normalize, replace, smartquotes +from .rules_core.state_core import StateCore + +_rules: list[tuple[str, RuleFunc]] = [ + ("normalize", normalize), + ("block", block), + ("inline", inline), + ("linkify", linkify), + ("replacements", replace), + ("smartquotes", smartquotes), +] + + +class ParserCore: + def __init__(self): + self.ruler = Ruler() + 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) -- cgit v1.2.3