[英]Including the '$' sign when exporting from org-mode Babel?
I am writing a tech book using org-mode. 我正在使用组织模式编写一本技术书籍。 I want to export to markdown (GitHub Flavored) code and results and it works fine.
我想导出到markdown(GitHub Flavored)代码和结果,它工作正常。 But I also want to export the
$
or whatever comes before (eg (venv) $
when I type something in the terminal. 但是我也希望在终端输入内容时输出
$
或之前的任何内容(例如(venv) $
。
Now I have this: 现在我有这个:
#+BEGIN_SRC sh :exports both
python --version
#+END_SRC
#+RESULTS:
: Python 3.6.2
Which gets exported into this: 哪个导出到此:
python --version
Python 3.6.2
And what I want is this: 我想要的是这个:
$ python --version
Python 3.6.2
Any ideas? 有任何想法吗?
For HTML output you could add an export filter like 对于HTML输出,您可以添加导出过滤器
(defun my-html-dollar-sign-filter (text backend info)
"Add a $ sign to the beginning of code blocks"
(when (org-export-derived-backend-p backend 'html)
(replace-regexp-in-string
"\\(<pre class=\"src src-sh\">\\)" "\\1$ " text)))
(add-to-list 'org-export-filter-src-block-functions
'my-html-dollar-sign-filter)
which workes sinces <pre class="src src-sh">python --version</pre>
identifies the command pretty unambiguously in the HTML output. 自从
<pre class="src src-sh">python --version</pre>
以来,HTML输出中的命令非常明确。 Unfortunately the Latex exporter wraps both code and result in a verbatim
environment which makes it impossible to only put a dollar sign in front of the code this way. 不幸的是,Latex导出器包装了两个代码并导致
verbatim
环境,这使得不可能只在代码前面放置一个美元符号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.