From: "N. Raghavendra" <nyraghu27132@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] ox-html.el: Fix display of language indicators for source blocks
Date: Tue, 06 Jun 2017 20:50:21 +0530 [thread overview]
Message-ID: <8760g9ywga.fsf@hri.res.in> (raw)
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 <raghu@hri.res.in>, http://www.retrotexts.net/
Harish-Chandra Research Institute, http://www.hri.res.in/
next reply other threads:[~2017-06-06 15:20 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-06 15:20 N. Raghavendra [this message]
2017-06-06 20:08 ` [PATCH] ox-html.el: Fix display of language indicators for source blocks N. Raghavendra
2017-06-08 18:57 ` N. Raghavendra
2017-06-08 19:24 ` Nicolas Goaziou
2017-06-08 19:42 ` N. Raghavendra
2017-06-12 16:45 ` Matt Price
2017-06-14 17:32 ` N. Raghavendra
2017-09-19 0:54 ` N. Raghavendra
2017-09-19 17:18 ` N. Raghavendra
2017-09-19 20:02 ` Nicolas Goaziou
2017-06-08 20:15 ` Matt Price
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8760g9ywga.fsf@hri.res.in \
--to=nyraghu27132@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).