使用 html/css,我想在网站底部自动生成参考书目,类似于 Latex 的 \bibliography 命令

发布于 2024-10-15 19:39:38 字数 876 浏览 5 评论 0原文

我会先问我的问题,然后为感兴趣的人提供一些背景知识:

我想知道 html 中是否有一个命令可以自动从 .bib 文件生成参考书目?这意味着在整个文本中,我会添加类似 的内容,然后在 html(或 css)文件的底部,我会编写类似 < code>,并且将使用我的 .bib 文件生成参考书目,并根据 APA 样式进行格式化。该功能与脚注非常相似,只不过每个脚注都是根据某个脚本填充的,该脚本从(本质上)xml 文件中提取信息并以所需的格式输出内容。不难想象有人创建了一个工具来做到这一点,但是,我的谷歌搜索技能并没有让我找到这样的工具。很容易找到将 bib 文件转换为 html 或 xml 的工具,但这不足以满足我的需求。我不想在线发布我的整个围脖文件。相反,对于我生成的每个文档,我希望将 bib 文件中的几个条目作为脚注包含在内。任何指示将不胜感激。

现在,问题背后的原因是:

我最近开始从使用 Latex 编写所有手稿切换到使用 html/css 编写它们。这种方法的优点是速度快:只有 1 个文件用于版本控制(而不是 .dvi、.ps、.aux、.blg 等),共享时要小得多,其他人可以编辑 html 文件并编译它更容易,它更适合我的口味,更容易在屏幕上阅读,等等。然而,对我来说缺点是,虽然我已经用 Latex 编写了很多年,但我才刚刚开始使用 html 和 css科学文档创建。切换的主要动力是 MathJaX,它使我能够将 Latex 方程嵌入到我的 html 文件中,因此,使我能够将 Latex 的优点与 css 的优点结合起来。我想几乎所有的同事都会从乳胶转向这种更简单的格式,假设一些剩余的问题得到解决,比如易于创建参考书目。

非常感谢。

I'll ask my question first, then give some background for those who are interested:

I would like to know if there is a command in html that will automatically generate a bibliography from a .bib file? This means that throughout the text, i would add something like <cite name="Jones2010">, and then at the bottom of the html (or css) file, I would write something like <makebib file="biblist.bib", format="APA">, and a bibliography would be generated using my .bib file, and formated according to the APA style. The functionality would be quite similar to footnotes, except that each footnote is populated according to some script that extracts the information from (essentially) an xml file and outputs the content in the desired format. It is not difficult to imagine somebody creating a tool to do just that, however, my google search skills have not enabled me to find such a tool. It is easy to find tools that convert bib files to html or xml, but that is not sufficient for my needs. I do not desire to publish my entire bib file online. Rather, for each document that I generate, I want several of the entries in the bib file to be included as footnotes. Any pointers will be greatly appreciated.

Now, the reason behind the question:

I have recently begun switching from writing all my manuscripts using latex to writing them using html/css. The advantages of this approach are fast: only 1 file for versioning (instead of .dvi, .ps, .aux, .blg, etc.), it is much smaller to share, other people can edit the html file and compile it much more easily, it is more configurable to my tastes, easier to read on screen, etc. The disadvantage for me, however, is that while I've been writing in latex for years, I've only just begin using html and css for scientific document creating. The main impetus for the switch was MathJaX, which enables me to to embed latex equations in my html files, and therefore, allows me to combine the advantages of latex with the advantages of css. I imagine that nearly all my colleagues will switch away from latex to this simpler format, assuming a few remaining issues get resolved, like ease of creating bibliographies.

Many thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

等风来 2024-10-22 19:39:38

你所要求的是不可能的,除非当你指定 html/css 时,你真正的意思是 html/css/php 或 html/css/python 或其他一些包含实际编程语言的组合,而不仅仅是标记语言。

我理解你的动机,我很想切换到 html 而不是 Latex!然而,我怀疑基于 html 的解决方案会涉及到在顶部添加太多额外的处理来整理参考书目等,以至于当您解决所有问题时,复杂性将开始接近 LaTeX 的复杂性。

我很高兴在这一点上被证明是错误的!

