1

I noticed a really weird behavior related to #+begin_xxx/#+end_xxx block. It turns out that contents inside those blocks are parsed as org-mode markup. That is, inside a block:

  • * at the beginning of a line is considered as a heading. A direct impact is that org-global-cycle fold/unfold incorrectly sectioning.
  • [[not a link]] is considered as an org-mode link. Export to pdf (org-latex-export-to-pdf) the org file will raise the error Unable to resolve link: "not a link" as it would fail to resolve unexisting links.
  • and probably more...

MWE

emacs-version = 26.3

org-version = 9.2.6

* H1
** H2
#+begin_example
* Should not be rendered as a heading!
[[Should be avoided when exporting]]
#+end_example

#+begin_src c
* sp  = "Should not be rendered as a heading!"
// [[Should be avoided when exporting]]
#+end_src

Issue: org-cycle (Tab)

org-cycle-1 org-cycle-2

Issue: org-global-cycle (Shift+Tab)

org-global-cycle-1 org-global-cycle-2 org-global-cycle-3

Issue: org-export-latex-to-pdf

org-export-latex-to-pdf

Related question

1

You must escape such constructs in example blocks. The Literal Examples section of the manual states:

There is one limitation, however. You must insert a comma right before lines starting with either ‘*’, ‘,*’, ‘#+’ or ‘,#+’, as those may be interpreted as outlines nodes or some other special syntax. Org transparently strips these additional commas whenever it accesses the contents of the block.

#+BEGIN_EXAMPLE
,* I am no real headline
#+END_EXAMPLE

And it turns out that escaping the "fake" headline also solves the link export problem. Try exporting this:

* H1
** H2
#+begin_example
,* Should not be rendered as a heading!
[[Should be avoided when exporting]]
#+end_example

#+begin_src c
,* sp  = "Should not be rendered as a heading!"
// [[Should be avoided when exporting]]
#+end_src

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.