emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: Unable to nest headings within export blocks [9.0 (9.0-elpa @ c:/Data/Documents/emacs.d/elpa/org-20161102/)]
@ 2016-11-03  3:47 Lixin Chin
  2016-11-03  5:20 ` Lixin Chin
  2016-11-05  7:41 ` Nicolas Goaziou
  0 siblings, 2 replies; 6+ messages in thread
From: Lixin Chin @ 2016-11-03  3:47 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 412 bytes --]

As per the subject, when a heading line is included within a
`#+BEGIN_EXPORT backend ... #+END_EXPORT' block, it breaks the parsing
of the block, which is instead split into multiple `paragraph' elements.

See the attached example (test.org), and associate exports (test.tex)
and (test.html).

Tested with `emacs -Q -l minimal-org.el', with the org package installed
from http://orgmode.org/elpa/, org-20161102.

[-- Attachment #2: test.org --]
[-- Type: text/plain, Size: 234 bytes --]

* Test heading

#+BEGIN_EXPORT latex
Text which should appear in \LaTeX{} exports, but not HTML.
#+END_EXPORT

#+BEGIN_EXPORT html
* HTML only heading
Text which should appear in HTML exports, but not \LaTeX{}.
#+END_EXPORT

[-- Attachment #3: test.tex --]
[-- Type: text/plain, Size: 925 bytes --]

% Created 2016-11-03 Thu 11:34
% Intended LaTeX compiler: pdflatex
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{grffile}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{amssymb}
\usepackage{capt-of}
\usepackage{hyperref}
\date{\today}
\title{}
\hypersetup{
 pdfauthor={},
 pdftitle={},
 pdfkeywords={},
 pdfsubject={},
 pdfcreator={Emacs 25.1.1 (Org mode 9.0)}, 
 pdflang={English}}
\begin{document}

\tableofcontents

\section{Test heading}
\label{sec:org0b53ca6}

Text which should appear in \LaTeX{} exports, but not HTML.

\#+BEGIN\(_{\text{EXPORT}}\) html
\section{HTML only heading}
\label{sec:org14261e8}
Text which should appear in HTML exports, but not \LaTeX{}.
\#+END\(_{\text{EXPORT}}\)
\end{document}

[-- Attachment #4: test.html --]
[-- Type: text/html, Size: 10960 bytes --]

[-- Attachment #5: minimal-org.el --]
[-- Type: text/plain, Size: 96 bytes --]

(setq user-emacs-directory "C:/Data/Documents/emacs.d/")
(package-initialize)
(require 'org)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Bug: Unable to nest headings within export blocks [9.0 (9.0-elpa @ c:/Data/Documents/emacs.d/elpa/org-20161102/)]
  2016-11-03  3:47 Bug: Unable to nest headings within export blocks [9.0 (9.0-elpa @ c:/Data/Documents/emacs.d/elpa/org-20161102/)] Lixin Chin
@ 2016-11-03  5:20 ` Lixin Chin
  2016-11-05  7:41 ` Nicolas Goaziou
  1 sibling, 0 replies; 6+ messages in thread
From: Lixin Chin @ 2016-11-03  5:20 UTC (permalink / raw)
  To: emacs-orgmode

This seems to be a symptom of the same issue as
http://lists.gnu.org/archive/html/emacs-orgmode/2016-10/msg00175.html

A workaround is to put the contents of the #+BEGIN_EXPORT ... block into
a separate .org file (include.org), and #+INCLUDE it in the main document

#+INCLUDE: "include.org" export <backend>

where "include.org":
* Heading
other text

On 03/11/2016 11:47 AM, Lixin Chin wrote:
> As per the subject, when a heading line is included within a
> `#+BEGIN_EXPORT backend ... #+END_EXPORT' block, it breaks the parsing
> of the block, which is instead split into multiple `paragraph' elements.
>
> See the attached example (test.org), and associate exports (test.tex)
> and (test.html).
>
> Tested with `emacs -Q -l minimal-org.el', with the org package installed
> from http://orgmode.org/elpa/, org-20161102.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Bug: Unable to nest headings within export blocks [9.0 (9.0-elpa @ c:/Data/Documents/emacs.d/elpa/org-20161102/)]
  2016-11-03  3:47 Bug: Unable to nest headings within export blocks [9.0 (9.0-elpa @ c:/Data/Documents/emacs.d/elpa/org-20161102/)] Lixin Chin
  2016-11-03  5:20 ` Lixin Chin
@ 2016-11-05  7:41 ` Nicolas Goaziou
  2016-11-07  2:47   ` Lixin Chin
  1 sibling, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2016-11-05  7:41 UTC (permalink / raw)
  To: Lixin Chin; +Cc: emacs-orgmode

Hello,

Lixin Chin <lixinchin@gmail.com> writes:

> As per the subject, when a heading line is included within a
> `#+BEGIN_EXPORT backend ... #+END_EXPORT' block, it breaks the parsing
> of the block, which is instead split into multiple `paragraph' elements.
>
> See the attached example (test.org), and associate exports (test.tex)
> and (test.html).
>
> Tested with `emacs -Q -l minimal-org.el', with the org package installed
> from http://orgmode.org/elpa/, org-20161102.
>
> * Test heading
>
> #+BEGIN_EXPORT latex
> Text which should appear in \LaTeX{} exports, but not HTML.
> #+END_EXPORT
>
> #+BEGIN_EXPORT html
> * HTML only heading
> Text which should appear in HTML exports, but not \LaTeX{}.
> #+END_EXPORT

