emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] ox-html: add option to restore old src block behaviour?
@ 2019-09-21 12:15 Jens Lechtenboerger
  2019-10-03  0:16 ` Matt Price
  2019-10-08  9:31 ` Nicolas Goaziou
  0 siblings, 2 replies; 7+ messages in thread
From: Jens Lechtenboerger @ 2019-09-21 12:15 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 906 bytes --]

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 ~<code>~ 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 <code> 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’m 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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-html-Control-source-line-wrapping.patch --]
[-- Type: text/x-diff, Size: 1923 bytes --]

From ba3130deb9dbbab3c7d293f901ff08be839a8a9d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jens=20Lechtenb=C3=B6rger?= <jens.lechtenboerger@fsfe.org>
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 "<span class=\"linenr\">%s</span>"
 			(format num-fmt line-num)))
 	      ;; Transcoded src line.
-	      (format "<code%s>%s</code>"
-                      (if num-start
-                          (format " data-ox-html-linenr=\"%s\"" line-num)
-                        "")
-                      loc)
+	      (if org-html-wrap-src-lines
+		  (format "<code%s>%s</code>"
+			  (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


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

end of thread, other threads:[~2019-10-16 17:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-21 12:15 [PATCH] ox-html: add option to restore old src block behaviour? Jens Lechtenboerger
2019-10-03  0:16 ` Matt Price
2019-10-08  9:31 ` Nicolas Goaziou
2019-10-08 18:40   ` Jens Lechtenboerger
2019-10-13  7:30     ` Nicolas Goaziou
2019-10-13 12:16       ` Jens Lechtenboerger
2019-10-16 17:06         ` Nicolas Goaziou

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