我正在构建一个Rails应用程序,并且正在寻找一种方法将带有html和内联MathJax数学(TeX)的数据库条目转换为LaTeX以创建pdf。
我发现了和我类似的问题:
- 使用 pandoc 将 html mathjax 转换为 Markdown https://stackoverflow.com/questions/16014717/convert-html-mathjax-to-markdown-with-pandoc
- 如何使用 pandoc 将带有 mathjax 的 HTML 转换为 Latex? https://stackoverflow.com/questions/11338049/how-to-convert-html-with-mathjax-into-latex-using-pandoc
我在这里看到两个选项:
- 创建一个 Haskell 可执行文件,其中包含类似的内容
\(y=f(x)\)
将 html 转换为 LaTeX 时单独使用
- Write a ruby method which does the following things:
- 采取
string
并将其拆分为array
使用正则表达式(string.split(regex)
)
- 循环遍历创建的
array
如果内容匹配regex
将不包含内联数学的部分转换为 LaTeXPandocRuby.html(string).to_latex
- 将所有内容重新连接在一起(
array.join
)
我更喜欢 ruby 方法解决方案,因为我在 Heroku 上托管我的应用程序,并且我不喜欢将二进制文件签入 git。
注:pandoc
二进制是这样实现的http://www.petekeen.net/introduction-to-heroku-buildpacks http://www.petekeen.net/introduction-to-heroku-buildpacks)
所以我的问题是:应该做什么regex
看起来像分裂string
by \(math\)
.
E.g. string
可以看起来像这样: text \(y=f(x) \iff \log_{10}(b)\) and \(a+b=c\) text
并且为了完整起见,Haskell脚本应该如何写才能离开\(math\)
单独转换为 LaTeX 和 ruby 方法不是一个可能的解决方案吗?
获取最新版本的 pandoc (1.12.2)。然后你可以做
pandoc -f html+tex_math_dollars+tex_math_single_backslash -t latex
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)