问题
在以下代码上运行
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
您可以使用
: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