0

I'm writing a short story. The end result will be a 30-page doc with zero chapters or headings, (not even a title.) However, within org mode, I would like to have a foldable outline for working with individual scenes. So I tried the following:

#+BEGIN_COMMENT

* SCENE #1 - Autopsy

#+END_COMMENT

This gives me the foldable outline within Emacs that I need, but unfortunately it exports the comment to ODT, even though the guide says otherwise:

      "regions surrounded by ‘#+BEGIN_COMMENT’ … ‘#+END_COMMENT’ are not exported."
      (Org Guide: 12.5 Comment Lines)

I've also tried using the COMMENT tag in front of the heading, but to no avail.

This is my first time trying Emacs for published prose. I bet there's a simple solution, but I haven't found it yet.

5
  • i tested on emacs 26.1... Both #+BEGIN_COMMENT option and tag option are working, by which I mean that the marked sections are not exported to odt. I used C-c C-e o o to export...
    – Saravana
    Mar 24 at 2:15
  • @Saravana Thanks for your reply. Really? It doesn't work here. Emacs 29.2 on Macos 14.4 Export: C-c C-e o O Apache Open Office 4.1.15 Results in following line in exported OD: SCENE #1 - Autopsy surrounded by begin/end comments. Any ideas?
    – user43800
    Mar 25 at 3:18
  • I've just noticed that some scene headings are successfully commented out while others are not. Perhaps an ill-defined macro has screwed up something. I'll investigate further. Thanks for help.
    – user43800
    Mar 25 at 6:43
  • See emacs.stackexchange.com/a/73108/42623 for more ideas
    – mxnt
    Mar 25 at 6:52
  • Still stuck on this. Here's a minimal doc that reproduces the problem, i.e. comments not hiding headings: ``` #+OPTIONS: title:nil toc:nil author nil date:nil num:nil #+BEGIN_COMMENT * Scene #1: Murder #+END_COMMENT Once upon a nasty time... blah blah End of scene #1. #+BEGIN_CENTER * #+END_CENTER #+BEGIN_COMMENT * Scene #2: Autopsy #+END_COMMENT Start of scene #2 ```
    – user43800
    Mar 25 at 21:22

2 Answers 2

0

Do a C-c C-c of the elisp code below ...

