emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: handling as special special block in derived export


From: John Kitchin
Subject: Re: handling as special special block in derived export
Date: Thu, 20 Jan 2022 11:12:01 -0500

It depends on what the src things look like. You might be able to just call ffap or some variant of it. Here is an example of the follow part that works for a file and url for me.

#+BEGIN_SRC emacs-lisp
(org-link-set-parameters
 "rstack"
 :follow (lambda (path)
  (ffap (or (ffap-url-at-point)
    (ffap-file-at-point)))))
#+END_SRC

#+RESULTS:
| :follow | (lambda (path) (ffap (or (ffap-url-at-point) (ffap-file-at-point)))) |


[[rstack:(("./screenshots/date-20-01-2022-time-10-36-54.png" . fade-out) (src2 . fade-in) ("https://google.com" . fade-out))]]


John

-----------------------------------
Professor John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803


On Thu, Jan 20, 2022 at 10:21 AM Matt Price <moptop99@gmail.com> wrote:


On Wed, Jan 19, 2022 at 12:18 PM John Kitchin <jkitchin@andrew.cmu.edu> wrote:
I am not sure this is quite what you are looking for. You could use a macro like this. 



{{{r-stack(((src1 . fade-out) (src2 . fade-in) (src3 . fade-out)))}}}

* code :noexport:

#+macro: r-stack (eval (r-stack $1))

#+BEGIN_SRC emacs-lisp
(defun r-stack (src-alist)
  "SRC-alist will be a string containing a list of (src . data-fragment)
src is a url or filename
data-fragment

Returns a string for export."  
  (let ((src (read src-alist)))
    (format "#+BEGIN_EXPORT html
<div class=\"r-stack\">
%s      
</div>
,#+END_EXPORT"
   (string-join
    (cl-loop for (src . data-fragment) in src
     collect
     (format "  <img data-fragment=\"%s\" src="">      data-fragment src))
    "\n"))))


(r-stack "((src1 . fade-out) (src2 . fade-in) (src3 . fade-out))")
#+END_SRC

#+RESULTS:
: #+BEGIN_EXPORT html
: <div class="r-stack">
:   <img data-fragment="fade-out" src="">:   <img data-fragment="fade-in" src="">:   <img data-fragment="fade-out" src=""      
: </div>
: #+END_EXPORT

You could also make a link do that.

Huh.  This wasn't at all what I was thinking but it may be a much better way than I'd htought of. 

A link seems like it would be a great solution, especially if I could figure out how to get the :follow function to open an individual ~src~ path. Would you use "looking-at" to get the right candidate, or can you think of a way to get completion candidates for a function that opens the file? I'm looking at your eamples in https://kitchingroup.cheme.cmu.edu/blog/2016/11/04/New-link-features-in-org-9 but can't quite follow the code.

Thank so mjch for this really interesting solution.

John

-----------------------------------
Professor John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803


On Wed, Jan 19, 2022 at 9:42 AM Matt Price <moptop99@gmail.com> wrote:
I am trying ot figure out if I can create a simplified syntax for a particular special block in a derived HTML exporter. 

I'm trying to produce HTML like this:

<div class="r-stack>
  <img data-fragment="fade-out" src="">"...."/>
  <img data-fragment="fade-in" src="">"..."/>
</div>


The derived backend (org-re-reveal) already has an 
#+ATTR_REVEAL that an make the data-fragment attributes, so it's not hard to produce
the desired outpu:

#+begin_r-stack
#+ATTR_REVEAL: :frag appear [[imglink1]]
#+ATTR_REVEAL: :frag appear
[[imglink2]] #+end_r-stack

However, I'd really like to add a less verbose syntax, like this:

#+begin_r-stack :frag (appear appear) [[imglink1]] [[imglink2]] #+end_r-stack
My question is: will the exporter preserve information from these header-like arguments, and is 
there a mechanism I can use in a custom ~special-block-function~ to make use of htem?

Thanks for your help as always!

Matt

reply via email to

[Prev in Thread] Current Thread [Next in Thread]