You need to escape the pseudo-headline with a comma.

  #+BEGIN_EXPORT html
  ,* HTML only heading
  Text which should appear in HTML exports, but not \LaTeX{}.
  #+END_EXPORT


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Bug: Unable to nest headings within export blocks [9.0 (9.0-elpa @ c:/Data/Documents/emacs.d/elpa/org-20161102/)]
  2016-11-05  7:41 ` Nicolas Goaziou
@ 2016-11-07  2:47   ` Lixin Chin
  2016-11-07 16:44     ` Charles C. Berry
  0 siblings, 1 reply; 6+ messages in thread
From: Lixin Chin @ 2016-11-07  2:47 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

Thanks, yes that almost works. Unfortunately the heading line is just
reproduced verbatim in the output, whereas ideally it should be parsed
as a normal heading.

I.e., currently:

#+BEGIN_EXPORT html
,* HTML only heading
Text which should appear in HTML exports, but not \LaTeX{}.
#+END_EXPORT

Exports as:

<div class="outline-text-2" id="text-1">
* HTML only heading
Text which should appear in HTML exports, but not \LaTeX{}.
</div>

Whereas ideally I'd like to be able to input:

#+BEGIN_EXPORT html
* HTML only heading
Text which should appear in HTML exports, but not \LaTeX{}.
#+END_EXPORT

that would export as:

<div id="outline-container-org2295e90" class="outline-2">
   <h2 id="org2295e90"><span class="section-number-2">2</span> HTML only 
heading</h2>
   <div class="outline-text-2" id="text-2">
   <p>
     Text which should appear in HTML exports, but not \LaTeX{}.
   </p>
   </div>
</div>

I'm not sure how difficult this would be to add to org-mode. It seems
that currently everything within a #+BEGIN_EXPORT <backend> ...
#+END_EXPORT block, or included using #+INCLUDE: <filename> export
<backend> is just treated as verbatim text to be include in the output,
and bypasses much of the org-mode parsing.

Regards,
Lixin


On 05/11/2016 03:41 PM, Nicolas Goaziou wrote:
> Hello,
>
> Lixin Chin <lixinchin@gmail.com> writes:
>
>> As per the subject, when a heading line is included within a
>> `#+BEGIN_EXPORT backend ... #+END_EXPORT' block, it breaks the parsing
>> of the block, which is instead split into multiple `paragraph' elements.
>>
>> See the attached example (test.org), and associate exports (test.tex)
>> and (test.html).
>>
>> Tested with `emacs -Q -l minimal-org.el', with the org package installed
>> from http://orgmode.org/elpa/, org-20161102.
>>
>> * Test heading
>>
>> #+BEGIN_EXPORT latex
>> Text which should appear in \LaTeX{} exports, but not HTML.
>> #+END_EXPORT
>>
>> #+BEGIN_EXPORT html
>> * HTML only heading
>> Text which should appear in HTML exports, but not \LaTeX{}.
>> #+END_EXPORT
> You need to escape the pseudo-headline with a comma.
>
>    #+BEGIN_EXPORT html
>    ,* HTML only heading
>    Text which should appear in HTML exports, but not \LaTeX{}.
>    #+END_EXPORT
>
>
> Regards,
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Bug: Unable to nest headings within export blocks [9.0 (9.0-elpa @ c:/Data/Documents/emacs.d/elpa/org-20161102/)]
  2016-11-07  2:47   ` Lixin Chin
@ 2016-11-07 16:44     ` Charles C. Berry
  2016-11-09  4:51       ` Lixin Chin
  0 siblings, 1 reply; 6+ messages in thread
From: Charles C. Berry @ 2016-11-07 16:44 UTC (permalink / raw)
  To: Lixin Chin; +Cc: emacs-orgmode

On Mon, 7 Nov 2016, Lixin Chin wrote:

> Hi,
>
> Thanks, yes that almost works. Unfortunately the heading line is just
> reproduced verbatim in the output, whereas ideally it should be parsed
> as a normal heading.
>
> I.e., currently:
>
> #+BEGIN_EXPORT html
> ,* HTML only heading
> Text which should appear in HTML exports, but not \LaTeX{}.
> #+END_EXPORT
>
> Exports as:
>
> <div class="outline-text-2" id="text-1">
> * HTML only heading
> Text which should appear in HTML exports, but not \LaTeX{}.
> </div>
>
> Whereas ideally I'd like to be able to input:
>
> #+BEGIN_EXPORT html
> * HTML only heading
> Text which should appear in HTML exports, but not \LaTeX{}.
> #+END_EXPORT
>
> that would export as:
>
> <div id="outline-container-org2295e90" class="outline-2">
>  <h2 id="org2295e90"><span class="section-number-2">2</span> HTML only 
> heading</h2>
>  <div class="outline-text-2" id="text-2">
>  <p>
>    Text which should appear in HTML exports, but not \LaTeX{}.
>  </p>
>  </div>
> </div>
>

Run this:

#+BEGIN_SRC emacs-lisp :eval never-export :exports none
   (require 'ob-org)
   (defun eval-if-html ()
     (if (not (eq org-export-current-backend 'html)) "never"))
#+END_SRC


Then export this with the html backend:

#+OPTIONS: toc:nil

#+BEGIN_SRC org :eval (eval-if-html) :exports results :results replace
   ,* HTML only heading
   Text which should appear in HTML exports, but not \LaTeX{}.
#+END_SRC

and you will get this:

<div id="outline-container-org1e9ad24" class="outline-2">
<h2 id="org1e9ad24"><span class="section-number-2">1</span> HTML only 
heading</h2>
<div class="outline-text-2" id="text-1">
<p>
Text which should appear in HTML exports, but not \LaTeX{}.
</p>
</div>
</div>

With other backends you get nothing.

HTH,

Chuck

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Bug: Unable to nest headings within export blocks [9.0 (9.0-elpa @ c:/Data/Documents/emacs.d/elpa/org-20161102/)]
  2016-11-07 16:44     ` Charles C. Berry