#+begin_src emacs-lisp :exports results :results none
  (add-hook 'org-export-before-parsing-hook
        (defun my-flush-headlines (backend)
          (cl-case backend
        (odt
         (org-with-wide-buffer
          ;; Flush headlines
          (flush-lines (rx (and bol (one-or-more "*") space (one-or-more any) eol))
                   (point-min) (point-max))))
        (otherwise
         ))))

  ;; (remove-hook 'org-export-before-parsing-hook-hook
  ;;         'my-flush-headlines)

#+end_src

* Non non deserunt consectetur amet, ullamco

Enim  non  voluptate  mollit  ea  laboris et  ex  nostrud  qui  labore
cupidatat. Do nisi ea quis et deserunt minim velit ut.

** Excepteur duis eiusmod reprehenderit et reprehenderit

Dolor elit, culpa aliqua enim culpa duis sit nostrud veniam, sint esse
sed id excepteur aute velit velit fugiat dolor.

* Sint eu magna aliqua enim

Occaecat  cupidatat  occaecat  excepteur  sed tempor  dolore  eu  quis
consectetur eu nulla labore proident, enim culpa.

** Fugiat fugiat consectetur fugiat fugiat

Irure  velit pariatur  nulla commodo  anim elit,  ea mollit  sit amet,
commodo et tempor ex commodo adipiscing id.
0

The recipe below hides the Outline Headings (as opposed to deleting those). Look at the XML style definition, and you can figure out what XML attributes come in to play for "hiding" and "page breaking" to take effect.

For the recipe below to work, you MUST be using The Authoritative fork of Org mode's ODT exporter .

(Note that the above exporter is a much more advanced and featureful ODT exporter than what is available in Emacs or Org mode repos.)

see also Create a stylesheet for your OpenDocument files, and inline the XML definitions right in your Org file–Think HTML_HEAD, or HTML_HEAD_EXTRA but for ODT / DOCX files

If you want this

enter image description here

export this

* Non non deserunt consectetur amet, ullamco

Enim  non  voluptate  mollit  ea  laboris et  ex  nostrud  qui  labore
cupidatat. Do nisi ea quis et deserunt minim velit ut.

** Excepteur duis eiusmod reprehenderit et reprehenderit

Dolor elit, culpa aliqua enim culpa duis sit nostrud veniam, sint esse
sed id excepteur aute velit velit fugiat dolor.

* Sint eu magna aliqua enim

Occaecat  cupidatat  occaecat  excepteur  sed tempor  dolore  eu  quis
consectetur eu nulla labore proident, enim culpa.

** Fugiat fugiat consectetur fugiat fugiat

Irure  velit pariatur  nulla commodo  anim elit,  ea mollit  sit amet,
commodo et tempor ex commodo adipiscing id.

# Hide Headings but also insert Page Break


#+ATTR_ODT: :target "extra_styles" :backends (odt)
#+begin_src nxml
<style:style style:name="Heading"
             style:parent-style-name="Standard"
             style:next-style-name="Text_20_body"
             style:family="paragraph"
             style:class="text"
             style:master-page-name="">
  <style:paragraph-properties fo:break-before="page"
                              fo:keep-with-next="always"
                              fo:margin-bottom="0.212cm"
                              fo:margin-top="0.423cm"
                              style:page-number="auto">
    <style:tab-stops>
      <style:tab-stop style:position="17cm"
                      style:type="right" />
    </style:tab-stops>
  </style:paragraph-properties>
  <style:text-properties style:font-name="Arial"
             style:font-name-asian="SimSun"
             style:font-name-complex="Tahoma1"
             fo:font-family="Arial"
             fo:font-size="14pt"
             style:font-family-asian="SimSun"
             style:font-family-complex="Tahoma"
             style:font-family-generic="swiss"
             style:font-family-generic-asian="system"
             style:font-pitch="variable"
             style:font-pitch-asian="variable"
             style:font-pitch-complex="variable"
             style:font-size-asian="14pt"
             style:font-size-complex="14pt"
             text:display="none" />
</style:style>
#+end_src

# # Hide Headings

# #+ATTR_ODT: :target "extra_styles" :backends (odt)
# #+begin_src nxml
# <style:style style:name="Heading"
#              style:parent-style-name="Standard"
#              style:next-style-name="Text_20_body"
#              style:family="paragraph"
#              style:class="text">
#   <style:paragraph-properties fo:keep-with-next="always"
#                               fo:margin-bottom="0.212cm"
#                               fo:margin-top="0.423cm">
#     <style:tab-stops>
#       <style:tab-stop style:position="17cm"
#                       style:type="right" />
#     </style:tab-stops>
#   </style:paragraph-properties>
#   <style:text-properties style:font-name="Arial"
#            style:font-name-asian="SimSun"
#            style:font-name-complex="Tahoma1"
#            fo:font-family="Arial"
#            fo:font-size="14pt"
#            style:font-family-asian="SimSun"
#            style:font-family-complex="Tahoma"
#            style:font-family-generic="swiss"
#            style:font-family-generic-asian="system"
#            style:font-family-generic-complex="system"
#            style:font-pitch="variable"
#            style:font-pitch-asian="variable"
#            style:font-pitch-complex="variable"
#            style:font-size-asian="14pt"
#            style:font-size-complex="14pt"
#            text:display="none" />
# </style:style>
# #+end_src

# Hide entries of Heading entries in TOC

#+ATTR_ODT: :target "extra_styles" :backends (odt)
#+begin_src nxml
<style:style style:name="Index"
             style:parent-style-name="Standard"
             style:family="paragraph"
             style:class="index">
  <style:paragraph-properties text:line-number="0"
                              text:number-lines="false" />
  <style:text-properties style:font-name-complex="Tahoma"
             style:font-family-complex="Tahoma"
             text:display="none" />
</style:style>
#+end_src


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.