From mboxrd@z Thu Jan 1 00:00:00 1970 From: "N. Raghavendra" Subject: [PATCH] ox-html.el: Fix display of language indicators for source blocks Date: Tue, 06 Jun 2017 20:50:21 +0530 Message-ID: <8760g9ywga.fsf@hri.res.in> Reply-To: "N. Raghavendra" Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49185) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIGHZ-00079h-IF for emacs-orgmode@gnu.org; Tue, 06 Jun 2017 11:20:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIGHU-0005WT-Sq for emacs-orgmode@gnu.org; Tue, 06 Jun 2017 11:20:33 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:35715) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dIGHU-0005Vr-N3 for emacs-orgmode@gnu.org; Tue, 06 Jun 2017 11:20:28 -0400 Received: by mail-pf0-x241.google.com with SMTP id u26so24654763pfd.2 for ; Tue, 06 Jun 2017 08:20:27 -0700 (PDT) Received: from ailuros (hrins2.hri.res.in. [220.227.103.136]) by smtp.gmail.com with ESMTPSA id v62sm14665170pfb.124.2017.06.06.08.20.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 08:20:25 -0700 (PDT) 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 CSS rules like pre.src-awk:before { content: 'Awk'; } in `org-html-style-default' don't work in the current Org version, because the class attribute has been moved from the `pre' element to a `code' child of that element. As a result, the name of the language isn't dipslayed when hovering over a source block in the HTML file. I am currently doing (setq org-html-keep-old-src t) but I think it's a kludge. A better way out would be to move back the `class' attribute from the `code' element to its `pre' parent in `org-src-html-block', or to change the CSS selectors in `org-html-style-default'. This patch does the former. (As for the latter, AFAIK there is no CSS selector which picks precisely those `pre' elements that have `code' children with attributes `src' and `src-LANG'.) Cheers, Raghu. ---------------------------------------------------------------------- * lisp/ox-html.el (org-html-src-block): Move the `class' attribute of the `code' element to its parent `pre' element. TINYCHANGE --- lisp/ox-html.el | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 3ad3ffe..857775b 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -3394,12 +3394,17 @@ contextual information." listing-number (org-trim (org-export-data caption info)))))) ;; Contents. - (let ((open (if org-html-keep-old-src "%s" + lang label + (if org-html-keep-old-src + "" + (format "" + (if (and klipsify + (string= lang "html")) + " data-editor-type=\"html\"" + ""))))) (close (if org-html-keep-old-src "" ""))) - (format "%s class=\"src src-%s\"%s%s>%s%s" - open lang label (if (and klipsify (string= lang "html")) - " data-editor-type=\"html\"" "") - code close))))))) + (concat open code close))))))) ;;;; Statistics Cookie -- 2.7.4 ---------------------------------------------------------------------- -- N. Raghavendra , http://www.retrotexts.net/ Harish-Chandra Research Institute, http://www.hri.res.in/