You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm creating a book with exercises. Many exercises have answers. I want to collect all the answers and put them into their own appendix, cross linked with the questions.
I have this working fine for PDF output. I have a pre_quarto filter that matches div.answer and moves them into their own list.
However, it doesn't work for HTML. The problem is that filters are loaded just once for a PDF documents, but they seem to be loaded for each chapter for HTML. This means that I don't seem to be able to traverse the entire document in a filter. I've confirmed that the .lua files are reinitialized for each chapter (see below).
Is there a trick for maintaining document-global state for lua filters when the target is HTML? Am I reinventing the wheel?
Cheers
Dave
To show that filters are reloaded for each chapter:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm creating a book with exercises. Many exercises have answers. I want to collect all the answers and put them into their own appendix, cross linked with the questions.
I have this working fine for PDF output. I have a pre_quarto filter that matches
div.answer
and moves them into their own list.However, it doesn't work for HTML. The problem is that filters are loaded just once for a PDF documents, but they seem to be loaded for each chapter for HTML. This means that I don't seem to be able to traverse the entire document in a filter. I've confirmed that the .lua files are reinitialized for each chapter (see below).
Is there a trick for maintaining document-global state for lua filters when the target is HTML? Am I reinventing the wheel?
Cheers
Dave
To show that filters are reloaded for each chapter:
And the chapters are all just
# some title
Run this:
(source attached)
reload.zip
Beta Was this translation helpful? Give feedback.
All reactions