From 492994585a35e029117d75fcecda1a7632fc71df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Thu, 28 May 2026 23:02:18 +0200 Subject: [PATCH 1/5] feat: bump to v1.5.0 with review fixes and new options 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 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. --- CHANGELOG.md | 25 ++ README.md | 68 +++- _extensions/elevator/_extension.yml | 2 +- _extensions/elevator/_modules/html.lua | 2 +- _extensions/elevator/_modules/logging.lua | 62 ++++ _extensions/elevator/_modules/string.lua | 23 +- _extensions/elevator/_schema.yml | 26 +- _extensions/elevator/_snippets.json | 15 + _extensions/elevator/elevator.lua | 418 ++++++++++++++++++---- example.qmd | 28 +- 10 files changed, 575 insertions(+), 94 deletions(-) create mode 100644 _extensions/elevator/_modules/logging.lua diff --git a/CHANGELOG.md b/CHANGELOG.md index b1580c4..7e36bf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,31 @@ ## Unreleased +## 1.5.0 (2026-05-28) + +### Bug Fixes + +- fix: JavaScript-escape anchor IDs and audio paths so values containing `"`, `\`, `<`, or newlines no longer break the generated init script. +- fix: Warn (once per render) when the bundled default `ding.mp3` cannot be located alongside the extension. +- fix: HTML-escape the button text so markup in the `text` argument is rendered as plain text rather than dropped or interpreted. + +### New Features + +- feat: Add `volume` attribute that clamps to the range [0.0, 1.0] and warns on out-of-range or non-numeric input. +- feat: Add `loop-audio` attribute that genuinely disables looping (works around Elevator.js's `setAttribute('loop', 'false')` no-op). +- feat: Add built-in named sounds. `audio=ding` and `end=ding` resolve to the bundled `ding.mp3`. +- feat: Add `shortcut` attribute to trigger the elevator from anywhere outside form fields via a keyboard key. +- feat: Add document-level disable via `elevator: false` (or `elevator: { enabled: false }`) in YAML metadata. + +### Documentation + +- docs: Document new attributes (`volume`, `loop-audio`, `shortcut`), built-in sounds, and global disable in `README.md`, `example.qmd`, `_schema.yml`, and `_snippets.json`. + +### Refactoring + +- refactor: Add `escape_js_string` helper to the shared `_modules/string.lua` module. +- refactor: Sync `_modules/` doc-style metadata with the canonical module headers and ship `_modules/logging.lua` alongside `string.lua` and `html.lua`. + ## 1.4.0 (2026-03-23) ### Refactoring diff --git a/README.md b/README.md index 9f85ecb..2d437c0 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Animation is only available for HTML-based documents. ## Installation ```sh -quarto add mcanouil/quarto-elevator@1.4.0 +quarto add mcanouil/quarto-elevator@1.5.0 ``` This will install the extension under the `_extensions` subdirectory. @@ -16,19 +16,65 @@ If you're using version control, you will want to check in this directory. ## Usage -To add an elevator button, use the `{{< elevator >}}` shortcode. For example: +To add an elevator button, use the `{{< elevator >}}` shortcode. -- Mandatory: +### Minimal - ```markdown - {{< elevator >}} - ``` +```markdown +{{< elevator >}} +``` + +### Custom text and scroll target + +The first positional argument is the button label and the second is the id of an element to scroll to instead of the top of the page. + +```markdown +{{< elevator "Back to header" my-header >}} +``` + +### Audio + +`audio` is the looping music played during the scroll and `end` is the sound played once the scroll finishes. + +```markdown +{{< elevator audio=music.mp3 end=ding.mp3 >}} +``` + +The built-in name `ding` resolves to the bundled `ding.mp3`, so `audio=ding` or `end=ding` works without copying the file into your project. + +### Volume + +`volume` accepts a number in the range [0.0, 1.0]. Out-of-range or non-numeric values are clamped and a warning is emitted at render time. + +```markdown +{{< elevator audio=music.mp3 volume=0.5 >}} +``` + +### Loop control -- Optional ``, ``, and ``: +`loop-audio` defaults to `true` (Elevator.js's own default). Set it to `false` to play the main audio just once. The extension overrides Elevator.js's internal `setAttribute('loop', 'false')` no-op so this option actually disables looping. + +```markdown +{{< elevator audio=music.mp3 loop-audio=false >}} +``` - ```markdown - {{< elevator >}} - ``` +### Keyboard shortcut + +`shortcut` binds a single key (matched against `KeyboardEvent.key`) that triggers the elevator from anywhere on the page, except when the focus is inside an ``, `