feat: commit some ai prompt
This commit is contained in:
@@ -97,3 +97,34 @@ xthesis是一个结构化的XML格式,而LaTeX是一个线性文档,除少
|
|||||||
- XThesis格式的组建和写出可以从@src/xthesis.py 中获取
|
- XThesis格式的组建和写出可以从@src/xthesis.py 中获取
|
||||||
- 配置文件的读取和验证可以从@src/config/latex2xthesis.py 中获取
|
- 配置文件的读取和验证可以从@src/config/latex2xthesis.py 中获取
|
||||||
- 使用pylatexenc库进行latex格式解析(我已经帮你添加好了,不需要再添加了)
|
- 使用pylatexenc库进行latex格式解析(我已经帮你添加好了,不需要再添加了)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 执行流程
|
||||||
|
|
||||||
|
- 使用pylatexenc的节点遍历功能,遍历LaTeX文档。
|
||||||
|
- 在初始状态下,首先尝试匹配配置文件中preface,document,appendix,reference。一旦匹配成功,可视为进入当前内容的进一步分析。
|
||||||
|
|
||||||
|
对于preface和appendix,进入即意味着进入section节点的分析,section节点的标题和内容会被分析。
|
||||||
|
|
||||||
|
对于reference,进入即意味着进入section1节点的分析。
|
||||||
|
|
||||||
|
对于document,进入则意味着准备
|
||||||
|
|
||||||
|
# 注意事项
|
||||||
|
|
||||||
|
注意到执行流程具有嵌套性和局部性,一旦进入某一特定元素,就按照该元素内部可能出现的情况进行分析,而不再考虑其他元素。因此我建议,实现时采用状态机,配以状态机上下文
|
||||||
|
|
||||||
|
模式,栈顶部的元素为当前操作的元素。完成当前节点就弹出,发现新节点就压入。
|
||||||
|
|
||||||
|
例如当前栈顶为paragraph元素,我接受到了一个figure元素,则立即将顶部的paragraph元素弹出,然后处理当前figure元素。因为figure元素不能位于自然段中,要自动断开自然段。
|
||||||
|
|
||||||
|
对于command模式和environment模式,其内部节点可在分析过程中立即给出,guard模式和comment模式则必须要继续读取才能获取。你需要仔细评估这两种的区别,采用正确的方式来处理,我这里姑且有两种方式供你参考,我推荐第一种,如果第一种绝对不可行,再使用第二种:
|
||||||
|
|
||||||
|
1. command和environment模式立即处理,guard和comment模式压入栈中进行处理,好处是内存用量比较小,坏处是写起来比较复杂
|
||||||
|
1. 对于guard和comment模式,持续获取节点并暂存到一个list中,把他们转化到command和environment模式,然后一起处理。优点是非常简单,缺点是内存用量会比较大
|
||||||
|
|||||||
153
docs/latex2xthesis.example.toml
Normal file
153
docs/latex2xthesis.example.toml
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
[preface]
|
||||||
|
mode = "comment"
|
||||||
|
comment-head = "region: preface"
|
||||||
|
comment-tail = "endregion"
|
||||||
|
|
||||||
|
[[preface.section]]
|
||||||
|
mode = "environment"
|
||||||
|
environment-keyword = "abstract"
|
||||||
|
|
||||||
|
caption = "args[0]"
|
||||||
|
body = "body"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[document]
|
||||||
|
mode = "comment"
|
||||||
|
comment-head = "region: document"
|
||||||
|
comment-tail = "endregion"
|
||||||
|
|
||||||
|
[document.section1]
|
||||||
|
mode = "guard"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[appendix]
|
||||||
|
mode = "comment"
|
||||||
|
comment-head = "region: appendix"
|
||||||
|
comment-tail = "endregion"
|
||||||
|
|
||||||
|
[[preface.section]]
|
||||||
|
mode = "guard"
|
||||||
|
guard-head = "section"
|
||||||
|
guard-tail = "abstract"
|
||||||
|
|
||||||
|
caption = "args[0]"
|
||||||
|
body = "body"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[reference]
|
||||||
|
mode = "command"
|
||||||
|
command-keyword = "bibliography"
|
||||||
|
|
||||||
|
body = "args[0]"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[b]
|
||||||
|
mode = "command"
|
||||||
|
command-keyword = "textbf"
|
||||||
|
|
||||||
|
body = "args[0]"
|
||||||
|
|
||||||
|
[i]
|
||||||
|
mode = "command"
|
||||||
|
command-keyword = "textit"
|
||||||
|
|
||||||
|
body = "args[0]"
|
||||||
|
|
||||||
|
[ref]
|
||||||
|
mode = "command"
|
||||||
|
command-keyword = "ref"
|
||||||
|
|
||||||
|
body = "args[0]"
|
||||||
|
|
||||||
|
[cref]
|
||||||
|
mode = "command"
|
||||||
|
command-keyword = "cref"
|
||||||
|
|
||||||
|
body = "args[0]"
|
||||||
|
|
||||||
|
[cite]
|
||||||
|
mode = "command"
|
||||||
|
command-keyword = "cite"
|
||||||
|
|
||||||
|
body = "args[0]"
|
||||||
|
|
||||||
|
[equation]
|
||||||
|
mode = "environment"
|
||||||
|
environment-keyword = "equation"
|
||||||
|
|
||||||
|
body = "body"
|
||||||
|
|
||||||
|
[equation.caption]
|
||||||
|
mode = "command"
|
||||||
|
command-keyword = "caption"
|
||||||
|
|
||||||
|
body = "args[0]"
|
||||||
|
|
||||||
|
[equation.label]
|
||||||
|
mode = "command"
|
||||||
|
command-keyword = "label"
|
||||||
|
|
||||||
|
body = "args[0]"
|
||||||
|
|
||||||
|
[figure]
|
||||||
|
mode = "environment"
|
||||||
|
environment-keyword = "figure"
|
||||||
|
|
||||||
|
body = "body"
|
||||||
|
|
||||||
|
[figure.caption]
|
||||||
|
mode = "command"
|
||||||
|
command-keyword = "caption"
|
||||||
|
|
||||||
|
body = "args[0]"
|
||||||
|
|
||||||
|
[figure.label]
|
||||||
|
mode = "command"
|
||||||
|
command-keyword = "label"
|
||||||
|
|
||||||
|
body = "args[0]"
|
||||||
|
|
||||||
|
[table]
|
||||||
|
mode = "environment"
|
||||||
|
environment-keyword = "table"
|
||||||
|
|
||||||
|
body = "body"
|
||||||
|
|
||||||
|
[table.caption]
|
||||||
|
mode = "command"
|
||||||
|
command-keyword = "caption"
|
||||||
|
|
||||||
|
body = "args[0]"
|
||||||
|
|
||||||
|
[table.label]
|
||||||
|
mode = "command"
|
||||||
|
command-keyword = "label"
|
||||||
|
|
||||||
|
body = "args[0]"
|
||||||
|
|
||||||
|
[pagebreaker]
|
||||||
|
mode = "command"
|
||||||
|
command-keyword = "clearpage"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user