From d2e6c88b311d13e55ce7b5a27933a6e32fa0eeb8 Mon Sep 17 00:00:00 2001
From: crossdark
Date: Fri, 1 Nov 2024 19:18:29 +0800
Subject: [PATCH] 3.2.6 action
---
.gitea/workflows/pypi.yaml | 44 +++++++++++++++++++++++++++++++++++++
.idea/CrossDown.iml | 3 ++-
.idea/misc.xml | 2 +-
CrossDown/Core.py | 7 ++++++
CrossDown/__init__.py | 42 ++++++++++++++++++++++++++++++-----
README.html | 10 ++++++---
README.md | 9 +++++++-
data.pkl | Bin 0 -> 20 bytes
requirements.txt | 5 +++--
run.py | 1 -
setup.py | 15 +++++--------
11 files changed, 115 insertions(+), 23 deletions(-)
create mode 100644 .gitea/workflows/pypi.yaml
create mode 100644 data.pkl
diff --git a/.gitea/workflows/pypi.yaml b/.gitea/workflows/pypi.yaml
new file mode 100644
index 0000000..4689e0a
--- /dev/null
+++ b/.gitea/workflows/pypi.yaml
@@ -0,0 +1,44 @@
+on:
+ push:
+ branches:
+ - main
+
+jobs:
+ build-push:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+
+ - name: Set up Python 3.11
+ uses: actions/setup-python@v2
+ with:
+ python-version: '3.11'
+
+ - name: Install build dependencies
+ run: |
+ python -m pip install --upgrade pip
+ pip install setuptools wheel
+
+ - name: Build the package
+ run: |
+ python3.11 setup.py sdist bdist_wheel
+
+ - name: Upload artifacts
+ uses: actions/upload-artifact@v2
+ with:
+ name: python-dist
+ path: |
+ dist/*.tar.gz
+ dist/*.whl
+
+ - name: Set up twine
+ run: pip install twine
+
+ - name: Publish to PyPI
+ env:
+ TWINE_USERNAME: '__token__'
+ TWINE_PASSWORD: 'pypi-AgEIcHlwaS5vcmcCJDYxNjk2MzExLTg2NjMtNDUwNi1hMTQ0LTM2NDkxY2U1NjExYwACKlszLCIwNmJkMmFkZS1hYjkxLTQ0MWMtOWM1ZC02MmE0OTc3NTc5Y2EiXQAABiD_N8XZktPwthdp9dRpkpm7dIEh3eVbSr-X6H_OS8OzDw'
+ run: |
+ twine upload dist/*
diff --git a/.idea/CrossDown.iml b/.idea/CrossDown.iml
index 9460add..508e51a 100644
--- a/.idea/CrossDown.iml
+++ b/.idea/CrossDown.iml
@@ -5,8 +5,9 @@
+
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index a971a2c..3eed65b 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,4 @@
-
+
\ No newline at end of file
diff --git a/CrossDown/Core.py b/CrossDown/Core.py
index c35ad9f..675d2fd 100644
--- a/CrossDown/Core.py
+++ b/CrossDown/Core.py
@@ -1,3 +1,8 @@
+"""
+核心代码
+"""
+
+
import re
import xml
from typing import *
@@ -30,6 +35,7 @@ from pymdownx.superfences import fence_div_format
from pymdownx.tasklist import TasklistExtension
from pymdownx.tilde import DeleteSubExtension
from pymdownx.magiclink import MagiclinkExtension
+from pymdownx.pathconverter import PathConverterExtension
from .Define import Variable
@@ -263,6 +269,7 @@ Extensions = {
'高级列表': FancyListExtension(),
'高级标题': SaneHeadersExtension(),
'超级链接': MagiclinkExtension(),
+ '路径转换器': PathConverterExtension(),
# 自定义
'基本风格': BasicExtension(),
diff --git a/CrossDown/__init__.py b/CrossDown/__init__.py
index a88e1c3..c030b06 100644
--- a/CrossDown/__init__.py
+++ b/CrossDown/__init__.py
@@ -1,11 +1,12 @@
from typing import *
+import pickle
from .Core import main
-
__all__ = [
'main', # 主函数
'indent', # 添加空格
- 'HEAD', #
+ 'HEAD', # HTML头部引用
+ 'Meta', # 元数据处理器
]
__version__ = '0.11.2'
__author__ = 'CrossDark'
@@ -13,15 +14,17 @@ __email__ = 'liuhanbo333@icloud.com'
__source__ = 'https://crossdark.net/'
__license__ = """MIT"""
-
HEAD = {
- ('latex', 'js'): '',
+ # mathjax
+ ('latex',
+ 'js'): '',
# mermaid
('mermaid', 'js'): '',
('mermaid', 'init'): '',
- ('code-highlight', 'css'): '', # 代码高亮css
+ # 代码高亮css
+ ('code-highlight', 'css'): '',
}
@@ -37,3 +40,32 @@ def indent(input_: Union[str, List, Tuple], indent_spaces: int = 4) -> str:
return "\n".join(
f"{' ' * indent_spaces}{line}" for line in (lambda x: x.splitlines() if isinstance(x, str) else x)(input_)
)
+
+
+class Meta:
+ """
+ 这是用于处理本模块的元数据的类
+ """
+
+ def __init__(self, major: int, minor: int = 0, micro: int = 0, requirements='requirements.txt',
+ long_description='README.md'):
+ # 设置版本
+ try:
+ with open('data.pkl', 'rb') as file: # 读取上次版本
+ latest_version = pickle.load(file)
+ except FileNotFoundError:
+ pass
+ else:
+ if latest_version[0] >= major: # 判断主版本号
+ if latest_version[1] >= minor: # 判断副版本号
+ if latest_version[2] >= micro: # 判断小版本号
+ raise ValueError('版本不对')
+ self.version = f'{major}.{minor}.{micro}' # 生成版本字符串
+ with open('data.pkl', 'wb') as file: # 记录版本
+ pickle.dump((major, minor, micro), file)
+
+ with open(requirements, 'r') as f: # 设置依赖
+ self.requirements = [line.strip() for line in f.readlines()]
+
+ with open(long_description, "r") as fh:
+ self.long_description = fh.read()
diff --git a/README.html b/README.html
index 3ceabde..fa0643b 100644
--- a/README.html
+++ b/README.html
@@ -69,6 +69,7 @@
4.1.1 LaTex
4.1.2 函数
4.1.3 按键风格
+ 4.1.4 突出
4.2 多行
CrossDown
- 自制的markdown,添加了一些自定义的语法
- 效果请见
+ 自制的markdown,添加了一些自定义的语法
+ 效果请见
+ 安装:pip3 install --index-url https://crossdark.net/api/packages/CrossDark/pypi/simple/ CrossDown
1 基本语法
1.1 标题
一级标题
@@ -187,7 +189,7 @@
4.1.1 LaTex
这是CO_2二氧化碳,或者可以写成这样CO2
这是H_2O水,或者写成H2O
- H32O
+ 3H2O
\lg\left(\frac{目标生物的理智值}{稳定折磨型工具人的理智值}\right)
4.1.2 函数
¥y=x*2+1¥
// 不定义范围
@@ -195,6 +197,8 @@
¥y=x**3¥€-50,50|-100,100€
// 定义了y范围
4.1.3 按键风格
Ctrl+Alt+Del
+ 4.1.4 突出
+ {突出内容}
4.2 多行
4.2.1 YAML
2
diff --git a/README.md b/README.md
index f4029b5..a9c4fb5 100644
--- a/README.md
+++ b/README.md
@@ -8,8 +8,11 @@ base_url: http://crossdark.net:3000/crossdark/CrossDown
# CrossDown
自制的markdown,添加了一些自定义的语法
+
效果请见
+安装:pip3 install --index-url https://crossdark.net/api/packages/CrossDark/pypi/simple/ CrossDown
+
1 基本语法
1.1 标题
@@ -108,7 +111,7 @@ The mock shebang will be treated like text here: ` #!js var test = 0; `.
这是$CO_2$二氧化碳,或者可以写成这样CO~2~
这是$H_2O$水,或者写成H~2~O
-H^3^~2~O
+^3^H~2~O
$\lg\left(\frac{目标生物的理智值}{稳定折磨型工具人的理智值}\right)$
@@ -124,6 +127,10 @@ $\lg\left(\frac{目标生物的理智值}{稳定折磨型工具人的理智值}\
++ctrl+alt+delete++
+4.1.4 突出
+
+`{突出内容}`
+
4.2 多行
4.2.1 YAML
diff --git a/data.pkl b/data.pkl
new file mode 100644
index 0000000000000000000000000000000000000000..60561754b7d9e8dbd74c6604e57203b51a2be84d
GIT binary patch
literal 20
WcmZo*naark0p85sOx~>RQ}h5Hy#rSO
literal 0
HcmV?d00001
diff --git a/requirements.txt b/requirements.txt
index efbb0cd..cefee52 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2,6 +2,7 @@ Markdown>=3.7
matplotlib~=3.8.2
numpy~=1.26.2
pygments>=2.18.0
-CrossDown~=2.2.0
+CrossDown>=2.2.0
setuptools~=70.1.1
-emoji~=2.13.2
\ No newline at end of file
+emoji~=2.13.2
+pymdown-extensions>=10.12
\ No newline at end of file
diff --git a/run.py b/run.py
index fb05684..0e381e1 100644
--- a/run.py
+++ b/run.py
@@ -2,7 +2,6 @@ import time
from CrossDown import *
-
if __name__ == '__main__':
# 开始计时
start_time = time.perf_counter_ns()
diff --git a/setup.py b/setup.py
index 0fbdcb3..f4cdb7b 100644
--- a/setup.py
+++ b/setup.py
@@ -1,23 +1,20 @@
import setuptools
-with open("README.md", "r") as fh:
- long_description = fh.read()
+from CrossDown import Meta
+
+meta = Meta(3, 2, 6)
setuptools.setup(
name="CrossDown",
- version="3.2.4",
+ version=meta.version,
author="CrossDark",
author_email="liuhanbo333@icloud.com",
description="CrossDark's MarkDown",
- long_description=long_description,
+ long_description=meta.long_description,
long_description_content_type="text/markdown",
url="https://github.com/CrossDark/CrossDown",
packages=setuptools.find_packages(),
- install_requires=[
- 'markdown',
- 'matplotlib',
- 'numpy',
- ],
+ install_requires=meta.requirements,
package_data={
'': ['Static/*'], # 这将包含static文件夹下的所有子文件夹和文件
},
|