From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jens Lechtenboerger Subject: [PATCH] ox-html: add option to restore old src block behaviour? Date: Sat, 21 Sep 2019 14:15:37 +0200 Message-ID: <87h8553kwm.fsf@informationelle-selbstbestimmung-im-internet.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:54095) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iBeIo-0001gx-3Y for emacs-orgmode@gnu.org; Sat, 21 Sep 2019 08:15:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iBeIm-00017s-Nt for emacs-orgmode@gnu.org; Sat, 21 Sep 2019 08:15:49 -0400 Received: from mx1.mailbox.org ([80.241.60.212]:50644) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iBeIm-00012f-DN for emacs-orgmode@gnu.org; Sat, 21 Sep 2019 08:15:48 -0400 Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id D37E34EBB2 for ; Sat, 21 Sep 2019 14:15:42 +0200 (CEST) Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id 6ki99fvvEXNN for ; Sat, 21 Sep 2019 14:15:38 +0200 (CEST) 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: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 2019-09-19, Matt Price wrote: > Over the summer, commit ded3d27b1468b878197e5fe55a70c5e13350ea27 > by Nik Clayton was merged to master. It's a one-line change that > adds new ~~ tags around each lin of code in html export of > source blocks. It's useful because it allows individual lines to > be addressed directly by CSS. > > However, at least one very common syntax highlighter, > https://highlinghtjs.org, expects just a single tag, as do > other common CSS frameworks. > [...] The attached patch adds a new variable org-html-wrap-src-lines to control whether code tags should be added or not. I=E2=80=99m not sure whether :package-version 9.3 is correct. Also, I set the value to t, which does not change the current functionality. However, for backwards compatibility (up to version 9.2.6), a value of nil would be preferable. Any thoughts? Best wishes Jens --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-ox-html-Control-source-line-wrapping.patch >From ba3130deb9dbbab3c7d293f901ff08be839a8a9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20Lechtenb=C3=B6rger?= Date: Sat, 21 Sep 2019 12:01:59 +0200 Subject: [PATCH] ox-html: Control source line wrapping * list/ox-html.el (org-html-do-format-code): Use new variable org-html-wrap-src-lines to control whether source code lines should be wrapped in code elements or not. Allow to revert to behavior before commit ded3d27b1468b878197e5fe55a70c5e13350ea27. --- lisp/ox-html.el | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 757006321..969e649fc 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -932,6 +932,14 @@ in all modes you want. Then, use the command :group 'org-export-html :type 'string) +(defcustom org-html-wrap-src-lines t + "If t, wrap individual lines of source blocks in \"code\" elements. +In this case, add line number in attribute \"data-ox-html-linenr\" when line +numbers are enabled." + :group 'org-export-html + :package-version '(Org . "9.3") + :type 'boolean) + ;;;; Table (defcustom org-html-table-default-attributes @@ -2256,11 +2264,13 @@ line of code." (format "%s" (format num-fmt line-num))) ;; Transcoded src line. - (format "%s" - (if num-start - (format " data-ox-html-linenr=\"%s\"" line-num) - "") - loc) + (if org-html-wrap-src-lines + (format "%s" + (if num-start + (format " data-ox-html-linenr=\"%s\"" line-num) + "") + loc) + loc) ;; Add label, if needed. (when (and ref retain-labels) (format " (%s)" ref)))) ;; Mark transcoded line as an anchor, if needed. -- 2.20.1 --=-=-=--