diff --git a/CrossDown/Core.py b/CrossDown/Core.py index a6ed85b..fa4ce36 100644 --- a/CrossDown/Core.py +++ b/CrossDown/Core.py @@ -1,5 +1,15 @@ from markdown.extensions import Extension, extra, admonition, meta, sane_lists, toc, wikilinks, codehilite, legacy_attrs + from pymdownx.arithmatex import ArithmatexExtension +from pymdownx.emoji import EmojiExtension +from pymdownx.blocks import BlocksExtension +from pymdownx.blocks.admonition import AdmonitionExtension +from pymdownx.blocks.definition import DefinitionExtension +from pymdownx.blocks.details import DetailsExtension +from pymdownx.blocks.html import HTMLExtension +from pymdownx.blocks.tab import TabExtension +from pymdownx.caret import CaretProcessor +from pymdownx.critic import CriticExtension from pygments.formatters import HtmlFormatter @@ -49,9 +59,9 @@ class HighlightHtmlFormatter(HtmlFormatter): Extensions = { # 自带 '基本扩展': extra.ExtraExtension(fenced_code={'lang_prefix': ''}), - '警告扩展': admonition.AdmonitionExtension(), + # '警告扩展': admonition.AdmonitionExtension(), '元数据': meta.MetaExtension(), - '能列表': sane_lists.SaneListExtension(), + # '能列表': sane_lists.SaneListExtension(), '目录': toc.TocExtension(), '内部链接': wikilinks.WikiLinkExtension(), # '代码高亮': codehilite.CodeHiliteExtension(guess_lang=False, pygments_formatter=HighlightHtmlFormatter), @@ -59,11 +69,20 @@ Extensions = { # pymdownx '超级数学': ArithmatexExtension(), + 'EMOJI': EmojiExtension(), + '块扩展': BlocksExtension(), + '警告': AdmonitionExtension(), + '定义列表': DefinitionExtension(), + '详情': DetailsExtension(), + 'HTML': HTMLExtension(), + '标签': TabExtension(), + '批评': CriticExtension(), } class PreProcess(Preprocessor): """预处理""" + def __init__(self, variable: Variable): super().__init__() self.variable = variable @@ -94,7 +113,8 @@ class Simple(InlineProcessor): super().__init__(pattern) self.tag = tag - def handleMatch(self, m: Match[str], data: str) -> Tuple[xml.etree.ElementTree.Element, int, int] | Tuple[None, None, None]: + def handleMatch(self, m: Match[str], data: str) -> Tuple[xml.etree.ElementTree.Element, int, int] | Tuple[ + None, None, None]: """ 处理匹配 :param m: re模块的匹配对象 @@ -123,7 +143,8 @@ class Nest(InlineProcessor): self.outer_tag = outer_tag self.inner_tag = inner_tag - def handleMatch(self, m: Match[str], data: str) -> Tuple[xml.etree.ElementTree.Element, int, int] | Tuple[None, None, None]: + def handleMatch(self, m: Match[str], data: str) -> Tuple[xml.etree.ElementTree.Element, int, int] | Tuple[ + None, None, None]: """ 处理匹配 :param m: re模块的匹配对象 @@ -156,7 +177,8 @@ class ID(InlineProcessor): self.property = property_ self.value = value - def handleMatch(self, m: Match[str], data: str) -> Tuple[xml.etree.ElementTree.Element, int, int] | Tuple[None, None, None]: + def handleMatch(self, m: Match[str], data: str) -> Tuple[xml.etree.ElementTree.Element, int, int] | Tuple[ + None, None, None]: """ 处理匹配 :param m: re模块的匹配对象 @@ -182,7 +204,8 @@ class Emoji(InlineProcessor): """ super().__init__(pattern) - def handleMatch(self, m: Match[str], data: str) -> Tuple[xml.etree.ElementTree.Element, int, int] | Tuple[None, None, None]: + def handleMatch(self, m: Match[str], data: str) -> Tuple[xml.etree.ElementTree.Element, int, int] | Tuple[ + None, None, None]: """ 处理匹配 :param m: re模块的匹配对象 @@ -272,7 +295,8 @@ class BoxBlock(BlockProcessor): class _Anchor(InlineProcessor): - def handleMatch(self, m: Match[str], data: str) -> Tuple[xml.etree.ElementTree.Element, int, int] | Tuple[None, None, None]: + def handleMatch(self, m: Match[str], data: str) -> Tuple[xml.etree.ElementTree.Element, int, int] | Tuple[ + None, None, None]: """ 处理匹配 :param m: re模块的匹配对象 @@ -357,6 +381,7 @@ class CodeBlock(Treeprocessor): """ 渲染单行代码 """ + def run(self, root: xml.etree.ElementTree.Element): for code in root: print(code.text) @@ -364,6 +389,7 @@ class CodeBlock(Treeprocessor): class Pre(Extension): """预处理""" + def __init__(self, variable: Variable): """ 初始化 @@ -401,7 +427,7 @@ class Basic(Extension): md.inlinePatterns.register(ID( r'\[(.*?)]-\((.*?)\)', tag='span', property_='title'), 'hide', 180 ) # [在指定的文本里面隐藏一段文本]-(只有鼠标放在上面才会显示隐藏文本) - md.inlinePatterns.register(Emoji(r':(.+?):'), 'emoji', 181) # 将emoji短代码转换为emoji字符 + # md.inlinePatterns.register(Emoji(r':(.+?):'), 'emoji', 181) # 将emoji短代码转换为emoji字符 md.parser.blockprocessors.register(Syllabus(md.parser), 'syllabus', 182) # 渲染提纲 @@ -475,8 +501,8 @@ class Code(Extension): :param md: 转换器 """ md.registerExtension(self) # 注册扩展 - md.treeprocessors.register(CodeLine(variable=self.variable), 'code_line', 0) # 渲染单行代码块 - md.treeprocessors.register(CodeBlock(), 'code_block', 1000) # 渲染多行代码块 + # md.treeprocessors.register(CodeLine(variable=self.variable), 'code_line', 0) # 渲染单行代码块 + # md.treeprocessors.register(CodeBlock(), 'code_block', 1000) # 渲染多行代码块 def main(text: str, variable: Variable = None) -> Tuple[str, Variable]: diff --git a/README.html b/README.html index cfb5dc7..0d26767 100644 --- a/README.html +++ b/README.html @@ -120,6 +120,15 @@
单行
这是\(CO_2\)二氧化碳
-这是\(H_2O\)水
-\(\lg\left(\frac{目标生物的理智值}{稳定折磨型工具人的理智值}\right)\)
+这是$CO_2$
二氧化碳
这是$H_2O$
水
$\lg\left(\frac{目标生物的理智值}{稳定折磨型工具人的理智值}\right)$
// 不定义范围
-// 定义了x范围
-// 定义了y范围
+¥y=x*2+1¥
// 不定义范围
¥y=x**2¥€-50,50€
// 定义了x范围
¥y=x**3¥€-50,50|-100,100€
// 定义了y范围
强调文本
-强调值
+{强调文本}
{强调变量}
A:
- 1. a
- 2. b
- 3. c
- B:
- - a
- - b
- - c
- 强调值:
- - a
- - b
-
A:
+ 1. a
+ 2. b
+ 3. c
+ B:
+ - a
+ - b
+ - c
+ 强调值:
+ - a
+ - b
+
#! usr/bin/python3.11
- def main():
- print('CrossDown')
-
#! usr/bin/python3.11
+ def main():
+ print('CrossDown')
+
graph TD
+ graph TD
A[开始]-->B[流程]
B-->C{判断}
C-->|结果1|D[结束1]
C-->|结果2|E[结束2]
-
cd ../..
+ cd ../..
ls
-
\documentclass{article}
- \title{我的第一个LaTeX文档}
- \author{作者姓名}
- \date{\today}
-
- \begin{document}
-
- \maketitle
-
- 这是我的第一个LaTeX文档。它包含了一个标题、作者信息、日期和一个简单的正文部分。
-
- \section{引言}
-
- 这是引言部分,可以简要介绍文档的主题和目的。
-
- \section{正文}
-
- 这是正文部分,可以详细阐述你的观点或研究内容。你可以根据需要添加更多的章节和子章节。
-
- \subsection{子章节示例}
-
- 这是一个子章节的示例,用于展示如何在LaTeX文档中创建层次结构。
-
- \end{document}
-
行内公式: p(x|y) = \frac{p(y|x)p(x)}{p(y)}
*斜体***粗体**~下划线~~~删除线~~==高亮==
-
*斜体***粗体**~下划线~~~删除线~~==高亮==
+
#! usr/bin/python3.11
+ #! usr/bin/python3.11
def main():
- print('CrossDown')
-
\
\a
@@ -328,7 +328,7 @@{强调变量}
警告标题
-警告内容
-!!! warning "警告标题" + 警告内容
🚴
-这是一个笑脸😃图案
++
这是一个笑脸 图案
这是一个1
@@ -417,5 +415,71 @@可以设置文段的字体为Helvetica
可以设置文段的自定义字体为小赖字体
可以设置文本的黄色外框
+Did you know?
+You can create a note with Blocks!
+Some content
+some markdown content
+Tab A content
+Tab B content
+Will be part of a separate, new tab group.
+Here is some incorrect Markdown. I am adding this here. Here is some more text
+ that I am removingtext. And here is even more text that I
+ am adding. Paragraph was deleted and replaced with some spaces.
Spaces were removed and a paragraph was added.
+And here is a comment on some
+ textThis works quite well. I just wanted to comment on it.. Substitutions isare great!
General block handling.
+