diff --git a/CrossDown/Core.py b/CrossDown/Core.py
index 483e2a5..61841ce 100644
--- a/CrossDown/Core.py
+++ b/CrossDown/Core.py
@@ -275,15 +275,20 @@ class CodeExtension(Extension):
md.treeprocessors.register(CodeLine(variable=self.variable), 'code_line', 100)
-def variable_formatter(source, language, css_class, md):
- if language != '':
- return InlineHilitePattern.highlight_code(src=source, language=language, classname=css_class, md=md)
+def inline_formatter(source, language, css_class, md): # 自定义的单行代码格式化器
+ if language != '': # 调用默认格式化函数
+ return md.inlinePatterns['backtick'].highlight_code(src=source, language=language, classname=css_class, md=md)
match tuple(source):
case '{', '#', *archers, '}': # 匹配到{#锚点}
- archer = str(archers.items())
+ archer = ''.join(archers)
return f'{archer}'
+ case '{', '-', *inline_links, '}': # 匹配到{-行内链接}
+ inline_link = ''.join(inline_links)
+ return f'{inline_link}'
+ case '{', *variable, '}': # 匹配到{变量}
+ return ''.join(variable)
case _:
- return f'{source}
' # Or string
+ return f'{source}
'
Extensions = {
@@ -319,7 +324,7 @@ Extensions = {
{
'name': '*',
'class': 'block',
- 'format': variable_formatter,
+ 'format': inline_formatter,
},
]
),
@@ -341,7 +346,7 @@ Extensions = {
# 自定义
'基本风格': BasicExtension(),
- '锚点': AnchorExtension(),
+ # '锚点': AnchorExtension(),
}
diff --git a/README.html b/README.html
index b0ffd39..0678995 100644
--- a/README.html
+++ b/README.html
@@ -187,12 +187,12 @@
直接在文本中使用 缩写 即可
`锚点`
+锚点
{-锚点}
单行
Here is some code: `#!py3 import pymdownx; pymdownx.version`.
+Here is some code: import pymdownx; pymdownx.__version__
.
The mock shebang will be treated like text here: #!js var test = 0;
.
这是CO_2二氧化碳,或者可以写成这样CO2
@@ -314,7 +314,7 @@7.1.3. 错误示范
不能出现两个及以上连续的点,例如:
7..1...4 错误示范
- +提纲号会被自动配置为锚点,可直接使用{-7}{-7.1}