emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] HTML exporting numbered literal examples
@ 2009-07-09 10:44 Ulf Stegemann
  2009-07-16 19:43 ` Bastien
  2009-08-03  4:27 ` Carsten Dominik
  0 siblings, 2 replies; 10+ messages in thread
From: Ulf Stegemann @ 2009-07-09 10:44 UTC (permalink / raw)
  To: emacs-orgmode

With latest CVS Emacs and Git Org mode exporting literal examples
(example/src) with the `-n' switch results in numbering starting on line
*2* of the example in the resulting HTML file (LaTeX seems to be okay).

The example in the manual ...

--8<--------------------------snip-------------------------->8---
  #+BEGIN_SRC emacs-lisp -n -r
  (save-excursion                  (ref:sc)
     (goto-char (point-min))       (ref:jump)
  #+END_SRC
  In line [[(sc)]] we remember the current positon.  [[(jump)][Line (jump)]]
  jumps to point-min.
--8<--------------------------snap-------------------------->8---

... (which is BTW not working as the manual misses the underscore in
`#+END_SRC') results (visually) in

--8<--------------------------snip-------------------------->8---
(save-excursion                  (ref:sc)
1:     (goto-char (point-min))
--8<--------------------------snap-------------------------->8---

with reference `sc' broken.

Can anyone reproduce this?

And while we are at it: Would it be feasible to have `-r' in literal
examples even without `-n', thus removing the label in the source code
block even if the example is not numbered. I have no concrete case where
this may be necessary but I think that usually labels shouldn't be
displayed in /literal/ examples.

Ulf

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

* Re: [BUG] HTML exporting numbered literal examples
  2009-07-09 10:44 [BUG] HTML exporting numbered literal examples Ulf Stegemann
@ 2009-07-16 19:43 ` Bastien
  2009-07-17 10:10   ` Ulf Stegemann
  2009-08-03  4:27 ` Carsten Dominik
  1 sibling, 1 reply; 10+ messages in thread
From: Bastien @ 2009-07-16 19:43 UTC (permalink / raw)
  To: Ulf Stegemann; +Cc: emacs-orgmode

Ulf Stegemann <ulf-news@zeitform.de> writes:

> With latest CVS Emacs and Git Org mode exporting literal examples
> (example/src) with the `-n' switch results in numbering starting on line
> *2* of the example in the resulting HTML file (LaTeX seems to be okay).
>
> The example in the manual ...
>
> --8<--------------------------snip-------------------------->8---
>   #+BEGIN_SRC emacs-lisp -n -r
>   (save-excursion                  (ref:sc)
>      (goto-char (point-min))       (ref:jump)
>   #+END_SRC
>   In line [[(sc)]] we remember the current positon.  [[(jump)][Line (jump)]]
>   jumps to point-min.
> --8<--------------------------snap-------------------------->8---
>
> ... (which is BTW not working as the manual misses the underscore in
> `#+END_SRC') results (visually) in

Fixed in the manual.

> --8<--------------------------snip-------------------------->8---
> (save-excursion                  (ref:sc)
> 1:     (goto-char (point-min))
> --8<--------------------------snap-------------------------->8---
>
> with reference `sc' broken.
>
> Can anyone reproduce this?

Yes.  And I just pushed fix for that.

> And while we are at it: Would it be feasible to have `-r' in literal
> examples even without `-n', thus removing the label in the source code
> block even if the example is not numbered. I have no concrete case where
> this may be necessary but I think that usually labels shouldn't be
> displayed in /literal/ examples.

For this I have no idea - it looks like we can wait for "concrete
examples" :)

-- 
 Bastien

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

* Re: [BUG] HTML exporting numbered literal examples
  2009-07-16 19:43 ` Bastien
@ 2009-07-17 10:10   ` Ulf Stegemann
  2009-07-17 14:50     ` Bastien
  0 siblings, 1 reply; 10+ messages in thread
From: Ulf Stegemann @ 2009-07-17 10:10 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

Bastien <bastienguerry@googlemail.com> wrote:

> Ulf Stegemann <ulf-news@zeitform.de> writes:
>
>> With latest CVS Emacs and Git Org mode exporting literal examples
>> (example/src) with the `-n' switch results in numbering starting on line
>> *2* of the example in the resulting HTML file (LaTeX seems to be okay).
>>
>> The example in the manual ...
>>
>> --8<--------------------------snip-------------------------->8---
>>   #+BEGIN_SRC emacs-lisp -n -r
>>   (save-excursion                  (ref:sc)
>>      (goto-char (point-min))       (ref:jump)
>>   #+END_SRC
>>   In line [[(sc)]] we remember the current positon.  [[(jump)][Line (jump)]]
>>   jumps to point-min.
>> --8<--------------------------snap-------------------------->8---
>>
>> ... (which is BTW not working as the manual misses the underscore in
>> `#+END_SRC') results (visually) in
>
> Fixed in the manual.

great, thanks!

>> --8<--------------------------snip-------------------------->8---
>> (save-excursion                  (ref:sc)
>> 1:     (goto-char (point-min))
>> --8<--------------------------snap-------------------------->8---
>>
>> with reference `sc' broken.
>>
>> Can anyone reproduce this?
>
> Yes.  And I just pushed fix for that.

dto. seems to work now as expected.

>> And while we are at it: Would it be feasible to have `-r' in literal
>> examples even without `-n', thus removing the label in the source code
>> block even if the example is not numbered. I have no concrete case where
>> this may be necessary but I think that usually labels shouldn't be
>> displayed in /literal/ examples.
>
> For this I have no idea - it looks like we can wait for "concrete
> examples" :)

I think, those examples are easy to make up.  Line numbers are great for
file contents and maybe input /or/ output.  But as soon as in- and output
are mixed up I find them rather disturbing (imagine e.g. a shell
session).  On the other hand removing labels and having that nice
highlighting feature with HTML exported files maybe useful in either
case.

I had a quick look at `org-export-number-lines' and the following seems
to work smoothly ...

--8<--------------------------snip-------------------------->8---

--- org-exp.el.orig	2009-07-17 11:56:22.000000000 +0200
+++ org-exp.el	2009-07-17 11:57:30.000000000 +0200
@@ -2293,8 +2293,6 @@
 (defun org-export-number-lines (text backend
 				     &optional skip1 skip2 number cont
 				     replace-labels label-format)
-  (if (and (not number) (not (eq replace-labels 'keep)))
-      (setq replace-labels nil)) ;; must use names if no numbers
   (setq skip1 (or skip1 0) skip2 (or skip2 0))
   (if (not cont) (setq org-export-last-code-line-counter-value 0))
   (with-temp-buffer
@@ -2342,7 +2340,7 @@
 	  (if replace-labels
 	      (progn
 		(delete-region (match-beginning 1) (match-end 1))
-		(push (cons ref n) org-export-code-refs))
+		(push (cons ref (if (> n 0) n ref)) org-export-code-refs))
 	    (goto-char (match-beginning 2))
 	    (delete-region (match-beginning 2) (match-end 2))
 	    (insert "(" ref ")")

--8<--------------------------snap-------------------------->8---

Ulf

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

* Re: Re: [BUG] HTML exporting numbered literal examples
  2009-07-17 10:10   ` Ulf Stegemann
@ 2009-07-17 14:50     ` Bastien
  2009-07-17 21:08       ` Ulf Stegemann
  0 siblings, 1 reply; 10+ messages in thread
From: Bastien @ 2009-07-17 14:50 UTC (permalink / raw)
  To: Ulf Stegemann; +Cc: emacs-orgmode

Ulf Stegemann <ulf-news@zeitform.de> writes:

> I think, those examples are easy to make up.  Line numbers are great for
> file contents and maybe input /or/ output.  But as soon as in- and output
> are mixed up I find them rather disturbing (imagine e.g. a shell
> session).  On the other hand removing labels and having that nice
> highlighting feature with HTML exported files maybe useful in either
> case.

I understand...

> I had a quick look at `org-export-number-lines' and the following seems
> to work smoothly ...

Thanks for the patch.  One problem though: now the first link (from the
manuals example) looks like "sc" but there is no "sc" left in the source
code.  This is a bit confusing, no?  So if we plan to make references to
lines of code, it make sense to have either the line numbering or the
labels (or both).  What do you think?

-- 
 Bastien

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

* Re: [BUG] HTML exporting numbered literal examples
  2009-07-17 14:50     ` Bastien
@ 2009-07-17 21:08       ` Ulf Stegemann
  2009-07-18  7:15         ` Bastien
  0 siblings, 1 reply; 10+ messages in thread
From: Ulf Stegemann @ 2009-07-17 21:08 UTC (permalink / raw)
  To: emacs-orgmode

Bastien <bastienguerry@googlemail.com> wrote:

> Ulf Stegemann <ulf-news@zeitform.de> writes:
>
>> I had a quick look at `org-export-number-lines' and the following seems
>> to work smoothly ...
>
> Thanks for the patch.  One problem though: now the first link (from the
> manuals example) looks like "sc" but there is no "sc" left in the source
> code.  This is a bit confusing, no?  So if we plan to make references to
> lines of code, it make sense to have either the line numbering or the
> labels (or both).  What do you think?

Right, I agree with your observation but I think I wouldn't with your
conclusion.  I don't think that this is a problem.  From the author's
point of view I think he/she knows what's going on since this is not the
default behaviour and the `-r' switch actually has to be added.  And
after all we are talking about links.  And as with any other link if the
link target is self-explanatory: fine, then I can use it as link name.  If
it is not, I should choose something less confusing for the reader.
Translated to the situation we have here this means: I can choose a
self-explanatory reference and use this or I can give the link a label
with a clear indication of what the link is about.

From the reader's point of view there's no confusion either because
he/she can always follow the link and see where this leads.

I absolutely second that confusing behaviour should be avoided whenever
possible but I don't think any confusion will occur here.

Ulf

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

* Re: Re: [BUG] HTML exporting numbered literal examples
  2009-07-17 21:08       ` Ulf Stegemann
@ 2009-07-18  7:15         ` Bastien
  2009-07-20 11:36           ` Ulf Stegemann
  0 siblings, 1 reply; 10+ messages in thread
From: Bastien @ 2009-07-18  7:15 UTC (permalink / raw)
  To: Ulf Stegemann; +Cc: emacs-orgmode

Ulf Stegemann <ulf-news@zeitform.de> writes:

> Right, I agree with your observation but I think I wouldn't with your
> conclusion.  I don't think that this is a problem.  From the author's
> point of view I think he/she knows what's going on since this is not the
> default behaviour and the `-r' switch actually has to be added.  And
> after all we are talking about links.  And as with any other link if the
> link target is self-explanatory: fine, then I can use it as link name.  If
> it is not, I should choose something less confusing for the reader.

One problem is the limitation about labels you can use.  E.g. labels do
not allow whitespaces.  It is hard to write meaningful self-explanatory
link names without using whitespaces.

I will see if I can overcome this in a clean way.

Thanks!

-- 
 Bastien

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

* Re: [BUG] HTML exporting numbered literal examples
  2009-07-18  7:15         ` Bastien
@ 2009-07-20 11:36           ` Ulf Stegemann
  2009-07-23 19:58             ` Bastien
  0 siblings, 1 reply; 10+ messages in thread
From: Ulf Stegemann @ 2009-07-20 11:36 UTC (permalink / raw)
  To: emacs-orgmode

Bastien <bastienguerry@googlemail.com> wrote:

> Ulf Stegemann <ulf-news@zeitform.de> writes:
>
>> Right, I agree with your observation but I think I wouldn't with your
>> conclusion.  I don't think that this is a problem.  From the author's
>> point of view I think he/she knows what's going on since this is not the
>> default behaviour and the `-r' switch actually has to be added.  And
>> after all we are talking about links.  And as with any other link if the
>> link target is self-explanatory: fine, then I can use it as link name.  If
>> it is not, I should choose something less confusing for the reader.
>
> One problem is the limitation about labels you can use.  E.g. labels do
> not allow whitespaces.  It is hard to write meaningful self-explanatory
> link names without using whitespaces.

Ah okay, that is a good point indeed.  I wasn't aware of the fact that
labels could not contain whitespaces.

> I will see if I can overcome this in a clean way.

That would be great. Thanks for your efforts!

Ulf

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

* Re: Re: [BUG] HTML exporting numbered literal examples
  2009-07-20 11:36           ` Ulf Stegemann
@ 2009-07-23 19:58             ` Bastien
  2009-07-24  6:38               ` Ulf Stegemann
  0 siblings, 1 reply; 10+ messages in thread
From: Bastien @ 2009-07-23 19:58 UTC (permalink / raw)
  To: Ulf Stegemann; +Cc: emacs-orgmode

Hi Ulf,

I've finally pushed a change that allows whitespaces in labels and allow
the "-r" switch to be used even if "-n" is not there. Please test it and
let me know if it works as expected.

Thanks,

Ulf Stegemann <ulf-news@zeitform.de> writes:

>>> conclusion.  I don't think that this is a problem.  From the author's
>>> point of view I think he/she knows what's going on since this is not the
>>> default behaviour and the `-r' switch actually has to be added.  And
>>> after all we are talking about links.  And as with any other link if the
>>> link target is self-explanatory: fine, then I can use it as link name.  If
>>> it is not, I should choose something less confusing for the reader.
>>
>> One problem is the limitation about labels you can use.  E.g. labels do
>> not allow whitespaces.  It is hard to write meaningful self-explanatory
>> link names without using whitespaces.
>
> Ah okay, that is a good point indeed.  I wasn't aware of the fact that
> labels could not contain whitespaces.
>
>> I will see if I can overcome this in a clean way.
>
> That would be great. Thanks for your efforts!
>
> Ulf

-- 
 Bastien

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

* Re: [BUG] HTML exporting numbered literal examples
  2009-07-23 19:58             ` Bastien
@ 2009-07-24  6:38               ` Ulf Stegemann
  0 siblings, 0 replies; 10+ messages in thread
From: Ulf Stegemann @ 2009-07-24  6:38 UTC (permalink / raw)
  To: emacs-orgmode

Hi Bastien,

Bastien <bastienguerry@googlemail.com> wrote:

> I've finally pushed a change that allows whitespaces in labels and allow
> the "-r" switch to be used even if "-n" is not there. Please test it and
> let me know if it works as expected.

great! I've tested this with some examples and it seems to work fine.
Thanks for adding this feature :)

Ulf

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

* Re: [BUG] HTML exporting numbered literal examples
  2009-07-09 10:44 [BUG] HTML exporting numbered literal examples Ulf Stegemann
  2009-07-16 19:43 ` Bastien
@ 2009-08-03  4:27 ` Carsten Dominik
  1 sibling, 0 replies; 10+ messages in thread
From: Carsten Dominik @ 2009-08-03  4:27 UTC (permalink / raw)
  To: Ulf Stegemann; +Cc: emacs-orgmode

Fixed, thanks.

- Carsten

On Jul 9, 2009, at 12:44 PM, Ulf Stegemann wrote:

> With latest CVS Emacs and Git Org mode exporting literal examples
> (example/src) with the `-n' switch results in numbering starting on  
> line
> *2* of the example in the resulting HTML file (LaTeX seems to be  
> okay).
>
> The example in the manual ...
>
> --8<--------------------------snip-------------------------->8---
>  #+BEGIN_SRC emacs-lisp -n -r
>  (save-excursion                  (ref:sc)
>     (goto-char (point-min))       (ref:jump)
>  #+END_SRC
>  In line [[(sc)]] we remember the current positon.  [[(jump)][Line  
> (jump)]]
>  jumps to point-min.
> --8<--------------------------snap-------------------------->8---
>
> ... (which is BTW not working as the manual misses the underscore in
> `#+END_SRC') results (visually) in
>
> --8<--------------------------snip-------------------------->8---
> (save-excursion                  (ref:sc)
> 1:     (goto-char (point-min))
> --8<--------------------------snap-------------------------->8---
>
> with reference `sc' broken.
>
> Can anyone reproduce this?
>
> And while we are at it: Would it be feasible to have `-r' in literal
> examples even without `-n', thus removing the label in the source code
> block even if the example is not numbered. I have no concrete case  
> where
> this may be necessary but I think that usually labels shouldn't be
> displayed in /literal/ examples.
>
> Ulf
>
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Remember: 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] 10+ messages in thread

end of thread, other threads:[~2009-08-03  4:27 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-09 10:44 [BUG] HTML exporting numbered literal examples Ulf Stegemann
2009-07-16 19:43 ` Bastien
2009-07-17 10:10   ` Ulf Stegemann
2009-07-17 14:50     ` Bastien
2009-07-17 21:08       ` Ulf Stegemann
2009-07-18  7:15         ` Bastien
2009-07-20 11:36           ` Ulf Stegemann
2009-07-23 19:58             ` Bastien
2009-07-24  6:38               ` Ulf Stegemann
2009-08-03  4:27 ` Carsten Dominik

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