* [PATCH] lists and exportation to latex
@ 2010-06-13 23:25 Nicolas Goaziou
2010-06-14 7:40 ` Nicolas Goaziou
0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2010-06-13 23:25 UTC (permalink / raw)
To: Org Mode List
[-- Attachment #1: Type: text/plain, Size: 572 bytes --]
Hello,
Here is a patch making latex exporter smarter about lists.
Here is a (vicious) example of what can be exported now.
------------------------------------------------------------------
1. A very long line with a mathematical environment at its end \(x =
25 \)
#+BEGIN_EXAMPLE
3. three
4. four
#+END_EXAMPLE
2. Another line
------------------------------------------------------------------
Exporting to html is still a problem though : it doesn't seem to use
org-list-to-html (and thus org-list-parse-list) from org-list.el.
-- Nicolas
[-- Attachment #2: 0001-Fix-and-improve-list-exporting-to-latex.patch --]
[-- Type: application/octet-stream, Size: 2441 bytes --]
From 2ab59460aee0dab79b199a3c0a9a144ef5e4a34f Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
Date: Mon, 14 Jun 2010 01:04:47 +0200
Subject: [PATCH] Fix and improve list exporting to latex.
* lisp/org-latex.el: items are no longer skipped when their first line
ends on a protected element.
* lisp/org-list.el: protected environments looking like lists are not
exported anymore.
---
lisp/org-latex.el | 29 ++++++++++++++---------------
lisp/org-list.el | 2 +-
2 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/lisp/org-latex.el b/lisp/org-latex.el
index edc05c6..01a4b05 100644
--- a/lisp/org-latex.el
+++ b/lisp/org-latex.el
@@ -2188,21 +2188,20 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
"Convert plain text lists in current buffer into LaTeX lists."
(let (res)
(goto-char (point-min))
- (while (re-search-forward org-list-beginning-re nil t)
- (org-if-unprotected
- (beginning-of-line)
- (setq res (org-list-to-latex (org-list-parse-list t)
- org-export-latex-list-parameters))
- (while (string-match "^\\(\\\\item[ \t]+\\)\\[@start:\\([0-9]+\\)\\]"
- res)
- (setq res (replace-match
- (concat (format "\\setcounter{enumi}{%d}"
- (1- (string-to-number
- (match-string 2 res))))
- "\n"
- (match-string 1 res))
- t t res)))
- (insert res "\n")))))
+ (while (org-re-search-forward-unprotected org-list-beginning-re nil t)
+ (beginning-of-line)
+ (setq res (org-list-to-latex (org-list-parse-list t)
+ org-export-latex-list-parameters))
+ (while (string-match "^\\(\\\\item[ \t]+\\)\\[@start:\\([0-9]+\\)\\]"
+ res)
+ (setq res (replace-match
+ (concat (format "\\setcounter{enumi}{%d}"
+ (1- (string-to-number
+ (match-string 2 res))))
+ "\n"
+ (match-string 1 res))
+ t t res)))
+ (insert res "\n"))))
(defconst org-latex-entities
'("\\!"
diff --git a/lisp/org-list.el b/lisp/org-list.el
index 938391d..2aacd09 100644
--- a/lisp/org-list.el
+++ b/lisp/org-list.el
@@ -1170,7 +1170,7 @@ sublevels as a list of strings."
(match-beginning 0)) end))))
(item (buffer-substring
(point)
- (or (and (re-search-forward
+ (or (and (org-re-search-forward-unprotected
org-list-beginning-re end t)
(goto-char (match-beginning 0)))
(goto-char end))))
--
1.7.1
[-- Attachment #3: Type: text/plain, Size: 201 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] lists and exportation to latex
2010-06-13 23:25 [PATCH] lists and exportation to latex Nicolas Goaziou
@ 2010-06-14 7:40 ` Nicolas Goaziou
2010-06-14 17:32 ` Eric Schulte
0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2010-06-14 7:40 UTC (permalink / raw)
To: emacs-orgmode
The example illustrating the patch should be :
------------------------------------------------------------------
1. A very long line with a mathematical environment at its end \(x =
25 \)
#+BEGIN_EXAMPLE
3. three
4. four
#+END_EXAMPLE
2. Another line
------------------------------------------------------------------
-- Nicolas
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Re: [PATCH] lists and exportation to latex
2010-06-14 7:40 ` Nicolas Goaziou
@ 2010-06-14 17:32 ` Eric Schulte
2010-06-14 18:10 ` Eric Schulte
0 siblings, 1 reply; 9+ messages in thread
From: Eric Schulte @ 2010-06-14 17:32 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
Hi Nicolas,
This patch looks great. Since it's >10 lines long, I must ask if you've
signed the FSF papers for contributions to Emacs? If not is that
something you're willing to do?
http://orgmode.org/worg/org-contribute.php
Thanks -- Eric
Nicolas Goaziou <n.goaziou@gmail.com> writes:
> The example illustrating the patch should be :
>
> ------------------------------------------------------------------
> 1. A very long line with a mathematical environment at its end \(x =
> 25 \)
>
> #+BEGIN_EXAMPLE
> 3. three
> 4. four
> #+END_EXAMPLE
>
> 2. Another line
> ------------------------------------------------------------------
>
> -- Nicolas
>
>
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Re: [PATCH] lists and exportation to latex
2010-06-14 17:32 ` Eric Schulte
@ 2010-06-14 18:10 ` Eric Schulte
2010-06-14 20:07 ` [PATCH] comments exporting Nicolas Goaziou
0 siblings, 1 reply; 9+ messages in thread
From: Eric Schulte @ 2010-06-14 18:10 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
A potentially related issue,
The following org-mode snippet doesn't export correctly to latex,
presumably because of protection issues similar to those addressed in
your patch. Any ideas?
--8<---------------cut here---------------start------------->8---
** comments not commented
# $some stuff
# some more stuff$ -- I should be a comment line
--8<---------------cut here---------------end--------------->8---
Best -- Eric
"Eric Schulte" <schulte.eric@gmail.com> writes:
> Hi Nicolas,
>
> This patch looks great. Since it's >10 lines long, I must ask if you've
> signed the FSF papers for contributions to Emacs? If not is that
> something you're willing to do?
>
> http://orgmode.org/worg/org-contribute.php
>
> Thanks -- Eric
>
> Nicolas Goaziou <n.goaziou@gmail.com> writes:
>
>> The example illustrating the patch should be :
>>
>> ------------------------------------------------------------------
>> 1. A very long line with a mathematical environment at its end \(x =
>> 25 \)
>>
>> #+BEGIN_EXAMPLE
>> 3. three
>> 4. four
>> #+END_EXAMPLE
>>
>> 2. Another line
>> ------------------------------------------------------------------
>>
>> -- Nicolas
>>
>>
>>
>>
>>
>> _______________________________________________
>> Emacs-orgmode mailing list
>> Please use `Reply All' to send replies to the list.
>> Emacs-orgmode@gnu.org
>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] comments exporting
2010-06-14 18:10 ` Eric Schulte
@ 2010-06-14 20:07 ` Nicolas Goaziou
2010-06-14 21:36 ` Eric Schulte
0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2010-06-14 20:07 UTC (permalink / raw)
To: Eric Schulte; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1123 bytes --]
>>>>> Eric Schulte writes:
> A potentially related issue,
> The following org-mode snippet doesn't export correctly to latex,
> presumably because of protection issues similar to those addressed in
> your patch. Any ideas?
> --8<---------------cut here---------------start------------->8---
> ** comments not commented
> # $some stuff
> # some more stuff$ -- I should be a comment line
> --8<---------------cut here---------------end--------------->8---
Yes.
Actually, the latex stuff is processed before taking care of comments
(one of the last actions in every exporter). So the $...$ snippet is
matched by org-latex and protected.
This patch removes protection check from comment deletion : something
in comment must not be exported anyway. I don't see any corner case
right now.
>> This patch looks great. Since it's >10 lines long, I must ask if you've
>> signed the FSF papers for contributions to Emacs? If not is that
>> something you're willing to do?
I have sent the signed papers last Wednesday (I had to since my patch
for org-babel-asymptote). I'm now waiting for their mail.
Regards,
--
Nicolas
[-- Attachment #2: 0001-Fix-comments-export-in-latex.patch --]
[-- Type: application/octet-stream, Size: 1456 bytes --]
From 39ba2f56b2e865c3c73352184aa9b7e891e09a5c Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
Date: Mon, 14 Jun 2010 21:54:08 +0200
Subject: [PATCH] Fix comments export in latex.
* lisp/org-exp.el: comment regexp now matches documentation. No more
protection check when deleting comments before export.
---
lisp/org-exp.el | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/lisp/org-exp.el b/lisp/org-exp.el
index 915e1f5..25ec663 100644
--- a/lisp/org-exp.el
+++ b/lisp/org-exp.el
@@ -1637,7 +1637,7 @@ table line. If it is a link, add it to the line containing the link."
"Remove comments, or convert to backend-specific format.
COMMENTSP can be a format string for publishing comments.
When it is nil, all comments will be removed."
- (let ((re "^\\(#\\|[ \t]*#\\+\\)\\(.*\n?\\)")
+ (let ((re "^\\(#\\|[ \t]*#\\+ \\)\\(.*\n?\\)")
pos)
(goto-char (point-min))
(while (or (looking-at re)
@@ -1649,9 +1649,8 @@ When it is nil, all comments will be removed."
(match-beginning 0) (match-end 0) '(org-protected t))
(replace-match (format commentsp (match-string 2)) t t))
(goto-char (1+ pos))
- (org-if-unprotected
- (replace-match "")
- (goto-char (max (point-min) (1- pos))))))))
+ (replace-match "")
+ (goto-char (max (point-min) (1- pos)))))))
(defun org-export-mark-radio-links ()
"Find all matches for radio targets and turn them into internal links."
--
1.7.1
[-- Attachment #3: Type: text/plain, Size: 201 bytes --]
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] comments exporting
2010-06-14 20:07 ` [PATCH] comments exporting Nicolas Goaziou
@ 2010-06-14 21:36 ` Eric Schulte
2010-06-15 13:03 ` Nicolas Goaziou
0 siblings, 1 reply; 9+ messages in thread
From: Eric Schulte @ 2010-06-14 21:36 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
Hi Nicolas,
Nicolas Goaziou <n.goaziou@gmail.com> writes:
>>>>>> Eric Schulte writes:
>
>> A potentially related issue,
>> The following org-mode snippet doesn't export correctly to latex,
>> presumably because of protection issues similar to those addressed in
>> your patch. Any ideas?
>
>> --8<---------------cut here---------------start------------->8---
>> ** comments not commented
>
>> # $some stuff
>> # some more stuff$ -- I should be a comment line
>> --8<---------------cut here---------------end--------------->8---
>
> Yes.
>
> Actually, the latex stuff is processed before taking care of comments
> (one of the last actions in every exporter). So the $...$ snippet is
> matched by org-latex and protected.
>
> This patch removes protection check from comment deletion : something
> in comment must not be exported anyway. I don't see any corner case
> right now.
>
Great. Thanks for the continuous flow of useful patches.
Not to look a gift patch in the mouth, but while this patch fixes the
above issue it looks like it introduces a new problem.
Before the patch the following
--8<---------------cut here---------------start------------->8---
** comments not commented
# $some stuff
# some more stuff$ -- I should be a comment line
1) a source block inside of an =enumerate=
#+source: plotxy
#+begin_src emacs-lisp :exports results
(message "I think so")
#+end_src
can cause problems
--8<---------------cut here---------------end--------------->8---
exports to
--8<---------------cut here---------------start------------->8---
\section{comments not commented}
\label{sec-1}
# some more stuff$ -- I should be a comment line
\begin{enumerate}
\item a source block inside of an \texttt{enumerate}
\begin{verbatim}
I think so
\end{verbatim}
can cause problems
\end{enumerate}
--8<---------------cut here---------------end--------------->8---
while after the patch it exports to
--8<---------------cut here---------------start------------->8---
\section{comments not commented}
\label{sec-1}
\begin{enumerate}
\item a source block inside of an \texttt{enumerate}
\#+source: plotxy
\#+results: plotxy
\begin{verbatim}
I think so
\end{verbatim}
can cause problems
\end{enumerate}
--8<---------------cut here---------------end--------------->8---
which is wrong in a different way.
>
>>> This patch looks great. Since it's >10 lines long, I must ask if you've
>>> signed the FSF papers for contributions to Emacs? If not is that
>>> something you're willing to do?
>
> I have sent the signed papers last Wednesday (I had to since my patch
> for org-babel-asymptote). I'm now waiting for their mail.
>
Oh, how forgetful of me, there's a todo in my agenda with your name on
it about checking up on the status of the FSF papers.
Thanks! -- Eric
>
> Regards,
>
> --
> Nicolas
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] comments exporting
2010-06-14 21:36 ` Eric Schulte
@ 2010-06-15 13:03 ` Nicolas Goaziou
2010-06-15 15:48 ` Eric Schulte
0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Goaziou @ 2010-06-15 13:03 UTC (permalink / raw)
To: Eric Schulte; +Cc: emacs-orgmode
Hello,
>>>>> Eric Schulte writes:
> Not to look a gift patch in the mouth, but while this patch fixes the
> above issue it looks like it introduces a new problem.
If you want a quick hack, just remove the space I introduced in the
comment regexp. But, imho, it isn't a real solution as #+source is
definitely not a comment and should not be caught by the regexp
comments.
I don't know yet what org-babel is really doing with the #+source
and #+results lines, but if they are no longer needed for exportation,
there should be a function to clean them before exporting.
In addition, there is another problem. In the example below, the
second item actually starts a brand new list upon exporting.
--8<---------------cut here---------------start------------->8---
** comments not commented
# $some stuff
# some more stuff$ -- I should be a comment line
1) a source block inside of an =enumerate=
#+source: plotxy
#+begin_src emacs-lisp :exports results
(message "I think so")
#+end_src
can cause problems
2) another line
--8<---------------cut here---------------end--------------->8---
If I had to take a guess, I'd say that org-babel messes with
indentation and org-latex, being very sensitive about indentation when
it comes to lists, gets disoriented.
So, is the result replacing the source code in the same
column as the #+begin_src ?
So I think something has to be fixed in org-babel.
I will look at it tomorrow,
Regards,
--
Nicolas
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] comments exporting
2010-06-15 13:03 ` Nicolas Goaziou
@ 2010-06-15 15:48 ` Eric Schulte
2010-06-15 16:32 ` Nicolas Goaziou
0 siblings, 1 reply; 9+ messages in thread
From: Eric Schulte @ 2010-06-15 15:48 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode
Hi Nicolas,
Thanks for the thoughtful response.
Nicolas Goaziou <n.goaziou@gmail.com> writes:
> Hello,
>>>>>> Eric Schulte writes:
>
>> Not to look a gift patch in the mouth, but while this patch fixes the
>> above issue it looks like it introduces a new problem.
>
> If you want a quick hack, just remove the space I introduced in the
> comment regexp. But, imho, it isn't a real solution as #+source is
> definitely not a comment and should not be caught by the regexp
> comments.
>
yes, I suppose so. When our #+source and #+results statements always
started on column zero they were being cleaned up later in the export
cycle so this wasn't a problem.
>
> I don't know yet what org-babel is really doing with the #+source
> and #+results lines, but if they are no longer needed for exportation,
> there should be a function to clean them before exporting.
>
Agreed, I'll take a look at this org-babel pre-processing later today
and add in functionality to clean up #+source: and #+results: lines.
>
> In addition, there is another problem. In the example below, the
> second item actually starts a brand new list upon exporting.
>
This problem I can't reproduce.
>
> ** comments not commented
> # $some stuff
> # some more stuff$ -- I should be a comment line
>
> 1) a source block inside of an =enumerate=
> #+source: plotxy
> #+begin_src emacs-lisp :exports results
> (message "I think so")
> #+end_src
>
> can cause problems
>
> 2) another line
>
after Org-babel pre-processing the above is converted to the following
for me
--8<---------------cut here---------------start------------->8---
# $some stuff
# some more stuff$ -- I should be a comment line
1) a source block inside of an =enumerate=
#+source: plotxy
#+results: plotxy
: I think so
can cause problems
2) another line
--8<---------------cut here---------------end--------------->8---
which exports to latex as expected.
Hopefully after I've made the above changes this list interruption will
cease, if not then I'll need to find an example I can reproduce.
>
>
> If I had to take a guess, I'd say that org-babel messes with
> indentation and org-latex, being very sensitive about indentation when
> it comes to lists, gets disoriented.
>
> So, is the result replacing the source code in the same
> column as the #+begin_src ?
>
yup, it's the same column, the only possible culprit I can see is two
empty lines (notice those are not indented but are truly empty) between
the #+source and #+results lines.
>
> So I think something has to be fixed in org-babel.
>
> I will look at it tomorrow,
>
> Regards,
Thanks, as always, for your help -- Eric
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] comments exporting
2010-06-15 15:48 ` Eric Schulte
@ 2010-06-15 16:32 ` Nicolas Goaziou
0 siblings, 0 replies; 9+ messages in thread
From: Nicolas Goaziou @ 2010-06-15 16:32 UTC (permalink / raw)
To: Eric Schulte; +Cc: emacs-orgmode
Hi,
>>>>> Eric Schulte writes:
> This problem I can't reproduce.
My bad. I wasn't on git head. There is no such problem anymore. After
you've made your changes, all should be set, hopefully.
Regards,
-- Nicolas
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2010-06-15 16:39 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-13 23:25 [PATCH] lists and exportation to latex Nicolas Goaziou
2010-06-14 7:40 ` Nicolas Goaziou
2010-06-14 17:32 ` Eric Schulte
2010-06-14 18:10 ` Eric Schulte
2010-06-14 20:07 ` [PATCH] comments exporting Nicolas Goaziou
2010-06-14 21:36 ` Eric Schulte
2010-06-15 13:03 ` Nicolas Goaziou
2010-06-15 15:48 ` Eric Schulte
2010-06-15 16:32 ` Nicolas Goaziou
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).