`org-export-to-html` 不导出 ANSI 颜色

问题描述 投票:0回答:1

问题

在以下代码上运行

org-export-to-html
后:

#+BEGIN_SRC shell :exports both :results output
  echo -e "\e[0;31mOUTPUT\e[0m"
#+END_SRC

OUTPUT 以黑色导出

所需输出

OUTPUT 以红色导出


建议的解决方案

以下代码使用 (aha)

将输出导出为 html
#+BEGIN_SRC shell :exports both :results output html
  echo -e "\e[0;31mOUTPUT\e[0m" | aha
#+END_SRC

建议解决方案的问题

初始命令只是

echo -e "\e[0;31mOUTPUT\e[0m"
而不是
echo -e "\e[0;31mOUTPUT\e[0m" | aha

org-mode
1个回答
0
投票

您可以使用

:prologue
:epilogue
将代码块包装在括号中,并将结果通过管道传输到
aha
(为此,我建议您使用
-n
选项)。

像这样:

#+BEGIN_SRC shell :exports both :results output html :prologue "(" :epilogue ") | aha -n"
echo -e "\e[0;31mOUTPUT\e[0m"
#+END_SRC

#+RESULTS:
#+begin_export html
<span style="color:red;">OUTPUT</span>
#+end_export
© www.soinside.com 2019 - 2024. All rights reserved.