From 36e4b26fd3138376a9a293b057477e0792bf8b6d Mon Sep 17 00:00:00 2001 From: yjwen Date: Fri, 18 Oct 2013 15:15:57 +0800 Subject: [PATCH] Add fragment to source blocks --- ox-reveal.el | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/ox-reveal.el b/ox-reveal.el index b83bfc1..5dfbc36 100644 --- a/ox-reveal.el +++ b/ox-reveal.el @@ -73,6 +73,7 @@ (keyword . org-reveal-keyword) (paragraph . org-reveal-paragraph) (section . org-reveal-section) + (src-block . org-reveal-src-block) (template . org-reveal-template)) :export-block '("REVEAL" "NOTES") @@ -545,11 +546,6 @@ holding export options." (unordered "") (descriptive ""))))) -(defun org-reveal--get-frag (info) - "Get Reveal fragment settings from context." - (let ((frag (plist-get info :reveal-frag))) - (if (eq frag "none") nil frag))) - (defun org-reveal-item (item contents info) "Transcode an ITEM element from Org to Reveal. CONTENTS holds the contents of the item. INFO is aplist holding @@ -631,12 +627,40 @@ the plist used as a communication channel." (defun org-reveal-section (section contents info) - "Transcode a SECTION element from Org to HTML. + "Transcode a SECTION element from Org to Reveal. CONTENTS holds the contents of the section. INFO is a plist holding contextual information." ;; Just return the contents. No "
" tags. contents) +(defun org-reveal-src-block (src-block contents info) + "Transcode a SRC-BLOCK element from Org to Reveal. +CONTENTS holds the contents of the item. INFO is a plist holding +contextual information." + (if (org-export-read-attribute :attr_html src-block :textarea) + (org-html--textarea-block src-block) + (let ((lang (org-element-property :language src-block)) + (caption (org-export-get-caption src-block)) + (code (org-html-format-code src-block info)) + (frag (org-export-read-attribute :attr_reveal src-block :frag)) + (label (let ((lbl (org-element-property :name src-block))) + (if (not lbl) "" + (format " id=\"%s\"" + (org-export-solidify-link-text lbl)))))) + (if (not lang) (format "
\n%s
" + (if frag (format "fragment %s" frag) "example") + label code) + (format + "
\n%s%s\n
" + (if (not caption) "" + (format "" + (org-export-data caption info))) + (format "\n
%s
" + (if frag + (format "fragment %s" frag) + (format "src src-%s" lang)) + label code)))))) + (defun org-reveal-template (contents info) "Return complete document string after HTML conversion. contents is the transcoded contents string.