0.8.6提纲号可算整好了

This commit is contained in:
跨越晨昏 2024-09-22 12:42:46 +08:00
parent 133ce5f8c9
commit 90b50d1440
3 changed files with 23 additions and 6 deletions

View File

@ -232,6 +232,8 @@ class CodeBlock:
self.codes[index] = f'<div class="{head}">{re.sub(f"({head})", "", code)}</div>' self.codes[index] = f'<div class="{head}">{re.sub(f"({head})", "", code)}</div>'
elif re.match(r'\$[^$]*\$', code): # 是LaTex代码(单行) elif re.match(r'\$[^$]*\$', code): # 是LaTex代码(单行)
self.codes[index] = re.sub(fr'\$([^$]*)\$', r'<p>\(\1\)</p>', code) self.codes[index] = re.sub(fr'\$([^$]*)\$', r'<p>\(\1\)</p>', code)
elif re.match(r'¥[^$]*¥', code): # 是数学函数(单行)
self.codes[index] = re.sub(fr'¥([^$]*)¥', r'<p>\(\1\)</p>', code)
else: # 是突出块 else: # 是突出块
self.codes[index] = f'<span class="block">{code}</span>' self.codes[index] = f'<span class="block">{code}</span>'
@ -326,7 +328,9 @@ class Syllabus:
re.sub(f'^({match.groups()[0]})', re.sub(f'^({match.groups()[0]})',
fr'{"#" * len(match.groups()[0].split("."))} \1{{#' + match.groups()[0] + '}', origen) fr'{"#" * len(match.groups()[0].split("."))} \1{{#' + match.groups()[0] + '}', origen)
if match is not None else origen) # 对于不是提纲的行,直接返回原始字符 if match is not None else origen) # 对于不是提纲的行,直接返回原始字符
(re.match(r'^([\d.]+) ', line), line) # 匹配提纲号 ((lambda x: re.match(r'^([\d.]+) ', x) # 判断是否是提纲
if not any((x.startswith('.'), re.search('\. ', x) is not None))
else None)(line), line) # 排除.在提纲号开头或结尾的情况
for line in self.text.splitlines() # 分割并遍历文本的每一行 for line in self.text.splitlines() # 分割并遍历文本的每一行
]) ])

View File

@ -117,6 +117,12 @@
<p>引文内添加<em>斜体</em><strong>粗体</strong><u>下划线</u><s>删除线</s><mark>高亮</mark></p> <p>引文内添加<em>斜体</em><strong>粗体</strong><u>下划线</u><s>删除线</s><mark>高亮</mark></p>
</blockquote> </blockquote>
<h1>6<span id="6"></span> 提纲</h1> <h1>6<span id="6"></span> 提纲</h1>
<h2>6.1<span id="6.1"></span> 提纲号</h2>
<p>以数字和点组成,通过空格与提纲名分隔,例如:</p>
<h3>6.1.1<span id="6.1.1"></span> 提纲号示例</h3>
<p>点不能出现在开头或结尾,例如
.6.1.2 错误示范
6.1.3. 错误示范</p>
<h1>7<span id="7"></span> 注释</h1> <h1>7<span id="7"></span> 注释</h1>
<h2>7.1<span id="7.1"></span> 强注释</h2> <h2>7.1<span id="7.1"></span> 强注释</h2>
<h2>7.2<span id="7.2"></span> 弱注释</h2> <h2>7.2<span id="7.2"></span> 弱注释</h2>
@ -124,10 +130,12 @@
<span class="block">// 代码中的注释弱不会被移除</span></p> <span class="block">// 代码中的注释弱不会被移除</span></p>
<h1>8<span id="8"></span> 列表</h1> <h1>8<span id="8"></span> 列表</h1>
<h2>8.1<span id="8.1"></span> 有序列表</h2> <h2>8.1<span id="8.1"></span> 有序列表</h2>
<h2>1.<span id="1."></span> a</h2> <ol>
<h2>2.<span id="2."></span> b</h2> <li>a</li>
<h2>3.<span id="3."></span> c</h2> <li>b</li>
<h2>4.<span id="4."></span> d</h2> <li>c</li>
<li>d</li>
</ol>
<h2>8.2<span id="8.2"></span> 无序列表</h2> <h2>8.2<span id="8.2"></span> 无序列表</h2>
<ul> <ul>
<li>A</li> <li>A</li>

View File

@ -84,7 +84,12 @@ graph LR
> 引文内添加*斜体***粗体**~下划线~~~删除线~~==高亮== > 引文内添加*斜体***粗体**~下划线~~~删除线~~==高亮==
6 提纲 6 提纲
6.1 提纲号
以数字和点组成,通过空格与提纲名分隔,例如:
6.1.1 提纲号示例
点不能出现在开头或结尾,例如
.6.1.2 错误示范
6.1.3. 错误示范
7 注释 7 注释
7.1 强注释 7.1 强注释
|= |=