emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "N. Raghavendra" <nyraghu27132@gmail.com>
To: emacs-orgmode@gnu.org
Cc: Matt Price <matt.price@utoronto.ca>
Subject: Re: [PATCH] ox-html.el: Fix display of language indicators for source blocks
Date: Tue, 19 Sep 2017 06:24:37 +0530	[thread overview]
Message-ID: <87tvzzecdu.fsf@gmail.com> (raw)
In-Reply-To: <87k24exyoz.fsf@gmail.com> (N. Raghavendra's message of "Wed, 14 Jun 2017 23:02:12 +0530")

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

At 2017-06-14T23:02:12+05:30, N. Raghavendra wrote:

> At 2017-06-12T12:45:13-04:00, Matt Price wrote:
>
>> As it stands right now, both changes (addition of `data-editor-type`
>> attribute and moving the language name class from `pre` to `code`)
>> are necessary to make klipse work
>
> I tried with some examples, and the editing facility of klipse seems
> to work even if you put the class attributes in the pre element
> instead of in its code child.  Let me check it again and provide an
> MWE, but it'll take a few days, because I am busy at work this week.
> If what I said is indeed correct, I have some suggestions on how to
> deal with the problem.

I am sorry for the inexcusable delay.

1. After rereading your message, I felt that one way out is restore the
   treatment of source code blocks, when klipse is not used, to what it
   was before you made commit d5bbf36553.  This means that the blocks
   are exported as content of pre elements, when klipse is not used.

2. When klipse is used, your code kicks in, and puts the source code
   blocks of the klipse languages in code children, with appropriate
   attributes, of pre elements.  Blocks of non-klipse languages are
   still put directly into pre elements as before, with the appropriate
   class attribute.

3. It remains to decide when klipse is being used.  It is used when
   `org-html-klipsify-src' has a non-nil value.

4. Lastly, we are not changing the export of code blocks when klipse is
   not being used.  Therefore, `org-html-keep-old-src' is not needed.

Attached is a patch that implements these changes.

I have also put a test file, and two exported HTML files, with and
without klipse, at http://www.retrotexts.net/tmp/ox-html-patch/
The Makefile there should be self-explanatory.  Please see if
klipse.html agrees with what you want, modulo syntax colouring (it was
produced in batch mode).  The file noklipse.html validates (it can be
checked at the W3C validator), and has language indicators.

I hope this takes care of our different requirements.

Cheers,
Raghu.

--
N. Raghavendra <raghu@hri.res.in>, http://www.retrotexts.net/
Harish-Chandra Research Institute, http://www.hri.res.in/


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-html.el-Partially-revert-d5bbf36553.patch --]
[-- Type: text/x-diff, Size: 2479 bytes --]

From 7f352785b7ac5d9858a57da83778d4cfa572d7a5 Mon Sep 17 00:00:00 2001
From: "N. Raghavendra" <raghu@hri.res.in>
Date: Tue, 19 Sep 2017 05:00:50 +0530
Subject: [PATCH] ox-html.el: Partially revert d5bbf36553

* lisp/ox-html.el (org-html-src-block): Unless klipse is used, export
source code blocks as content of `pre' elements, and not as content of
`code' children of `pre' elements.  Restores the previous way of
exporting source code blocks, and fixes the display of language
indicators while hovering over the blocks in the exported HTML file,
when klipse is not used.
(org-html-keep-old-src): Remove it.  Not needed because it is now the
default, unless klipse is used.
---
 lisp/ox-html.el | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index ebb233b..be36d66 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -174,7 +174,6 @@
     (:html-klipsify-src nil nil org-html-klipsify-src)
     (:html-klipse-css nil nil org-html-klipse-css)
     (:html-klipse-js nil nil org-html-klipse-js)
-    (:html-klipse-keep-old-src nil nil org-html-keep-old-src)
     (:html-klipse-selection-script nil nil org-html-klipse-selection-script)
     (:infojs-opt "INFOJS_OPT" nil nil)
     ;; Redefine regular options.
@@ -1572,12 +1571,6 @@ https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag"
   :package-version '(Org . "9.1")
   :type 'string)
 
-(defcustom org-html-keep-old-src nil
-  "When non-nil, use <pre class=\"\"> instead of <pre><code class=\"\">."
-  :group 'org-export-html
-  :package-version '(Org . "9.1")
-  :type 'boolean)
-
 
 ;;;; Todos
 
@@ -3384,12 +3377,16 @@ contextual information."
 			      listing-number
 			      (org-trim (org-export-data caption info))))))
 		;; Contents.
-		(let ((open (if org-html-keep-old-src "<pre" "<pre><code"))
-		      (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)))))))
+		(if klipsify
+		    (format "<pre><code class=\"src src-%s\"%s%s>%s</code></pre>"
+			    lang
+			    label
+			    (if (and klipsify (string= lang "html"))
+				" data-editor-type=\"html\""
+			      "")
+			    code)
+		  (format "<pre class=\"src src-%s\"%s>%s</pre>"
+                          lang label code)))))))
 
 ;;;; Statistics Cookie
 
-- 
2.7.4


  reply	other threads:[~2017-09-19  0:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-06 15:20 [PATCH] ox-html.el: Fix display of language indicators for source blocks N. Raghavendra
2017-06-06 20:08 ` 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 [this message]
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=87tvzzecdu.fsf@gmail.com \
    --to=nyraghu27132@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=matt.price@utoronto.ca \
    /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).