sign when exporting from Babel org mode? I am writing a technical book using org-mode. I want to export the default code and ...">
sign when exporting from Babel org mode? - emacs 💉 ♂️ 👩🏻‍🤝‍👨🏾

Including the '$' sign when exporting from Babel org mode?

I am writing a technical book using org-mode. I want to export the default code and results (GitHub Flavored) and it works great. But I also want to export $or everything that comes earlier (for example (venv) $, when I enter something into the terminal.

Now I have this:

#+BEGIN_SRC sh :exports both
  python --version
#+END_SRC

#+RESULTS:
: Python 3.6.2

What is exported to this:

python --version
Python 3.6.2

And I want this:

$ python --version

Python 3.6.2

Any ideas?

+4
source share
1 answer

For HTML output, you can add an export filter , for example

(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)

sinces <pre class="src src-sh">python --version</pre>, HTML. , Latex verbatim, .

0

Source: https://habr.com/ru/post/1688030/


All Articles