1.9.8 修bug
This commit is contained in:
parent
d6107c6adf
commit
34f7d0d85e
@ -12,6 +12,8 @@ import lxml
|
|||||||
import xml
|
import xml
|
||||||
import emoji
|
import emoji
|
||||||
|
|
||||||
|
from .Define import Variable
|
||||||
|
|
||||||
try: # 检测当前平台是否支持扩展语法
|
try: # 检测当前平台是否支持扩展语法
|
||||||
from .Extra import *
|
from .Extra import *
|
||||||
|
|
||||||
@ -211,7 +213,7 @@ class CodeLine(Treeprocessor):
|
|||||||
渲染单行代码
|
渲染单行代码
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, variable: Dict):
|
def __init__(self, variable: Variable):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.variable = variable
|
self.variable = variable
|
||||||
|
|
||||||
@ -326,7 +328,7 @@ class Anchor(Extension):
|
|||||||
|
|
||||||
|
|
||||||
class Code(Extension):
|
class Code(Extension):
|
||||||
def __init__(self, variable: Dict):
|
def __init__(self, variable: Variable):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.variable = variable
|
self.variable = variable
|
||||||
|
|
||||||
@ -336,7 +338,7 @@ class Code(Extension):
|
|||||||
# md.treeprocessors.register(CodeBlock(), 'code_block', 1) # 渲染多行代码块
|
# 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:
|
if variable is None:
|
||||||
variable = {}
|
variable = {}
|
||||||
md = Markdown(extensions=[Basic(), Box(), Anchor()] + list(Extensions.values()) + [Code(variable=variable)])
|
md = Markdown(extensions=[Basic(), Box(), Anchor()] + list(Extensions.values()) + [Code(variable=variable)])
|
||||||
|
4
CrossDown/Define.py
Normal file
4
CrossDown/Define.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
from typing import *
|
||||||
|
|
||||||
|
|
||||||
|
Variable = Union[Dict[str, Union[str, Tuple[str], List[str]]], None]
|
@ -22,13 +22,6 @@ HEAD = {
|
|||||||
('mermaid', 'init'): '<script>mermaid.initialize({startOnLoad:true})</script>',
|
('mermaid', 'init'): '<script>mermaid.initialize({startOnLoad:true})</script>',
|
||||||
|
|
||||||
('code-highlight', 'css'): '<link rel="stylesheet" href="../Static/styles.css">', # 代码高亮css
|
('code-highlight', 'css'): '<link rel="stylesheet" href="../Static/styles.css">', # 代码高亮css
|
||||||
|
|
||||||
('block', 'css'): """<style>
|
|
||||||
.block {
|
|
||||||
background-color: grey; /* 灰色背景 */
|
|
||||||
color: white; /* 白色文字 */
|
|
||||||
}
|
|
||||||
</style>"""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -42,4 +35,5 @@ def indent(input_: Union[str, List, Tuple], indent_spaces: int = 4) -> str:
|
|||||||
# 使用字符串的splitlines()方法分割原始字符串为行列表,如果是可迭代对象则直接遍历
|
# 使用字符串的splitlines()方法分割原始字符串为行列表,如果是可迭代对象则直接遍历
|
||||||
# 遍历行列表,给每行前面加上相应的缩进,并重新组合成字符串
|
# 遍历行列表,给每行前面加上相应的缩进,并重新组合成字符串
|
||||||
return "\n".join(
|
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_)
|
||||||
|
)
|
||||||
|
@ -8,12 +8,6 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
|
||||||
<script>mermaid.initialize({startOnLoad:true})</script>
|
<script>mermaid.initialize({startOnLoad:true})</script>
|
||||||
<link rel="stylesheet" href="../Static/styles.css">
|
<link rel="stylesheet" href="../Static/styles.css">
|
||||||
<style>
|
|
||||||
.block {
|
|
||||||
background-color: grey; /* 灰色背景 */
|
|
||||||
color: white; /* 白色文字 */
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<!-- 可以在这里添加其他元数据和CSS链接 -->
|
<!-- 可以在这里添加其他元数据和CSS链接 -->
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
Loading…
Reference in New Issue
Block a user