I'm such a slow coder that this is all I got to in my free moments today:patch for defcustoms that inserts the necessary code into a src block. further refinements necessary before it works properly; severla more would be useful for hte improvements that Bastien suggests.
On Wed, Dec 14, 2016 at 12:55 PM, Matt Price <mopto...@gmail.com> wrote: > > > > On Wed, Dec 14, 2016 at 5:06 AM, Rasmus <ras...@gmx.us> wrote: > >> >> I don’t know if much more support is needed. We add some automatic >> configuration scripting or add a per-block switch for enabling klipse. >> >> Two more little things. HTML blocks can't use the standard editor so they > need an extra attribute `data-editor-style="html"` > > >
From 05cc9948fe65201317a770c2d20cb9202b7d83ce Mon Sep 17 00:00:00 2001 From: Matt Price <matt.pr...@utoronto.ca> Date: Wed, 14 Dec 2016 17:37:09 -0500 Subject: [PATCH] preliminary support for live preview of code snippets Src blocks in supported languages are exported in a REPL which permits live execution, courtesy of the klipse library. Defcustom `org-html-klipsify-src' set to nil by default, controls this behaviour. --- lisp/ox-html.el | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 63a8c84..2704f84 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -1548,7 +1548,33 @@ CSS classes, then this prefix can be very useful." :group 'org-export-html :type 'string) - +(defcustom org-html-klipsify-src nil + "Set to non-nil if you would like to make source code blocks editable in exported presentation." + :group 'org-export-html + :type 'boolean) + +(defcustom org-html-klipse-css "https://storage.googleapis.com/app.klipse.tech/css/codemirror.css" + "Location of the codemirror css file for use with klipse." + :group 'org-export-html + :type 'string) + +(defcustom org-html-klipse-js "https://storage.googleapis.com/app.klipse.tech/plugin_prod/js/klipse_plugin.min.js" + "location of the klipse js source code." + :group 'org-export-html + :type 'string) + +(defcustom org-html-klipse-selection-script + "window.klipse_settings = {selector_eval_html: '.src-html', + selector_eval_js: '.src-js', + selector_eval_python_client: '.src-python', + selector_eval_scheme: '.src-scheme', + selector: '.src-clojure', + selector_eval_ruby: '.src-ruby'};" + "javascript snippet to activate klipse" + :group 'org-export-html + :type 'string) + + ;;; Internal Functions (defun org-html-xhtml-p (info) @@ -2041,6 +2067,11 @@ holding export options." (format "</%s>\n" (nth 1 (assq 'content (plist-get info :html-divs)))) ;; Postamble. (org-html--build-pre/postamble 'postamble info) + ;; klipse library for live code blocks, if requested + (if org-html-klipsify-src + (concat "<script>"org-html-klipse-selection-script "</script> +<script src=\"" org-html-klipse-js "\"></script> +<link rel=\"stylesheet\" type=\"text/css\" href=\"" org-html-klipse-css "\"/>")) ;; Closing document. "</body>\n</html>")) -- 2.10.2