feat: v1.5.0 review fixes and new options#30
Open
mcanouil wants to merge 3 commits into
Open
Conversation
Address the v1.4.0 monorepo review findings and ship the requested
enhancements as a single v1.5.0 release.
Bug fixes
- JavaScript-escape anchor IDs and audio paths via a new
escape_js_string helper so values containing backslashes, quotes,
newlines, or </ cannot break out of the inline <script> tag.
- Warn (once per render) when the bundled default ding.mp3 cannot be
located alongside the extension.
- HTML-escape the button text so markup in the text argument is
rendered as plain text.
New features
- volume attribute clamped to [0.0, 1.0] with a warning on
out-of-range or non-numeric input.
- loop-audio attribute that genuinely disables looping by wrapping
window.Audio around Elevator.js construction.
- Built-in named sounds: audio=ding and end=ding resolve to the
bundled ding.mp3.
- shortcut attribute binding a single KeyboardEvent.key value,
ignored inside form fields and contenteditable elements.
- Document-level disable via elevator: false (or
elevator: { enabled: false }) in YAML metadata.
Docs and scaffolding
- Document the new attributes, named sounds, and global disable in
README.md, example.qmd, _schema.yml, and _snippets.json.
- Fix the BossaBossa.mp3 link in README.md (file ships at repo root).
- Ship _modules/logging.lua and sync module headers with the
canonical style.
- Drop the module-level globally_disabled cache. Re-reading meta on each call is cheap, removes a stale-state risk across documents in a project, and shrinks the helper to four lines. - Inline the needs_audio_wrap flag. The condition is short and only used once. - Unify the custom-button and Quarto back-to-top wiring blocks behind a single build_wiring helper that takes a config table. The back-to-top variant supplies pre_init_js for the onclick reset and omits missing_label so the else branch is skipped. - Replace em dashes with colons in the build_wiring docstring.
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.
Acts on the
quarto-elevator (v1.4.0)section of the monorepo review.Fixes the JavaScript-escaping bug that breaks the generated init script when anchor IDs or audio paths contain
",\,<, or newlines, surfaces a clear warning when the bundled defaultding.mp3is missing, and adds the requested enhancements: volume, loop control, built-in named sounds, a keyboard shortcut, and a document-level disable.Bumps the extension to
v1.5.0.fix: JavaScript-escape anchor IDs and audio paths (
elevator.lua).A new
escape_js_stringhelper in_modules/string.luaescapes\\,",', control characters, and</so payloads cannot break out of the surrounding inline<script>tag.fix: Warn (once per render) when the bundled default
ding.mp3resource cannot be located alongside the extension.fix: HTML-escape the button text so markup in the
textargument is rendered as plain text rather than dropped or interpreted.feat:
volumeattribute.Clamps to
[0.0, 1.0]; warns on out-of-range or non-numeric input.Implemented by temporarily wrapping
window.Audioduringnew Elevator(...)because Elevator.js holds its audio objects in private closure variables.feat:
loop-audioattribute.Defaults to
true(matching Elevator.js's own default).When
false, the wrappedAudioignores Elevator.js's internalsetAttribute('loop', 'false')(which would otherwise still enable looping becauseloopis a boolean attribute).feat: Built-in named sounds.
audio=dingandend=dingresolve to the bundledding.mp3.feat:
shortcutattribute.Binds a single
KeyboardEvent.keyvalue (e.g.,"t","Escape") that triggers the elevator from anywhere on the page, except inside<input>,<textarea>,<select>, orcontenteditableelements.feat: Document-level disable.
elevator: false(orelevator: { enabled: false }) in YAML metadata suppresses every{{< elevator >}}invocation in that document.docs: Document new attributes (
volume,loop-audio,shortcut), built-in named sounds, and the global disable inREADME.md,example.qmd,_schema.yml, and_snippets.json.docs: Fix a broken link in
README.md(_extensions/elevator/BossaBossa.mp3toBossaBossa.mp3; the file ships at the repo root, not inside the extension).docs: Bump
quarto add ...@1.5.0references.refactor: Add
escape_js_stringto_modules/string.lua.refactor: Sync
_modules/string.luaand_modules/html.lua@moduleheaders with the canonical style ("name").refactor: Ship
_modules/logging.luafrom the canonical module set so the filter can callquarto.log.warningwith the standard[elevator] ...prefix.refactor: Drop the chatty
console.log("Elevator: Initializing...")and "Found ..." debug lines from the generated script; keep the "not found" diagnostics so failures remain visible.