From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thibault Marin Subject: Possible bug with coderef highlighting in HTML export Date: Sun, 03 Dec 2017 04:35:30 -0600 Message-ID: <87lgikp099.fsf@dell-desktop.WORKGROUP> Reply-To: thibault.marin@gmx.com Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38145) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eLRcb-0006OX-1Z for emacs-orgmode@gnu.org; Sun, 03 Dec 2017 05:35:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eLRcW-0000uV-3z for emacs-orgmode@gnu.org; Sun, 03 Dec 2017 05:35:41 -0500 Received: from mout.gmx.net ([212.227.17.21]:56660) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eLRcV-0000ty-QD for emacs-orgmode@gnu.org; Sun, 03 Dec 2017 05:35:36 -0500 Received: from dell-desktop ([99.47.196.62]) by mail.gmx.com (mrgmx103 [212.227.17.174]) with ESMTPSA (Nemesis) id 0MJSuF-1eMpCR2xwZ-0036L5 for ; Sun, 03 Dec 2017 11:35:32 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: org mode Hi all, I am using Org mode version 9.1.3 (release_9.1.3-216-g259656 @ /.../org-mode/lisp/) and I am experiencing an issue with the exported HTML of the following org file: ,---- | this links get highlighted [[(link0)]]. | | this link does not get highlighted [[(link1)]]. | | #+begin_src emacs-lisp -r | 0(ref:link0) | #+end_src | | #+begin_src emacs-lisp -r | | 1(ref:link1) | #+end_src `---- The relevant HTML output is: ,---- |

| this links get highlighted 1. |

| |

| this link does not get highlighted 1. |

| |
|
0
| 
|
| |
|
1
| 
|
`---- The issue is that the link to the line in the second source block is not highlighted (it does not get the "coderef-off" span markup). I tried to dig a little and it appears that `org-html-do-format-code' does not handle empty lines at the beginning of a block. `(org-split-string "\n1")' returns '("1") which looses the first empty line. The line reference received via the `refs' variable (which has value ((2 . link1))) then becomes out of sync with the `code' variable (split by lines) used for formatting of the code block. I am not sure what is the best way to handle this: 1. Should the `refs' variable be built accounting for the top empty lines? 2. Alternatively, should the `org-html-do-format-code' and `org-export-format-code' functions count the number of top empty lines and adjust the line number accordingly? 3. Should top empty lines be completely deleted, before the `refs' array is built? I can try to propose a patch if the best option can be decided. Option 2 seems relatively simple but feels like a hack. I would appreciate any suggestions on how to best fix this. Thanks in advance. thibault From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Possible bug with coderef highlighting in HTML export Date: Sun, 03 Dec 2017 15:08:56 +0100 Message-ID: <877eu3dhtz.fsf@nicolasgoaziou.fr> References: <87lgikp099.fsf@dell-desktop.WORKGROUP> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37044) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eLUx6-0003qd-Uu for emacs-orgmode@gnu.org; Sun, 03 Dec 2017 09:09:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eLUx2-0004CC-58 for emacs-orgmode@gnu.org; Sun, 03 Dec 2017 09:09:04 -0500 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:45012) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eLUx1-0004Bw-VI for emacs-orgmode@gnu.org; Sun, 03 Dec 2017 09:09:00 -0500 In-Reply-To: <87lgikp099.fsf@dell-desktop.WORKGROUP> (Thibault Marin's message of "Sun, 03 Dec 2017 04:35:30 -0600") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Thibault Marin Cc: org mode Hello, Thibault Marin writes: > I am using Org mode version 9.1.3 (release_9.1.3-216-g259656 @ > /.../org-mode/lisp/) and I am experiencing an issue with the exported > HTML of the following org file: > > ,---- > | this links get highlighted [[(link0)]]. > | > | this link does not get highlighted [[(link1)]]. > | > | #+begin_src emacs-lisp -r > | 0(ref:link0) > | #+end_src > | > | #+begin_src emacs-lisp -r > | > | 1(ref:link1) > | #+end_src > `---- > > The relevant HTML output is: > > ,---- > |

> | this links get highlighted 1. > |

> | > |

> | this link does not get highlighted 1. > |

