gpt4 book ai didi

html - 如何在 orgmode 中对 html 导出标记代码块评估?

转载 作者:太空宇宙 更新时间:2023-11-04 02:21:34 26 4
gpt4 key购买 nike

如果我在 orgmode 中有一个代码块,我可以使用 :exports both 选项导出它的评估。

#+begin_src cpp -n :includes <iostream> :exports both
std::cout << "Hello there";
#+end_src

#+RESULTS:
: Hello there

当我导出到 html (C-c C-e h o) 时,结果 block 跟在代码块之后。但是,我想更明确地表明第二个 block 是第一个 block 的结果,比如一个简单的标签。

如果我修改上面的内容,像这样:

#+begin_src cpp -n :includes <iostream> :exports both
std::cout << "Hello there";
#+end_src

Output:

#+RESULTS:
: Hello there

然后标签“输出:”出现,但结果 block 出现两次——一次在标签之前,一次在标签之后。更糟糕的是,如果我在 orgmode (C-c C-c) 中运行代码,那么第二个结果 block 将放置在文本标签“Output:”之前。我怀疑这也是导出方面发生的事情。

我还注意到,当导出到 html 时,结果 block 被放置在 example 类的 pre 标签中。我想我可以用类似的东西修改 css:

pre.example::before { content: "Output:"; }

但不幸的是,这会将文本放在 pre block 中,我无法添加任何换行符。

是否有任何简单的方法可以在 orgmode 本身或通过 css 中将文本标签添加到结果 block ?如果可能,我想避免使用 javascript。

最佳答案

这应该适用于最近的组织:

    #+name: foo
#+begin_src cpp -n :includes <iostream> :exports both
std::cout << "Hello there";
#+end_src

Output:

#+RESULTS: foo
: Hello there

关于html - 如何在 orgmode 中对 html 导出标记代码块评估?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38034269/

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