Skip to content

Allow simple challenge callouts without accordion blocks#718

Open
alex-ball wants to merge 1 commit intocarpentries:mainfrom
alex-ball:allow-simple-challenge
Open

Allow simple challenge callouts without accordion blocks#718
alex-ball wants to merge 1 commit intocarpentries:mainfrom
alex-ball:allow-simple-challenge

Conversation

@alex-ball
Copy link
Copy Markdown

The accordion lua filter for challenge blocks is set up to transform a structure like this:

  • div.challenge
    • (question)
    • div.hint / div.solution
      • (answer)
    • (debrief)

into a structure like this:

  • div.challenge
    • (question)
  • div.hint / div.solution
    • (answer)
  • div.discussion
    • (debrief)

But it does this (in effect) by taking away all the content up to the last inner block, and assuming that whatever is left must be a debrief discussion. This does not take into account the possibility that there were no inner blocks to begin with, and means that

  • div.challenge
    • (set of steps to try)

is transformed into

  • div.discussion
    • (set of steps to try)

This PR changes that behaviour so the filter will only put the content at the end of a div.challenge into a div.discussion if at least one div.challenge has already been added to the challenge train; otherwise it will just add the current div.challenge to the train unaltered. I have done this with an additional local Boolean, as I think this is marginally more efficient in Lua than checking for an empty pandoc.List with next(...) == nil but I'm prepared to be corrected on that.

I have added a unit test for this behaviour, which the old code fails and the new code passes.

Fixes #672.

Differentiate between content that occurs after accordion blocks in a
challenge fenced div and content that occurs inside a challenge fenced
div with no accordion blocks.
@froggleston froggleston self-assigned this Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Challenge fenced div with no inner fenced divs is converted to Discussion

2 participants