forked from CrossDark/CrossDown
2.2 添加属性设置
This commit is contained in:
parent
2a07853466
commit
bf399ff836
@ -1,6 +1,6 @@
|
||||
from re import Match
|
||||
|
||||
from markdown.extensions import Extension, extra, admonition, meta, sane_lists, toc, wikilinks, codehilite
|
||||
from markdown.extensions import Extension, extra, admonition, meta, sane_lists, toc, wikilinks, codehilite, legacy_attrs
|
||||
|
||||
from pygments.formatters import HtmlFormatter
|
||||
|
||||
@ -14,7 +14,6 @@ from markdown.blockparser import BlockParser
|
||||
from markdown import Markdown
|
||||
from typing import *
|
||||
import re
|
||||
import lxml
|
||||
import xml
|
||||
import emoji
|
||||
|
||||
@ -56,6 +55,7 @@ Extensions = {
|
||||
'目录': toc.TocExtension(),
|
||||
'内部链接': wikilinks.WikiLinkExtension(),
|
||||
'代码高亮': codehilite.CodeHiliteExtension(guess_lang=False, pygments_formatter=HighlightHtmlFormatter),
|
||||
'属性设置': legacy_attrs.LegacyAttrExtension()
|
||||
}
|
||||
|
||||
|
||||
@ -319,7 +319,7 @@ class CodeLine(Treeprocessor):
|
||||
for code in root.findall('.//code'): # 在所有段落中查找单行代码
|
||||
if re.match(r'\$[^$]*\$', code.text): # 渲染Latex
|
||||
code.text = fr'\({code.text[1:-1]}\)'
|
||||
code.tag = 'p'
|
||||
code.tag = 'span'
|
||||
elif re.match(r'¥[^$]*¥', code.text): # 是数学函数(单行)
|
||||
if EXTRA_ABLE: # 支持扩展语法
|
||||
expression, range_ = re.findall(r'¥([^$]*)¥(€[^$]*€)?', code.text)[0] # 分离表达式与范围(如果有)
|
||||
@ -444,8 +444,8 @@ class Anchor(Extension):
|
||||
:param md: 转换器
|
||||
"""
|
||||
md.registerExtension(self) # 注册扩展
|
||||
md.inlinePatterns.register(_Anchor(r'\{#([^{}#]+)}'), 'anchor', 0) # 定义锚点
|
||||
md.inlinePatterns.register(LinkLine(r'\{([^{}#]+)}'), 'line_link', 0) # 添加页内链接
|
||||
md.inlinePatterns.register(_Anchor(r'\{{#([^{}#]+)}}'), 'anchor', 0) # 定义锚点
|
||||
md.inlinePatterns.register(LinkLine(r'\{{([^{}#]+)}}'), 'line_link', 0) # 添加页内链接
|
||||
|
||||
|
||||
class Code(Extension):
|
||||
|
16
README.html
16
README.html
File diff suppressed because one or more lines are too long
18
README.md
18
README.md
@ -81,11 +81,11 @@ ___
|
||||
|
||||
3.1 定义
|
||||
|
||||
{#锚点名}
|
||||
{{#锚点名}}
|
||||
|
||||
3.2 页内链接
|
||||
|
||||
{锚点名}
|
||||
{{锚点名}}
|
||||
|
||||
4 代码块
|
||||
|
||||
@ -131,6 +131,7 @@ B:
|
||||
4.2.2 Python
|
||||
|
||||
```python
|
||||
#! usr/bin/python3.11
|
||||
def main():
|
||||
print('CrossDown')
|
||||
```
|
||||
@ -149,6 +150,7 @@ graph TD
|
||||
|
||||
```shell
|
||||
cd ../..
|
||||
ls
|
||||
```
|
||||
|
||||
4.2.5 latex
|
||||
@ -223,7 +225,7 @@ cd ../..
|
||||
|
||||
7..1...4 错误示范
|
||||
|
||||
提纲号会被自动配置为锚点,可直接使用{7}{7.1}
|
||||
提纲号会被自动配置为锚点,可直接使用{{7}}{{7.1}}
|
||||
|
||||
8 注释
|
||||
|
||||
@ -361,3 +363,13 @@ Orange
|
||||
16 变量
|
||||
|
||||
{[强调变量]}
|
||||
|
||||
17 属性设置
|
||||
|
||||
可以设置文段的字体{@style=font-family: sans-serif;}为sans-serif
|
||||
|
||||
可以设置文段的字体{@style=font-family: Helvetica;}为Helvetica
|
||||
|
||||
可以设置文段的自定义字体{@style=font-family: SetoFont;}为小赖字体
|
||||
|
||||
可以设置文本的黄色外框{@style=display: inline-block; border: 1px solid yellow;}
|
Loading…
Reference in New Issue
Block a user