3

I'm trying to post a babel src block that contains a babel definition since I am documenting some babel source blocks in a Hugo post written in org mode.

What I want to do is the following:

#+BEGIN_SRC #+BEGIN_SRC dot :file my_output_file.png :cmdline -Kdot -Tpng digraph G { my_start -> one_branch; my_start -> another_branch; } #+END_SRC #+END_SRC 

And the output I'd like to achieve when exporting is:

#+BEGIN_SRC dot :file my_output_file.png :cmdline -Kdot -Tpng digraph G { my_start -> one_branch; my_start -> another_branch; } #+END_SRC 

BUt what I get instead is

#+BEGIN_SRC dot :file my_output_file.png :cmdline -Kdot -Tpng digraph G { my_start -> one_branch; my_start -> another_branch; } 

Since the first #+END_SRC finishes the code block.

Is there any way to escape the #+END_SRC so I can have my src block as I expect?

Thanks a lot!

1
  • You escape the inside #+BEGIN and #+END by prefixing them with a ,. You can find many such examples here in my ox-hugo test file.. just search for ,#. Commented Jan 27, 2018 at 17:43

2 Answers 2

3

In general, you can include any orgmode inside a literal example (SRC or EXAMPLE blocks, or even headings).

You may need to escape headings and block delimiters with a comma. This escaping is done automatically if you edit your block in a separate buffer via C-c '.

Documentation here.

Example of block with escaped heading and source block:

* Test #+begin_src org ,* this is a heading The following is a source code example ,#+begin_src emacs-lisp (+ 1 2 3 4) ,#+end_src ,#+RESULTS: : 10 #+end_src 
1

Do you need the outer block to be a SRC block? The standard way I think of doing what you want is like this:

#+BEGIN_EXAMPLE #+BEGIN_SRC dot ... ... #+END_SRC #+END_EXAMPLE 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.