Giter Site home page Giter Site logo

Comments (4)

tsdh avatar tsdh commented on August 9, 2024

I've just looked at the code. ox-reveal derives from ox-html which declares (inline-src-block . org-html-inline-src-block) and

(defun org-html-inline-src-block (inline-src-block contents info)
  "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
CONTENTS holds the contents of the item.  INFO is a plist holding
contextual information."
  (let* ((org-lang (org-element-property :language inline-src-block))
     (code (org-element-property :value inline-src-block)))
    (error "Cannot export inline src block")))

ox-reveal should therefore provide a custom function.
Below is a patch that implements that. Unfortunately, the function is never called. That also explains why there's no error which the ox-html function signals. So there's something wrong with org's export framework...

I think my patch does the right thing anyway.

From bf5c6a5fa01cef223162d6ef70d402ce12bbf819 Mon Sep 17 00:00:00 2001
From: Tassilo Horn <[email protected]>
Date: Wed, 12 Jun 2013 17:06:08 +0200
Subject: [PATCH] Support inline src code

---
 ox-reveal.el | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/ox-reveal.el b/ox-reveal.el
index 016d839..86c2458 100644
--- a/ox-reveal.el
+++ b/ox-reveal.el
@@ -59,6 +59,7 @@
   :translate-alist
   '((headline . org-reveal-headline)
     (inner-template . org-reveal-inner-template)
+    (inline-src-block . org-reveal-inline-src-block)
     (item . org-reveal-item)
     (keyword . org-reveal-keyword)
     (paragraph . org-reveal-paragraph)
@@ -517,6 +518,14 @@ the plist used as a communication channel."
                            (org-export-read-attribute :attr_reveal paragraph :frag))
                 contents)))))

+(defun org-reveal-inline-src-block (inline-src-block contents info)
+  "Transcode an INLINE-SRC-BLOCK element from Org to HTML.
+CONTENTS holds the contents of the item.  INFO is a plist holding
+contextual information."
+  (let* ((org-lang (org-element-property :language inline-src-block))
+    (code (org-element-property :value inline-src-block)))
+    (format "<code class=\"src src-%s\">%s</code>" org-lang code)))
+
 (defun org-reveal-section (section contents info)
   "Transcode a SECTION element from Org to HTML.
 CONTENTS holds the contents of the section. INFO is a plist
-- 
1.8.2.1

from org-reveal.

tsdh avatar tsdh commented on August 9, 2024

It seems like inline code blocks cannot be exported (intentionally), although I don't understand the reasons...

See

http://lists.gnu.org/archive/html/emacs-orgmode/2013-06/msg00531.html
http://lists.gnu.org/archive/html/emacs-orgmode/2013-06/msg00534.html

from org-reveal.

yjwen avatar yjwen commented on August 9, 2024

Hello, Tassilo,

Sorry for a late response. I was recently too busy to take a look on Org-Reveal.

I checked your mail discussion and the Babel documents, it seems like the inline source codes are used for evaluation, rather than showing source codes.

With the default setting, Babel will evaluate the inline source codes and put the evaluation result into context. For example, exporting the following contents to HTML will result in a page showing "1 + 1 = 2".

  • Inline Code Evaluation

    1 + 1 = src_python{ return 1 + 1 }

    Also, to enable Python evaluation, you need to add Python to Babel's do-load list by adding the following codes to your .emacs . Similar precess for other languages.

    (add-hook 'org-mode-hook
    (lambda ()
    (org-babel-do-load-languages
    'org-babel-load-languages
    '((python . t)))))


According to the Babel's document, you should be able to export inline source codes themselves instead of the evaluation result by setting header argument :export code, like below

  • Inline Code Evaluation

    1 + 1 = src_python[:exports code]{ return 1 + 1 }

    But actually, such inline codes will result in a "+BEGIN_SRC" text that are not parsed. I think it is a bug of Babel and the export engine.

Regards,
Yujie

from org-reveal.

tsdh avatar tsdh commented on August 9, 2024

Yeah, I've just found that out, too, thanks to Eric Schulte's reply on the org-mode list. We'll see what he says...

from org-reveal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.