What you're asking isn't possible, unless when you specify html/css you really mean html/css/php or html/css/python or some other combination that includes an actual programming language, rather than just a markup language.

I understand your motivation, I'd love to switch to html instead of latex! However, I suspect an html-based solution would involve so much extra processing added on top to sort out bibliographies etc that the complexity would start approaching that of LaTeX by the time you got it all worked out.

I'd be pleased to be proven wrong on this!

贪恋 2024-10-22 19:39:38

我过去曾使用 XSLT 和 BibTeX 完成此操作。概括地说,这些步骤是

  1. 使用某种约定或其他约定来标记文档:我使用 Smith99
  2. 编写一个 XSLT 脚本将该文件转换为包含 \itation 命令的 .aux 文件
  3. 使用 BibTeX 和 .bst 文件,该文件输出 HTML 而不是 LaTeX
  4. 使用另一个 XSLT 脚本(或相同的,以不同的模式)将参考书目拉入

它并不像听起来那么繁琐,但你可以看看 我是如何在谷歌代码上做到的。特别是,请参阅 structure.xsltplainhtml.bst

如果有更直接的方法,我很想听听。

I've done this, in the past, using XSLT and BibTeX. In outline, the steps are

  1. Mark up your document using some convention or other: I used <span class='citation'>Smith99</span>
  2. Write an XSLT script to transform that file into a .aux file with \citation commands in it
  3. Use BibTeX along with a .bst file which spits out HTML rather than LaTeX
  4. Use another XSLT script (or the same one, in a different mode) to pull the bibliography in

It's not quite as fiddly as it sounds, but you can look at how I did it on google code. In particular, see structure.xslt and plainhtml.bst.

If there's a more direct way, I'd be quite interested to hear about it.

月下凄凉 2024-10-22 19:39:38

到目前为止,这两个答案都有些正确,尽管不完全符合您的要求。部分问题在于,这个问题的措辞不一定有意义。

HTML 只是标记;你需要一些东西来处理标记,可以是python、php、ruby等。

而且你可能想用XML(或XHTML)而不是HTML编写。

XSLT 可能适合您(一旦采用 XML 格式),但请记住,XSLT 文档定义了一组规则。您将获得一个 XSLT 引擎来对 XML 文档应用 XSLT 规则。

Both answers so far are somewhat correct, although not quite what you were asking for. Part of the problem is that the question as it's phrased doesn't necessarily makes sense.

HTML is just markup; you need something to process the markup, be it python, php, ruby, etc.

And you probably want to write in XML (or XHTML), not HTML.

XSLT may work for you (once it's in XML), but remember, an XSLT document that defines a set of rules. You would get an XSLT engine to apply your XSLT rules against your XML document.

蘸点软妹酱 2024-10-22 19:39:38

您可以使用 bibtex2html。该包采用一系列命令行参数并从 BibTeX 源中提取信息并输出带有 html 标记的文件。

据我所知,你无法让它像 LaTeX \cite 命令一样读取和解析 html 文档,但有几种方法可以指示你想要的引用。我发现最简单的方法是维护我在手稿中使用的 BibTeX 键的文本文件,然后使用 --citefile 选项调用它。还有一个名为 bib2bib 的工具,可以执行搜索命令。

这是一个非常灵活的包,有很多选项,因此它可以在很多情况下使用。例如,您可以让它从输出文件中省略 标头,以便您可以直接粘贴到现有的 html 文档中。

该文档很有用,但请务必查看 pdf 文档文件和手册页。

You can create an html bibliography from a .bib file using bibtex2html. This package takes a series of command line arguments and extracts the info from the BibTeX source and outputs a file with html markup.

As far as I know you cannot get it to read and parse the html document like the LaTeX \cite command but there are several ways to indicate the references you want. I find that the easiest way is to just maintain a text file of the BibTeX keys I use in my manuscript and then call this using the --citefile option. There is also a tool called bib2bib included that will take search commands.

It is a very flexible package and there are a lot of options so it works in a lot of situations. For example you can get it to omit the <html> headers from the output file so that you can directly paste into an existing html document.

The documentation is useful but make sure you look at the pdf documentation file and the man pages.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文