Conversation
pandoc.Div(source_code) was being called with a plain Lua string.
Pandoc treats that string as ordinary prose text, which collapses all
whitespace (newlines, indentation, repeated spaces) down to single
spaces before the HTML writer emits it. The algorithm's original line
structure is lost in the rendered <div class="pseudocode"> element.
Wrap the source in a pandoc.RawBlock("html", ...) instead (with the
minimal HTML-entity escaping pandoc would otherwise have applied),
so the exact source text -- including line breaks and indentation --
reaches pseudocode.js unchanged.
…errors The render call previously ran exactly once, synchronously, at the point this inline script executes in the page. In a revealjs presentation that timing is not guaranteed to line up with Reveal's own initialization, and a rendering failure was silently swallowed (the block just stayed blank with no indication anything went wrong). Guard each container with a data-pseudocode-rendered flag and also re-run the render pass on Reveal's "ready" and "slidechanged" events. This mirrors the pattern reveal.js's own bundled MathJax/KaTeX plugins use (see plugin/math/math.js and plugin/math/katex.js) to re-typeset content relative to slide readiness. Also wrap the render call in try/catch and print any error onto the slide/page in place of the algorithm, instead of failing silently, so a malformed pseudocode block is visibly broken rather than just missing with no diagnostic.
There was no example demonstrating the extension in a revealjs presentation. Add examples/revealjs/revealjs.qmd (with the standard _extensions symlink used by the other example directories) with the algorithm on a non-title slide, and link it from the README's example list alongside the existing single/book/beamer/cross-reference examples.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for a nice package. I was making a Revealjs presentation and realized that some additional functionality had to be added for the algorithms to show properly.
This PR contains the necessary additions to the source code that I need to make for this to work properly, including an example.