简体   繁体   English

在Java或C ++中将latex转换为html?

[英]Convert latex to html in Java or C++?

There are many tools for converting latex into html . 很多工具可以将乳胶转换成html I'm looking for a Java or C++ program to do this. 我正在寻找一个Java或C ++程序来做到这一点。 It will need to run on multiple operating systems. 它需要在多个操作系统上运行。 The solution will be used on academic papers, so it should ideally also be able to interpret things like bibtex. 该解决方案将用于学术论文,因此理想情况下也应该能够解释像bibtex这样的东西。

I found htmltolatex which is a "Java program for converting HTML pages into LaTeX", but it doesn't seem to operate in the other direction. 我发现htmltolatex是一个“将HTML页面转换成LaTeX的Java程序”,但它似乎并没有在另一个方向上运行。

Related questions: 相关问题:

Update: Just to clarify a little further: I want to distribute a package in another language that will accept any LaTeX document and produce HTML output (mostly of academic papers). 更新:只是为了进一步澄清:我想以另一种语言分发一个包,它将接受任何LaTeX文档并生成HTML输出(主要是学术论文)。 I can't expect anything else to be installed (eg ghostscript, perl, latex2html, tth) on the machines already, and it needs to run cross platform. 我不能指望在机器上安装任何其他东西(例如ghostscript,perl,latex2html,tth),它需要运行跨平台。 In other words, if I can find something that has compilable source code (or code in Java or C++) then I would rather go down that route so that the application is self contained. 换句话说,如果我能找到具有可编译源代码(或Java或C ++代码)的东西,那么我宁愿沿着那条路走下去,以便应用程序是自包含的。 Alternatively, I will just use latex2html or tth and require the user to install those separately (although that's not ideal). 或者,我将使用latex2html或tth并要求用户单独安装(尽管这并不理想)。

Latex2html is the way to go. Latex2html是要走的路。 You say that you don't want any dependency, but any library you'll pick will be something you'll depend on. 你说你不想要任何依赖,但你选择的任何库都将是你依赖的东西。 Latex2html: Latex2html:

  • works great, 效果很好,
  • it's part of TeX 它是TeX的一部分
  • it's relatively small that you can bundle the executable with your app 您可以将可执行文件与应用程序捆绑在一起相对较小
  • it's open source (GPL), so you might also try to link it within your program and not have an external dependency (you need to release with a GPL-compatible license, though) 它是开源的(GPL),所以你也可以尝试在你的程序中链接它而没有外部依赖(你需要发布一个兼容GPL的许可证)
  • support bibtex out of the box, 支持bibtex开箱即用,
  • understand hyperlinks (if you convert from a postscript, you'll lose the hyperlinks) 了解超链接(如果你从postscript转换,你将失去超链接)

I believe it compiles on all the major platforms (Linux, Windows, Mac) - but honestly I only have Linux so I can't say for sure. 我相信它可以在所有主要平台(Linux,Windows,Mac)上编译 - 但老实说,我只有Linux,所以我不能肯定地说。

I dont know of a native Java or C++ library to do this. 我不知道本地Java或C ++库来做到这一点。 But, if you're generating HTML anyway, you could always use JavaScript to convert the latex to html within the document. 但是,如果你正在生成HTML,你总是可以使用JavaScript将乳胶转换为文档中的html。

jsMath is great at this: jsMath很擅长:

http://www.math.union.edu/~dpvc/jsMath/ http://www.math.union.edu/~dpvc/jsMath/

As I see it, there are five fairly widely adopted tools for latex to html conversion (there are many more which are less actively used ): 正如我所看到的,有五种相当广泛采用的工具用于乳胶到HTML转换(还有更多不常用的工具 ):

  • Latex2Hmtl is a set of perl scripts. Latex2Hmtl是一组perl脚本。
  • TtH is compiled and written in C. TtH是用C编译和编写的。
  • Hevea is compiled and written in OCaml (with a GNU Library General Public License). Hevea是在OCaml中编译和编写的(具有GNU库通用公共许可证)。
  • TeX4ht is compiled and written in C (with an LPPL license). TeX4ht是用C编译和编写的(带有LPPL许可证)。
  • Another interesting looking option is plasTeX which is written in Python. 另一个有趣的选择是用Python编写的plasTeX

USENIX has a nice page showing how to use some of these. USENIX有一个很好的页面,展示了如何使用其中的一些。

So far, my best option seems to be TtH since I can readily compile the C source into my C++ application. 到目前为止,我最好的选择似乎是TtH,因为我可以很容易地将C源代码编译到我的C ++应用程序中。

I use LyX as a frontend to latex, which makes editing a lot more convenient, and sort of produces its own flavor of latex. 我使用LyX作为乳胶的前端,这使编辑更方便,并且产生自己的乳胶味道。 The upside is that for LyX, there is a separate html export, which uses all the extra-information present in LyX. 好处是LyX,有一个单独的html导出,它使用LyX中的所有额外信息。 The tool is called eLyxer. 该工具称为eLyxer。

The homepage states: 主页说明:

There are some tools for TeX -> HTML conversion … but the results tend to be poor and rigid. TeX有一些工具 - > HTML转换......但结果往往很差且很僵硬。 eLyXer is meant to produce acceptable-to-beautiful HTML code, depending on your browser's Unicode and CSS rendering merits. eLyXer旨在生成可接受的漂亮HTML代码,具体取决于您的浏览器的Unicode和CSS渲染优点。

I can't really compare the output of elyxer with the tex2html tools, but I can confirm that elyxer produces clean, beautiful html code that probably does what you want. 我无法真正比​​较elyxer的输出和tex2html工具,但我可以确认elyxer会产生干净,漂亮的HTML代码,可能会做你想要的。 If you're willing to give LyX a shot :) 如果你愿意给LyX一个机会:)

为什么不运行Latex,并将结果(postscript?pdf)转换为HTML?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM