From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ulf Stegemann Subject: Re: [BUG] HTML exporting numbered literal examples Date: Fri, 17 Jul 2009 12:10:39 +0200 Message-ID: References: <87r5wg8lch.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MRkP7-0008Mo-7O for emacs-orgmode@gnu.org; Fri, 17 Jul 2009 06:11:01 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MRkP2-0008LV-2C for emacs-orgmode@gnu.org; Fri, 17 Jul 2009 06:11:00 -0400 Received: from [199.232.76.173] (port=51809 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MRkP1-0008LP-NJ for emacs-orgmode@gnu.org; Fri, 17 Jul 2009 06:10:55 -0400 Received: from main.gmane.org ([80.91.229.2]:39059 helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MRkP1-0004oj-4h for emacs-orgmode@gnu.org; Fri, 17 Jul 2009 06:10:55 -0400 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MRkOw-0008Im-5L for emacs-orgmode@gnu.org; Fri, 17 Jul 2009 10:10:50 +0000 Received: from london.zeitform.net ([146.140.213.100]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 17 Jul 2009 10:10:50 +0000 Received: from ulf-news by london.zeitform.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 17 Jul 2009 10:10:50 +0000 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Hi, Bastien wrote: > Ulf Stegemann 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