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