gpt4 book ai didi

html - 如何使用 emacsclient -e "command"将 .org 文件转换为 html?

转载 作者:可可西里 更新时间:2023-11-01 12:57:13 25 4
gpt4 key购买 nike

我想使用emacsclient -e "command" 将org模式文件转换为html文件,例如:

emacsclient -e "(org-html-export-as-html ./mynote.org)" > ./mynote.html

希望它将输出保存到 mynote.html 文件中。
但是我还不熟悉elisp。实际上,org-html-export-as-html 有很多我不知道如何使用的参数。

最佳答案

A/你可以“自己”做:

emacsclient -e "(progn (find-file \"file.org\") (org-html-export-to-html) (kill-buffer))" 

注意:要使其正常工作,您应该使用

启动 Emacs
emacs --daemon 

或者如果您已经在运行 Emacs,请键入 M-x server-start

B/使用 github 包

https://github.com/nhoffman/org-export

它创建了一些已编译的 lisp 可执行文件:

  • 组织导出 html
  • 组织导出纠结
  • ...

但我的个人经验是命令行方法更快。

C/Bonus,纠结文件

您可以使用相同的命令行方法来处理文件:

emacsclient -e "(org-babel-tangle-file \"file.org\")"

更新,提供更多关于C/的细节

“缠结”是从 literate programming 创造的一个术语

Literate programming (LP) tools are used to obtain two representations from a literate source file: one suitable for further compilation or execution by a computer, the "tangled" code, and another for viewing as formatted documentation, which is said to be "woven" from the literate source.[3] While the first generation of literate programming tools were computer language-specific, the later ones are language-agnostic and exist above the programming languages.

你有一个独特的文件:

#+TITLE: My Org file

* Configuration

#+BEGIN_SRC bash :tangle yes :tangle "tangled.sh" :shebang "#!/bin/bash"
echo "This is my configuration script"
echo "..do something interesting here.."
#+END_SRC

您可以 html 导出它(A/或 B/部分),但也可以导出它包含的代码,这里是一个 shell 脚本。在 Emacs 中,这可以通过 C-c C-v t 完成,或者在 shell 中,使用我在 C/ 部分提供的命令。结果是自动生成了 tangled.sh 文件。

您可以在这里查看:Babel: active code in Org-mode了解更多详情。

关于html - 如何使用 emacsclient -e "command"将 .org 文件转换为 html?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48109547/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com