I have the same problem.

It occurs on a 2nd pass through org-export-blocks-preprocess (in
org-exp-blocks.el).

1st pass runs OK, 2nd pass gets the error condition.

1st pass processes the following:

   (buffer-substring match-start (point-max)) ->
   "#+begin_src emacs-lisp\n  (message \"Hello, World!\")\n#+end_src\n"

2nd pass processes an emptied skeleton of the block

   (buffer-substring match-start (point-max)) ->
   "#+begin_src emacs-lisp\n#+end_src\n"

And fails to balance begin with end.

At this point in the code, the regular expression for matching
begin/end contains (I made ^M and tab visible here):

  inner-re  =   "[\r\n][\t ]*#\\+\\(begin\\|end\\)_src"

And this expression fails right away:

  (re-search-forward inner-re nil t)  ->  nil

I'll try to dig further into what's goning on.

Regards,
.j.

On Mon, Dec 12, 2011 at 09:54:18AM +0100, Christian Moe wrote:
> Hi,
>
> Here's a minimal document:
>
> ----BEGIN EXAMPLE----
>
> #+title: Testing
>
> * Src blocks
>
> Here's some Lisp:
>
> #+begin_src emacs-lisp
>   (message "Hello world!")
> #+end_src
>
> ----END EXAMPLE----
>
> When I try to export the "Src blocks" subtree to PDF via LaTeX, I
> get the error:
>
> "unbalanced begin/end_src blocks"
>
> Export of the whole document to PDF via LaTeX is not affected.
>
> Neither, initially, is HTML export, including subtree export to
> HTML. However, after getting an error by trying to export the
> subtree to LaTeX, I get the same error when trying to export to HTML
> (whether subtree or the whole document). I can "clear" the HTML
> export error by exporting the whole document via LaTeX again.

Reply via email to