Compare commits
No commits in common. "d2e6c88b311d13e55ce7b5a27933a6e32fa0eeb8" and "28248329064cc69c259e565b69ebc23af9e38998" have entirely different histories.
d2e6c88b31
...
2824832906
@ -1,44 +0,0 @@
|
|||||||
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/*
|
|
@ -5,9 +5,8 @@
|
|||||||
<excludeFolder url="file://$MODULE_DIR$/CrossDown.egg-info" />
|
<excludeFolder url="file://$MODULE_DIR$/CrossDown.egg-info" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/dist" />
|
<excludeFolder url="file://$MODULE_DIR$/dist" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Python 3.11 (CrossDown)" jdkType="Python SDK" />
|
<orderEntry type="jdk" jdkName="Python 3.11" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (CrossDown)" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11" project-jdk-type="Python SDK" />
|
||||||
</project>
|
</project>
|
@ -1,8 +1,3 @@
|
|||||||
"""
|
|
||||||
核心代码
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import xml
|
import xml
|
||||||
from typing import *
|
from typing import *
|
||||||
@ -35,11 +30,29 @@ from pymdownx.superfences import fence_div_format
|
|||||||
from pymdownx.tasklist import TasklistExtension
|
from pymdownx.tasklist import TasklistExtension
|
||||||
from pymdownx.tilde import DeleteSubExtension
|
from pymdownx.tilde import DeleteSubExtension
|
||||||
from pymdownx.magiclink import MagiclinkExtension
|
from pymdownx.magiclink import MagiclinkExtension
|
||||||
from pymdownx.pathconverter import PathConverterExtension
|
|
||||||
|
|
||||||
from .Define import Variable
|
from .Define import Variable
|
||||||
|
|
||||||
|
|
||||||
|
class PreProcess(Preprocessor):
|
||||||
|
"""预处理"""
|
||||||
|
|
||||||
|
def __init__(self, variable: Variable):
|
||||||
|
super().__init__()
|
||||||
|
self.variable = variable
|
||||||
|
|
||||||
|
def run(self, lines: List[str]) -> List[str]:
|
||||||
|
new_lines = []
|
||||||
|
for line in lines: # 逐行遍历
|
||||||
|
for value in re.findall(r'\{\[(.+?)]}', line): # 找到变量
|
||||||
|
if value in self.variable: # 变量已定义
|
||||||
|
line = re.sub(fr'\{{\[{value}]}}', self.variable[value], line) # 替换变量为值
|
||||||
|
else:
|
||||||
|
line = re.sub(fr'\{{\[{value}]}}', value, line) # 不替换变量
|
||||||
|
new_lines.append(line)
|
||||||
|
return new_lines
|
||||||
|
|
||||||
|
|
||||||
class Simple(InlineProcessor):
|
class Simple(InlineProcessor):
|
||||||
"""
|
"""
|
||||||
可通过简单的正则表达式和HTML标签实现的样式
|
可通过简单的正则表达式和HTML标签实现的样式
|
||||||
@ -199,6 +212,26 @@ class LinkLine(InlineProcessor):
|
|||||||
return tag, m.start(), m.end()
|
return tag, m.start(), m.end()
|
||||||
|
|
||||||
|
|
||||||
|
class Pre(Extension):
|
||||||
|
"""预处理"""
|
||||||
|
|
||||||
|
def __init__(self, variable: Variable):
|
||||||
|
"""
|
||||||
|
初始化
|
||||||
|
:param variable: 变量字典
|
||||||
|
"""
|
||||||
|
super().__init__()
|
||||||
|
self.variable = variable
|
||||||
|
|
||||||
|
def extendMarkdown(self, md: Markdown):
|
||||||
|
"""
|
||||||
|
添加扩展
|
||||||
|
:param md: 转换器
|
||||||
|
"""
|
||||||
|
md.registerExtension(self) # 注册扩展
|
||||||
|
md.preprocessors.register(PreProcess(self.variable), 'pre_process', 1000)
|
||||||
|
|
||||||
|
|
||||||
class BasicExtension(Extension):
|
class BasicExtension(Extension):
|
||||||
"""
|
"""
|
||||||
渲染基本样式
|
渲染基本样式
|
||||||
@ -269,7 +302,6 @@ Extensions = {
|
|||||||
'高级列表': FancyListExtension(),
|
'高级列表': FancyListExtension(),
|
||||||
'高级标题': SaneHeadersExtension(),
|
'高级标题': SaneHeadersExtension(),
|
||||||
'超级链接': MagiclinkExtension(),
|
'超级链接': MagiclinkExtension(),
|
||||||
'路径转换器': PathConverterExtension(),
|
|
||||||
|
|
||||||
# 自定义
|
# 自定义
|
||||||
'基本风格': BasicExtension(),
|
'基本风格': BasicExtension(),
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
from typing import *
|
from typing import *
|
||||||
import pickle
|
|
||||||
from .Core import main
|
from .Core import main
|
||||||
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'main', # 主函数
|
'main', # 主函数
|
||||||
'indent', # 添加空格
|
'indent', # 添加空格
|
||||||
'HEAD', # HTML头部引用
|
'HEAD', #
|
||||||
'Meta', # 元数据处理器
|
|
||||||
]
|
]
|
||||||
__version__ = '0.11.2'
|
__version__ = '0.11.2'
|
||||||
__author__ = 'CrossDark'
|
__author__ = 'CrossDark'
|
||||||
@ -14,17 +13,15 @@ __email__ = 'liuhanbo333@icloud.com'
|
|||||||
__source__ = 'https://crossdark.net/'
|
__source__ = 'https://crossdark.net/'
|
||||||
__license__ = """MIT"""
|
__license__ = """MIT"""
|
||||||
|
|
||||||
|
|
||||||
HEAD = {
|
HEAD = {
|
||||||
# mathjax
|
('latex', 'js'): '<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML"></script>',
|
||||||
('latex',
|
|
||||||
'js'): '<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML"></script>',
|
|
||||||
|
|
||||||
# mermaid
|
# mermaid
|
||||||
('mermaid', 'js'): '<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>',
|
('mermaid', 'js'): '<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>',
|
||||||
('mermaid', 'init'): '<script>mermaid.initialize({startOnLoad:true})</script>',
|
('mermaid', 'init'): '<script>mermaid.initialize({startOnLoad:true})</script>',
|
||||||
|
|
||||||
# 代码高亮css
|
('code-highlight', 'css'): '<link rel="stylesheet" href="../Static/styles.css">', # 代码高亮css
|
||||||
('code-highlight', 'css'): '<link rel="stylesheet" href="../Static/styles.css">',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -40,32 +37,3 @@ def indent(input_: Union[str, List, Tuple], indent_spaces: int = 4) -> str:
|
|||||||
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_)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
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()
|
|
||||||
|
11
README.html
11
README.html
@ -69,7 +69,6 @@
|
|||||||
<li><a href="#4.1.1">4.1.1 LaTex</a></li>
|
<li><a href="#4.1.1">4.1.1 LaTex</a></li>
|
||||||
<li><a href="#4.1.2">4.1.2 函数</a></li>
|
<li><a href="#4.1.2">4.1.2 函数</a></li>
|
||||||
<li><a href="#4.1.3">4.1.3 按键风格</a></li>
|
<li><a href="#4.1.3">4.1.3 按键风格</a></li>
|
||||||
<li><a href="#4.1.4">4.1.4 突出</a></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="#4.2">4.2 多行</a><ul>
|
<li><a href="#4.2">4.2 多行</a><ul>
|
||||||
@ -135,9 +134,8 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<h1 id="crossdown">CrossDown</h1>
|
<h1 id="crossdown">CrossDown</h1>
|
||||||
<p>自制的markdown,添加了一些自定义的语法</p>
|
<p>自制的markdown,添加了一些自定义的语法
|
||||||
<p>效果请见<README.html></p>
|
效果请见<README.html></p>
|
||||||
<p>安装:pip3 install --index-url <a href="https://crossdark.net/api/packages/CrossDark/pypi/simple/">https://crossdark.net/api/packages/CrossDark/pypi/simple/</a> CrossDown</p>
|
|
||||||
<h1 id="1">1 基本语法</h1>
|
<h1 id="1">1 基本语法</h1>
|
||||||
<h2 id="1.1">1.1 标题</h2>
|
<h2 id="1.1">1.1 标题</h2>
|
||||||
<h1 id="_1">一级标题</h1>
|
<h1 id="_1">一级标题</h1>
|
||||||
@ -189,7 +187,7 @@
|
|||||||
<h3 id="4.1.1">4.1.1 LaTex</h3>
|
<h3 id="4.1.1">4.1.1 LaTex</h3>
|
||||||
<p>这是<span class="arithmatex"><span class="MathJax_Preview">CO_2</span><script type="math/tex">CO_2</script></span>二氧化碳,或者可以写成这样CO<sub>2</sub></p>
|
<p>这是<span class="arithmatex"><span class="MathJax_Preview">CO_2</span><script type="math/tex">CO_2</script></span>二氧化碳,或者可以写成这样CO<sub>2</sub></p>
|
||||||
<p>这是<span class="arithmatex"><span class="MathJax_Preview">H_2O</span><script type="math/tex">H_2O</script></span>水,或者写成H<sub>2</sub>O
|
<p>这是<span class="arithmatex"><span class="MathJax_Preview">H_2O</span><script type="math/tex">H_2O</script></span>水,或者写成H<sub>2</sub>O
|
||||||
<sup>3</sup>H<sub>2</sub>O</p>
|
H<sup>3</sup><sub>2</sub>O</p>
|
||||||
<p><span class="arithmatex"><span class="MathJax_Preview">\lg\left(\frac{目标生物的理智值}{稳定折磨型工具人的理智值}\right)</span><script type="math/tex">\lg\left(\frac{目标生物的理智值}{稳定折磨型工具人的理智值}\right)</script></span></p>
|
<p><span class="arithmatex"><span class="MathJax_Preview">\lg\left(\frac{目标生物的理智值}{稳定折磨型工具人的理智值}\right)</span><script type="math/tex">\lg\left(\frac{目标生物的理智值}{稳定折磨型工具人的理智值}\right)</script></span></p>
|
||||||
<h3 id="4.1.2">4.1.2 函数</h3>
|
<h3 id="4.1.2">4.1.2 函数</h3>
|
||||||
<p><code>¥y=x*2+1¥</code> // 不定义范围</p>
|
<p><code>¥y=x*2+1¥</code> // 不定义范围</p>
|
||||||
@ -197,8 +195,6 @@
|
|||||||
<p><code>¥y=x**3¥€-50,50|-100,100€</code> // 定义了y范围</p>
|
<p><code>¥y=x**3¥€-50,50|-100,100€</code> // 定义了y范围</p>
|
||||||
<h3 id="4.1.3">4.1.3 按键风格</h3>
|
<h3 id="4.1.3">4.1.3 按键风格</h3>
|
||||||
<p><span class="keys"><kbd class="key-control">Ctrl</kbd><span>+</span><kbd class="key-alt">Alt</kbd><span>+</span><kbd class="key-delete">Del</kbd></span></p>
|
<p><span class="keys"><kbd class="key-control">Ctrl</kbd><span>+</span><kbd class="key-alt">Alt</kbd><span>+</span><kbd class="key-delete">Del</kbd></span></p>
|
||||||
<h3 id="4.1.4">4.1.4 突出</h3>
|
|
||||||
<p><code>{突出内容}</code></p>
|
|
||||||
<h2 id="4.2">4.2 多行</h2>
|
<h2 id="4.2">4.2 多行</h2>
|
||||||
<h3 id="4.2.1">4.2.1 YAML</h3>
|
<h3 id="4.2.1">4.2.1 YAML</h3>
|
||||||
<div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"> 2</span>
|
<div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal"> 2</span>
|
||||||
@ -276,7 +272,6 @@
|
|||||||
<div class="highlight"><pre><span></span><code>#! usr/bin/python3.11
|
<div class="highlight"><pre><span></span><code>#! usr/bin/python3.11
|
||||||
def main():
|
def main():
|
||||||
print('CrossDown')
|
print('CrossDown')
|
||||||
`#!py3 print('cd')`
|
|
||||||
</code></pre></div>
|
</code></pre></div>
|
||||||
<h1 id="5">5 转义</h1>
|
<h1 id="5">5 转义</h1>
|
||||||
<p>\ </p>
|
<p>\ </p>
|
||||||
|
10
README.md
10
README.md
@ -8,11 +8,8 @@ base_url: http://crossdark.net:3000/crossdark/CrossDown
|
|||||||
|
|
||||||
# CrossDown
|
# CrossDown
|
||||||
自制的markdown,添加了一些自定义的语法
|
自制的markdown,添加了一些自定义的语法
|
||||||
|
|
||||||
效果请见<README.html>
|
效果请见<README.html>
|
||||||
|
|
||||||
安装:pip3 install --index-url https://crossdark.net/api/packages/CrossDark/pypi/simple/ CrossDown
|
|
||||||
|
|
||||||
1 基本语法
|
1 基本语法
|
||||||
|
|
||||||
1.1 标题
|
1.1 标题
|
||||||
@ -111,7 +108,7 @@ The mock shebang will be treated like text here: ` #!js var test = 0; `.
|
|||||||
这是$CO_2$二氧化碳,或者可以写成这样CO~2~
|
这是$CO_2$二氧化碳,或者可以写成这样CO~2~
|
||||||
|
|
||||||
这是$H_2O$水,或者写成H~2~O
|
这是$H_2O$水,或者写成H~2~O
|
||||||
^3^H~2~O
|
H^3^~2~O
|
||||||
|
|
||||||
$\lg\left(\frac{目标生物的理智值}{稳定折磨型工具人的理智值}\right)$
|
$\lg\left(\frac{目标生物的理智值}{稳定折磨型工具人的理智值}\right)$
|
||||||
|
|
||||||
@ -127,10 +124,6 @@ $\lg\left(\frac{目标生物的理智值}{稳定折磨型工具人的理智值}\
|
|||||||
|
|
||||||
++ctrl+alt+delete++
|
++ctrl+alt+delete++
|
||||||
|
|
||||||
4.1.4 突出
|
|
||||||
|
|
||||||
`{突出内容}`
|
|
||||||
|
|
||||||
4.2 多行
|
4.2 多行
|
||||||
|
|
||||||
4.2.1 YAML
|
4.2.1 YAML
|
||||||
@ -206,7 +199,6 @@ $$
|
|||||||
#! usr/bin/python3.11
|
#! usr/bin/python3.11
|
||||||
def main():
|
def main():
|
||||||
print('CrossDown')
|
print('CrossDown')
|
||||||
`#!py3 print('cd')`
|
|
||||||
```
|
```
|
||||||
|
|
||||||
5 转义
|
5 转义
|
||||||
|
@ -2,7 +2,6 @@ Markdown>=3.7
|
|||||||
matplotlib~=3.8.2
|
matplotlib~=3.8.2
|
||||||
numpy~=1.26.2
|
numpy~=1.26.2
|
||||||
pygments>=2.18.0
|
pygments>=2.18.0
|
||||||
CrossDown>=2.2.0
|
CrossDown~=2.2.0
|
||||||
setuptools~=70.1.1
|
setuptools~=70.1.1
|
||||||
emoji~=2.13.2
|
emoji~=2.13.2
|
||||||
pymdown-extensions>=10.12
|
|
1
run.py
1
run.py
@ -2,6 +2,7 @@ import time
|
|||||||
|
|
||||||
from CrossDown import *
|
from CrossDown import *
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# 开始计时
|
# 开始计时
|
||||||
start_time = time.perf_counter_ns()
|
start_time = time.perf_counter_ns()
|
||||||
|
15
setup.py
15
setup.py
@ -1,20 +1,23 @@
|
|||||||
import setuptools
|
import setuptools
|
||||||
|
|
||||||
from CrossDown import Meta
|
with open("README.md", "r") as fh:
|
||||||
|
long_description = fh.read()
|
||||||
meta = Meta(3, 2, 6)
|
|
||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="CrossDown",
|
name="CrossDown",
|
||||||
version=meta.version,
|
version="2.2.0",
|
||||||
author="CrossDark",
|
author="CrossDark",
|
||||||
author_email="liuhanbo333@icloud.com",
|
author_email="liuhanbo333@icloud.com",
|
||||||
description="CrossDark's MarkDown",
|
description="CrossDark's MarkDown",
|
||||||
long_description=meta.long_description,
|
long_description=long_description,
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
url="https://github.com/CrossDark/CrossDown",
|
url="https://github.com/CrossDark/CrossDown",
|
||||||
packages=setuptools.find_packages(),
|
packages=setuptools.find_packages(),
|
||||||
install_requires=meta.requirements,
|
install_requires=[
|
||||||
|
'markdown',
|
||||||
|
'matplotlib',
|
||||||
|
'numpy',
|
||||||
|
],
|
||||||
package_data={
|
package_data={
|
||||||
'': ['Static/*'], # 这将包含static文件夹下的所有子文件夹和文件
|
'': ['Static/*'], # 这将包含static文件夹下的所有子文件夹和文件
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user