Skip to content

Commit

Permalink
Merge pull request #11700 from quarto-dev/bugfix/issue-11699
Browse files Browse the repository at this point in the history
Work around shortcode parameter inconsistency in `video` text contexts
  • Loading branch information
cscheid authored Dec 18, 2024
2 parents 0ce5ced + aa67ff2 commit 6c27dff
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
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%" >}}
-->

0 comments on commit 6c27dff

Please sign in to comment.