Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

格式化 Markdown 文件时将数学公式一并格式化 #3718

Open
renbaoshuo opened this issue Dec 24, 2021 · 3 comments
Open

格式化 Markdown 文件时将数学公式一并格式化 #3718

renbaoshuo opened this issue Dec 24, 2021 · 3 comments

Comments

@renbaoshuo
Copy link
Contributor

我遇到的问题是

现在 OI Wiki 的源文件中虽然 Markdown 格式是基本统一的,但内嵌的数学公式似乎并没有被格式化,这可能会对编辑时的公式阅读产生影响。

据我观察,有的页面中的数学公式源码非常“紧凑”,而有的则非常“松散”。

我希望能有这样的解决方案

将 Markdown 中内嵌的数学公式以一种基本统一的风格格式化。

我觉得这些备选方案也可以接受

No response

@CoelacanthusHex
Copy link
Member

CoelacanthusHex commented Jan 11, 2022

一个缩进 LaTeX 的工具 https://github.com/cmhughes/latexindent.pl
在线版本 https://c.albert-thompson.com/latex-pretty/
一个简单的尝试
图片

GitHub
Perl script to add indentation (leading horizontal space) to LaTeX files. It can modify line breaks before, during and after code blocks; it can perform text wrapping and paragraph line break remov...
Online Latex Formatter, beautify tidy, and format your latex code here.

@Enter-tainer
Copy link
Member

如果原本的数学公式完全挤在了一行,这个工具可以正常处理吗

@CoelacanthusHex
Copy link
Member

我来总结下群里的讨论:

  1. latexindent.pl 不太可行,因为它做不到插入空白
  2. 实现完整的 LaTaX 格式化器(或者说,解析器)过于困难,原因是完整的 LaTeX 是上下文有关文法
  3. 我们可以实现一个不支持新建命令(即产生新语法或改变语法)的 LeTaX 子集(这是容易达成的。首先,新建命令对于单纯的数学公式表达是不必要的;其次,OI Wiki 对内容具有较强的控制力),这个子集应当是上下文无关文法的,对这个子集实现格式化是有可能实现的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants