From 34f7d0d85e621027a4005e7087e0910558b35032 Mon Sep 17 00:00:00 2001 From: crossdark Date: Thu, 17 Oct 2024 18:56:06 +0800 Subject: [PATCH] =?UTF-8?q?1.9.8=20=E4=BF=AEbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CrossDown/Core.py | 8 +++++--- CrossDown/Define.py | 4 ++++ CrossDown/__init__.py | 10 ++-------- README.html | 6 ------ 4 files changed, 11 insertions(+), 17 deletions(-) create mode 100644 CrossDown/Define.py diff --git a/CrossDown/Core.py b/CrossDown/Core.py index 9fea80d..6636631 100644 --- a/CrossDown/Core.py +++ b/CrossDown/Core.py @@ -12,6 +12,8 @@ import lxml import xml import emoji +from .Define import Variable + try: # 检测当前平台是否支持扩展语法 from .Extra import * @@ -211,7 +213,7 @@ class CodeLine(Treeprocessor): 渲染单行代码 """ - def __init__(self, variable: Dict): + def __init__(self, variable: Variable): super().__init__() self.variable = variable @@ -326,7 +328,7 @@ class Anchor(Extension): class Code(Extension): - def __init__(self, variable: Dict): + def __init__(self, variable: Variable): super().__init__() self.variable = variable @@ -336,7 +338,7 @@ class Code(Extension): # md.treeprocessors.register(CodeBlock(), 'code_block', 1) # 渲染多行代码块 -def main(text: str, variable: Union[Dict[str, str], None] = None) -> Tuple[str, Dict[str, List[str]]]: +def main(text: str, variable: Variable = None) -> Tuple[str, Dict[str, List[str]]]: if variable is None: variable = {} md = Markdown(extensions=[Basic(), Box(), Anchor()] + list(Extensions.values()) + [Code(variable=variable)]) diff --git a/CrossDown/Define.py b/CrossDown/Define.py new file mode 100644 index 0000000..4ea0932 --- /dev/null +++ b/CrossDown/Define.py @@ -0,0 +1,4 @@ +from typing import * + + +Variable = Union[Dict[str, Union[str, Tuple[str], List[str]]], None] diff --git a/CrossDown/__init__.py b/CrossDown/__init__.py index 51f3d62..a88e1c3 100644 --- a/CrossDown/__init__.py +++ b/CrossDown/__init__.py @@ -22,13 +22,6 @@ HEAD = { ('mermaid', 'init'): '', ('code-highlight', 'css'): '', # 代码高亮css - - ('block', 'css'): """""" } @@ -42,4 +35,5 @@ def indent(input_: Union[str, List, Tuple], indent_spaces: int = 4) -> str: # 使用字符串的splitlines()方法分割原始字符串为行列表,如果是可迭代对象则直接遍历 # 遍历行列表,给每行前面加上相应的缩进,并重新组合成字符串 return "\n".join( - f"{' ' * indent_spaces}{line}" for line in (lambda x: x.splitlines() if isinstance(x, str) else x)(input_)) + f"{' ' * indent_spaces}{line}" for line in (lambda x: x.splitlines() if isinstance(x, str) else x)(input_) + ) diff --git a/README.html b/README.html index a977b09..857bf82 100644 --- a/README.html +++ b/README.html @@ -8,12 +8,6 @@ -