Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around shortcode parameter inconsistency in video text contexts #11700

Merged
merged 4 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/changelog-1.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ All changes included in 1.7:
This also provides a new public function `quarto.utils.is_empty_node`
that allows to check whether a node is empty, i.e., whether it's an
empty list, has no child nodes, and contains no text.
- ([#11699](https://github.com/quarto-dev/quarto-cli/issues/11699)): Fix crash with `video` shortcode inside HTML comments.
- Expose new `quarto.paths.tinytex_bin_dir` in Quarto's Lua API. If TinyTeX is found by Quarto, this will be set to the path to the `bin` directory of the TinyTeX installation where command line tool are located (e.g., `pdflatex`, `tlmgr`, etc.). If TinyTeX is not found, this will be `nil`, meaning Quarto will use the system PATH to find the command line tools.

## Other Fixes and Improvements
Expand Down
13 changes: 10 additions & 3 deletions src/resources/extensions/quarto/video/video.lua
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,16 @@ function htmlVideo(src, height, width, title, start, aspectRatio)
-- https://github.com/quarto-dev/quarto-cli/issues/6833
-- handle partially-specified width, height, and aspectRatio
if aspectRatio then
local strs = splitString(aspectRatio, 'x')
wr = tonumber(strs[1])
hr = tonumber(strs[2])
-- https://github.com/quarto-dev/quarto-cli/issues/11699#issuecomment-2549219533
-- we remove quotes as a
-- local workaround for inconsistent shortcode argument parsing on our end.
--
-- removing quotes in general is not a good idea, but the
-- only acceptable values for aspectRatio are 4x3, 16x9, 21x9, 1x1
-- and so we can safely remove quotes in this context.
local strs = splitString(aspectRatio:gsub('"', ''):gsub("'", ''), 'x')
local wr = tonumber(strs[1])
local hr = tonumber(strs[2])
local aspectRatioNum = wr / hr
if height and not width then
width = math.floor(height * aspectRatioNum + 0.5)
Expand Down
9 changes: 9 additions & 0 deletions tests/docs/smoke-all/2024/12/17/issue-11699.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: "Video embedding in an HTML comment"
---

<!--

{{< video https://www.youtube.com/watch?v=Sq1QZB5baNw title="Figure Status Update - OpenAI Speech-to-Speech Reasoning" aspect-ratio="21x9" width="100%" height="100%" >}}

-->
Loading