[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] [PATCH] ox-html.el: Fix display of language indicators for source bl
From: |
N. Raghavendra |
Subject: |
[O] [PATCH] ox-html.el: Fix display of language indicators for source blocks |
Date: |
Tue, 06 Jun 2017 20:50:21 +0530 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) |
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 "<pre" "<pre><code"))
+ (let ((open (format "<pre class=\"src src-%s\"%s>%s"
+ lang label
+ (if org-html-keep-old-src
+ ""
+ (format "<code%s>"
+ (if (and klipsify
+ (string= lang "html"))
+ " data-editor-type=\"html\""
+ "")))))
(close (if org-html-keep-old-src "</pre>"
"</code></pre>")))
- (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 <address@hidden>, http://www.retrotexts.net/
Harish-Chandra Research Institute, http://www.hri.res.in/
- [O] [PATCH] ox-html.el: Fix display of language indicators for source blocks,
N. Raghavendra <=