> | > |
> |
0
> | 
> |
> | > |
> |
1
> | 
> |
> `---- > > The issue is that the link to the line in the second source block is not > highlighted (it does not get the "coderef-off" span markup). Indeed. > I tried to dig a little and it appears that `org-html-do-format-code' > does not handle empty lines at the beginning of a block. > `(org-split-string "\n1")' returns '("1") which looses the first empty > line. The line reference received via the `refs' variable (which has > value ((2 . link1))) then becomes out of sync with the `code' variable > (split by lines) used for formatting of the code block. > > I am not sure what is the best way to handle this: > > 1. Should the `refs' variable be built accounting for the top empty lines? > 2. Alternatively, should the `org-html-do-format-code' and > `org-export-format-code' functions count the number of top empty lines and > adjust the line number accordingly? > 3. Should top empty lines be completely deleted, before the `refs' array is > built? > > I can try to propose a patch if the best option can be decided. Option 2 seems > relatively simple but feels like a hack. > > I would appreciate any suggestions on how to best fix this. Option 1 seems the best way to go. Replacing `org-split-string' with `split-string' is straightforward in this case. However, some issues remain in `org-html-fontify-code'. Thank you. Regards, -- Nicolas Goaziou From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thibault Marin Subject: Re: Possible bug with coderef highlighting in HTML export Date: Sun, 03 Dec 2017 18:41:42 -0600 Message-ID: <87y3mjtjcp.fsf@dell-desktop.WORKGROUP> References: <87lgikp099.fsf@dell-desktop.WORKGROUP> <877eu3dhtz.fsf@nicolasgoaziou.fr> Reply-To: thibault.marin@gmx.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eLepT-00008z-R1 for emacs-orgmode@gnu.org; Sun, 03 Dec 2017 19:41:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eLepQ-00038I-OQ for emacs-orgmode@gnu.org; Sun, 03 Dec 2017 19:41:51 -0500 Received: from mout.gmx.net ([212.227.15.19]:55734) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eLepQ-000386-DE for emacs-orgmode@gnu.org; Sun, 03 Dec 2017 19:41:48 -0500 In-reply-to: <877eu3dhtz.fsf@nicolasgoaziou.fr> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: org mode --=-=-= Content-Type: text/plain Hi, Hi the attach patch fixes the issue for me. Please let me know if you have any suggestions. As always, thanks for the guidance. thibault --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-bug-in-HTML-export-of-code-blocks-with-starting-.patch >From a78dc91c9fd1aacb2c65f66ae5afa9ee25f56e01 Mon Sep 17 00:00:00 2001 From: thibault Date: Sun, 3 Dec 2017 17:42:13 -0600 Subject: [PATCH] Fix bug in HTML export of code blocks with starting blank lines * lisp/ox-html.el (org-html-do-format-code): Preverse starting blank lines when splitting code lines (use `split-string' instead of `org-split-string'). (org-html-fontify-code): Preserve starting blank lines in returned code string. --- lisp/ox-html.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 0e22c1699..90a6cede0 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -2202,7 +2202,7 @@ https://github.com/hniksic/emacs-htmlize")) (org-html-htmlize-region-for-paste (point-min) (point-max)))))) ;; Strip any enclosing
 tags.
-	  (let* ((beg (and (string-match "\\`]*>\n*" code) (match-end 0)))
+	  (let* ((beg (and (string-match "\\`]*>\n?" code) (match-end 0)))
 		 (end (and beg (string-match "\\'" code))))
 	    (if (and beg end) (substring code beg end) code)))))))))
 
@@ -2215,7 +2215,7 @@ alist between line numbers and references (as returned by
 `org-export-unravel-code'), a boolean specifying if labels should
 appear in the source code, and the number associated to the first
 line of code."
-  (let* ((code-lines (org-split-string code "\n"))
+  (let* ((code-lines (split-string code "\n"))
 	 (code-length (length code-lines))
 	 (num-fmt
 	  (and num-start
-- 
2.14.1


--=-=-=--

From mboxrd@z Thu Jan  1 00:00:00 1970
From: Nicolas Goaziou 
Subject: Re: Possible bug with coderef highlighting in HTML export
Date: Mon, 04 Dec 2017 08:24:42 +0100
Message-ID: <87y3mj7y6d.fsf@nicolasgoaziou.fr>
References: <87lgikp099.fsf@dell-desktop.WORKGROUP>
	<877eu3dhtz.fsf@nicolasgoaziou.fr>
	<87y3mjtjcp.fsf@dell-desktop.WORKGROUP>
Mime-Version: 1.0
Content-Type: text/plain
Return-path: 
Received: from eggs.gnu.org ([2001:4830:134:3::10]:36748)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from ) id 1eLl7P-0006iB-3g
	for emacs-orgmode@gnu.org; Mon, 04 Dec 2017 02:24:47 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from ) id 1eLl7O-0003bc-42
	for emacs-orgmode@gnu.org; Mon, 04 Dec 2017 02:24:47 -0500
Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:45054)
	by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
	(Exim 4.71) (envelope-from )
	id 1eLl7N-0003YP-TQ
	for emacs-orgmode@gnu.org; Mon, 04 Dec 2017 02:24:46 -0500
In-Reply-To: <87y3mjtjcp.fsf@dell-desktop.WORKGROUP> (Thibault Marin's message
	of "Sun, 03 Dec 2017 18:41:42 -0600")
List-Id: "General discussions about Org-mode." 
List-Unsubscribe: ,
	
List-Archive: 
List-Post: 
List-Help: 
List-Subscribe: ,
	
Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org
Sender: "Emacs-orgmode"
	
To: Thibault Marin 
Cc: org mode 

Hello,

Thibault Marin  writes:

> Hi the attach patch fixes the issue for me.  Please let me know if you
> have any suggestions.

It looks good. Applied. Thank you.

Regards,

-- 
Nicolas Goaziou