From bfe171fade915b299a277cdc982f6c33f2a74ba0 Mon Sep 17 00:00:00 2001 From: crossdark Date: Fri, 11 Oct 2024 17:54:30 +0800 Subject: [PATCH] =?UTF-8?q?1.7.3=20=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E9=83=A8=E5=88=86=E4=B9=B1=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CrossDown/Core.py | 25 +++++++++++++++---------- CrossDown/__init__.py | 7 +------ README.html | 19 +++++++++---------- README.md | 1 - 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/CrossDown/Core.py b/CrossDown/Core.py index 1a401b9..0051ede 100644 --- a/CrossDown/Core.py +++ b/CrossDown/Core.py @@ -12,22 +12,16 @@ import emoji Extensions = { "Extra": "markdown.extensions.extra", - "Abbreviations": "markdown.extensions.abbr", - "Attribute Lists": "markdown.extensions.attr_list", - "Definition Lists": "markdown.extensions.def_list", - "Fenced Code Blocks": "markdown.extensions.fenced_code", - "Footnotes": "markdown.extensions.footnotes", - "Tables": "markdown.extensions.tables", # "Smart Strong": "markdown.extensions.smart_strong", "Admonition": "markdown.extensions.admonition", # "CodeHilite": "markdown.extensions.codehilite", # "HeaderId": "markdown.extensions.headerid", "Meta-Data": "markdown.extensions.meta", - "New Line to Break": "markdown.extensions.nl2br", + # "New Line to Break": "markdown.extensions.nl2br", "Sane Lists": "markdown.extensions.sane_lists", - "SmartyPants": "markdown.extensions.smarty", + # "SmartyPants": "markdown.extensions.smarty", "Table of Contents": "markdown.extensions.toc", - "WikiLinks": "markdown.extensions.wikilinks", + # "WikiLinks": "markdown.extensions.wikilinks", } try: # 检测当前平台是否支持扩展语法 @@ -225,6 +219,16 @@ class CodeLine(Treeprocessor): code.text = code.text[1:-1] +class CodeBlock(Treeprocessor): + def run(self, root): + for elem in root: # 在所有段落中查找单行代码 + print(elem.tag) + print(elem.text) + print('----------------------------------------------------------------------------------------') + for code in elem.findall('code'): # 找到代码块 + pass + + class Basic(Extension): """ 渲染基本样式 @@ -280,7 +284,8 @@ class Anchor(Extension): class Code(Extension): def extendMarkdown(self, md: Markdown) -> None: md.registerExtension(self) # 注册扩展 - md.treeprocessors.register(CodeLine(), 'code_block', 0) # 渲染多行代码块 + md.treeprocessors.register(CodeLine(), 'code_line', 0) # 渲染单行代码块 + md.treeprocessors.register(CodeBlock(), 'code_block', 0) # 渲染多行代码块 def main(text: str) -> Tuple[str, Dict[str, List[str]]]: diff --git a/CrossDown/__init__.py b/CrossDown/__init__.py index 5f80377..6e2ee5a 100644 --- a/CrossDown/__init__.py +++ b/CrossDown/__init__.py @@ -31,12 +31,7 @@ HEAD = ( BODY = ( '', - '', ) diff --git a/README.html b/README.html index 5e80a9e..22133f9 100644 --- a/README.html +++ b/README.html @@ -19,12 +19,7 @@ -

CrossDown

-

自制的markdown,添加了一些自定义的语法klzzwxh:0001效果请见klzzwxh:0000

+

自制的markdown,添加了一些自定义的语法 + 效果请见README.html

1 基本语法

1.1 标题

一级标题

@@ -223,7 +219,7 @@ -

引文内添加klzzwxhklzzwxhklzzwxh:00470044klzzwxh:0045

+

引文内添加klzzwxhklzzwxhklzzwxh:00390036klzzwxh:0037

7 提纲

7.1 提纲号

@@ -233,11 +229,14 @@

.7.1.2 错误示范

7.1.3. 错误示范

不能出现两个及以上连续的点,例如:

-

7..1…4 错误示范

+

7..1...4 错误示范

提纲号会被自动配置为锚点,可直接使用776.1}

8 注释

8.1 强注释

-

|=klzzwxhklzzwxhklzzwxh:00340029klzzwxh:0032=|

+

|= + 无论如何都会被移除 + 放在代码块里也没用 + =|

8.2 弱注释

diff --git a/README.md b/README.md index a7094db..e643eb1 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ Title: CrossDown示例 Summary: 够简洁的了 Authors: CrossDark Date: __date__ -blank-value: g base_url: http://crossdark.net:3000/crossdark/CrossDown [TOC]