From: Rasmus <rasmus@gmx.us>
To: bzg@gnu.org
Cc: emacs-orgmode@gnu.org
Subject: Re: New worg page: Publishing beamer slideshows and articles from one source
Date: Mon, 26 May 2014 17:56:38 +0200 [thread overview]
Message-ID: <87mwe4sfd5.fsf@gmx.us> (raw)
In-Reply-To: <87mwe4n219.fsf@bzg.ath.cx> (Bastien's message of "Mon, 26 May 2014 14:43:30 +0200")
[-- Attachment #1: Type: text/plain, Size: 1356 bytes --]
Bastien <bzg@gnu.org> writes:
> Hi Rasmus,
>
> Rasmus <rasmus@gmx.us> writes:
>
>>> The only tricky part is to remove the heading from the table
>>> of contents, but this is optional and the limitation can be advertized
>>> as such.
>>
>> Come on, that's not really acceptable for an advice on org-mode.org.
>
> It is better than the current situation.
I disagree. Let's try to keep the quality on Worg high. Let's not put
broken code there, especially without explaining why.
I have attached a quick patch with a text that I think is more
accurate and that tries to explain the issue. I think the tone may be
too "academic"/dry.
Since Suvayu put the initial effort into the answer I will wait for
his approval before submitting it.
>> To deal with the tricky part you need an additional filter. Or you
>> need a filter on the final output and you'd probably need to make some
>> accounting of what's present and what is not so that you can update
>> counters and TOCs.
>
> That's why I say it's tricky.
>
> Let's keep this constructive and move forward -- maybe that was not
> your intention, but the tone of your first email was a bit harsh.
> I'm sure Suvayu is open to suggestions on how to improve the filter.
That was not the intention. For that I appoligize.
–Rasmus
--
Summon the Mothership!
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ignore-headlines.patch --]
[-- Type: text/x-diff, Size: 4868 bytes --]
diff --git a/org-hacks.org b/org-hacks.org
index 63dfa62..2679a00 100644
--- a/org-hacks.org
+++ b/org-hacks.org
@@ -2195,30 +2195,52 @@ before you proceed.
:CUSTOM_ID: ignoreheadline
:END:
#+index: Export!ignore headlines
-Sometimes users want to ignore the headline text during export. In
-the old exporter one would use a export hook. From Org 8.0 onwards,
-the export filter mechanism is used (see: =org-export-filters-alist=).
-
-To ignore a headline during export using special tags, you can use the
-following filter.
-#+begin_src emacs-lisp
- (defun sa-ignore-headline (contents backend info)
- "Ignore headlines with tag `ignoreheading'."
- (when (and (org-export-derived-backend-p backend 'latex 'html 'ascii)
- (string-match "\\`.*ignoreheading.*\n"
- (downcase contents)))
- (replace-match "" nil nil contents)))
-
- (add-to-list 'org-export-filter-headline-functions 'sa-ignore-headline)
-#+end_src
-Adding this to your configuration, you can ignore headlines by tagging
-them with =ignoreheading=. In the above snippet, this works for
-LaTeX, HTML, and ASCII backends. You can add more backends to the
-list by just appending the appropriate name like this: =\'backend=.
-If you would rather have this feature in all backends, then simply
-remove the =when= condition.
+Sometimes users want to ignore the headline text during export like in
+the Beamer exporter (=ox-beamer=). In the [[http://orgmode.org/manual/Beamer-export.html#Beamer-export][Beamer exporter]] one can use
+the tag =ignoreheading= to disable the export of a certain headline,
+whilst still retaining the content of the headline. We can imitate
+this feature in other export backends. Note that this is not a
+particularly easy problem, as the Org exporter creates a static
+representation of section numbers, table of contents etc.
+
+Consider the following document
+#+BEGIN_SRC org
+ ,* head 1 :noexport:
+ ,* head 2 :ignoreheading:
+ ,* head 3
+ ,* =head 4= :ignoreheading:
-You can find the latest version of the filter in [[https://github.com/suvayu/.emacs.d/blob/master/org-mode-config.el][my setup on github]].
+#+END_SRC
+We want to remove heading 2 and 4.
+
+There are different strategies to accomplish this:
+1. The best option is to remove headings tagged with =ignoreheading=
+ before export starts. This can be accomplished with the hook
+ =org-export-before-parsing-hook= that runs before the buffer has
+ been parsed. In the example above, however, =head 2= would not be
+ exported as it becomes part of =head 1= which is not exporter. To
+ overcome this move perhaps =head 1= can be moved to the end of the
+ buffer. An example of a hook that removes headings is before
+ parsing is available [[https://lists.gnu.org/archive/html/emacs-orgmode/2014-03/msg01459.html][here]]. Note, this solution is compatible with
+ /all/ export formats!
+2. The problem is simple when exporting to LaTeX, as the LaTeX
+ compiler determines numbers. We can thus use
+ =org-export-filter-headline-functions= to remove the offending
+ headlines. One regexp-based solution that looks for the word
+ =ignoreheading= is available on [[https://stackoverflow.com/questions/10295177/is-there-an-equivalent-of-org-modes-b-ignoreheading-for-non-beamer-documents][StackOverflow]] for both the legacy
+ exporter Org v7 exporter and the current Org v8 exporter. Note,
+ however, that this filter will only work with LaTeX (numbering and
+ the table of content may break in other exporters). In the example
+ above, this filer will work flawlessly in LaTeX, it will not work
+ at all in HTML and it will fail to update section numbers, TOC and
+ leave some auxiliary lines behind when exporting to plain text.
+3. Another solution that tries to recover the Org element
+ representation is available [[https://lists.gnu.org/archive/html/emacs-orgmode/2014-03/msg01480.html][here]]. In the example above this filter
+ will not remove =head 4= exporting to any backend, since verbatim
+ strings do not retain the Org element representation. It will
+ remove the extra heading line when exporting to plain text, but
+ will also fail to update section numbers. It should be fairly
+ simple to also make it work with HTML.
*** Export Org to Org and handle includes.
#+index: Export!handle includes
@@ -3846,4 +3868,3 @@ hydrometer correction, abv calculation, priming sugar for a given CO_2
volume, etc. More integration with org-mode should be possible: for
instance it would be nice to be able to use a lookup table (of ingredients)
to calculate target original gravity, IBUs, etc.
-
next prev parent reply other threads:[~2014-05-26 15:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-10 2:57 New worg page: Publishing beamer slideshows and articles from one source James Harkins
2014-05-12 19:17 ` Suvayu Ali
2014-05-14 0:56 ` James Harkins
2014-05-14 16:11 ` Suvayu Ali
2014-05-21 13:28 ` Bastien
2014-05-24 9:54 ` Suvayu Ali
2014-05-25 10:12 ` Rasmus
2014-05-26 5:24 ` Bastien
2014-05-26 10:24 ` Rasmus
2014-05-26 12:43 ` Bastien
2014-05-26 15:56 ` Rasmus [this message]
2014-05-27 13:15 ` Suvayu Ali
2014-05-28 19:51 ` Bastien
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mwe4sfd5.fsf@gmx.us \
--to=rasmus@gmx.us \
--cc=bzg@gnu.org \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).