0

I'm preparing a talk in org-reveal. I'm using a construct like this on several slides:

- Bulletpoint A
#+begin_src
Example code for A
#+end_src
- Bulletpoint B
#+begin_src
Example code for B
#+end_src

I would like to fragment this such that first, only Bulletpoint A (with its code example) is visible and, after a click, Bulletpoint B with its code shows up.

I have tried various things:

  • If I put a #+ATTR_REVEAL: :frag t on the line before - Bulletpoint A, then the list itself will be fragmented, but the code examples are both visible right from the start.
  • From this answer on fragmenting a table I've learned about @@html: <div class="fragment"… @@. However, I can't get this to work with source blocks. If I put the @@html: … @@ before the #+begin_src, then org-reveal wraps the custom HTML in a <p>…</p>, which of course means that the source block is not wrapped inside the fragmenting div anymore. If I put the @@html: … @@ inside the source block, it is output verbatim. I guess I would need to place the opening <div> right before the <pre> tag, but I don't see how to accomplish this in org-reveal.

So, two things would help me a lot:

  • Is there any way of assigning a fragment index to a source block? I don't need fragmenting inside the source blocks.
  • Is there a more comfortable way than manually writing the @@html: … @@ (or macros with the same content) at every bullet point and every source block?
1
  • 1
    The problem might be that Org mode does not interpret this as a list of two elements. Try indenting (manually if necessary) the source blocks to the column under the B of Bulletpoint. Then put the cursor on the dash of the first item and say M-: (org-element-at-point). It should say (plain-list (:type unordered :begin 1 :end 139 ...) - the values of begin and end are going to be different in your case, but make sure that they encompass the whole list. Use C-x = to check. Now try with org-reveal again.
    – NickD
    Feb 1, 2022 at 14:46

1 Answer 1

0

The way I solved this for me now is this. I first created these two macros to avoid the very verbose @@html syntax:

#+MACRO:  fb @@html: <div class="fragment" data-fragment-index="$1">@@
#+MACRO:  fe @@html: </div>@@

And then I manually wrap my bullet lists in these fragmenting divs:

{{{fb(1)}}}
   - Point A
#+begin_src 
Code for point A
#+end_src
{{{fe}}}
{{{fb(2)}}}
   - Point B
#+begin_src 
Code for point B
#+end_src
{{{fe}}}
{{{fb(3)}}}
   - Point C
#+begin_src bash
Code for point C
#+end_src
{{{fe}}}

This works rather predictably and does not depend on any indentations being correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.