@ 2016-11-09  4:51       ` Lixin Chin
  0 siblings, 0 replies; 6+ messages in thread
From: Lixin Chin @ 2016-11-09  4:51 UTC (permalink / raw)
  To: Charles C. Berry; +Cc: emacs-orgmode

On Mon, 7 Nov 2016 08:44:47 -0800
"Charles C. Berry" <ccberry@ucsd.edu> wrote:

> Run this:
> 
> #+BEGIN_SRC emacs-lisp :eval never-export :exports none
>    (require 'ob-org)
>    (defun eval-if-html ()
>      (if (not (eq org-export-current-backend 'html)) "never"))
> #+END_SRC
> 
> 
> Then export this with the html backend:
> 
> #+OPTIONS: toc:nil
> 
> #+BEGIN_SRC org :eval (eval-if-html) :exports results :results replace
>    ,* HTML only heading
>    Text which should appear in HTML exports, but not \LaTeX{}.
> #+END_SRC
> 
> and you will get this:
> 
> <div id="outline-container-org1e9ad24" class="outline-2">
> <h2 id="org1e9ad24"><span class="section-number-2">1</span> HTML only 
> heading</h2>
> <div class="outline-text-2" id="text-1">
> <p>
> Text which should appear in HTML exports, but not \LaTeX{}.
> </p>
> </div>
> </div>
> 
> With other backends you get nothing.
> 
> HTH,
> 
> Chuck

Thank you very much, that works perfectly!

For future reference, I tweaked the source code block to allow
specifying multiple export backends, and to avoid generating results
when evaluating using C-c C-c:

#+BEGIN_SRC emacs-lisp :eval never-export :exports none :results silent
  (require 'cl-extra)
  (defun eval-if-export (backend)
    "For use within org-mode source blocks :eval argument. Causes
  the block to be evaluated if the current export backend matches
  any of the backends in BACKEND. (e.g., (eval-if-export '(latex
  html)))."
    (unless (cl-some (lambda (back) (eq org-export-current-backend
back))
                      backend)
      "never"))
#+END_SRC

Then using:
#+BEGIN_SRC org :eval (eval-if-export '(html)) :exports
results :results replace
  ,* HTML only heading
  Text which should appear in HTML exports, but not \LaTeX{}.
#+END_SRC

The syntax isn't as elegant as #+BEGIN_EXPORT <backend> ...
#+END_EXPORT, but it works nicely enough.

Thanks,
Lixin

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-11-09  4:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-03  3:47 Bug: Unable to nest headings within export blocks [9.0 (9.0-elpa @ c:/Data/Documents/emacs.d/elpa/org-20161102/)] Lixin Chin
2016-11-03  5:20 ` Lixin Chin
2016-11-05  7:41 ` Nicolas Goaziou
2016-11-07  2:47   ` Lixin Chin
2016-11-07 16:44     ` Charles C. Berry
2016-11-09  4:51       ` Lixin Chin

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