diff --git a/news/changelog-1.8.md b/news/changelog-1.8.md index 0b709283c76..af1507c22e1 100644 --- a/news/changelog-1.8.md +++ b/news/changelog-1.8.md @@ -132,8 +132,10 @@ All changes included in 1.8: - ([#12853](https://github.com/quarto-dev/quarto-cli/issues/12853)): fix replaceAll() escaping issue with embedded notebooks containing `$` in their Markdown. - ([#12939](https://github.com/quarto-dev/quarto-cli/pull/12939)): Upgrade `mermaidjs` to 11.6.0. - ([#13031](https://github.com/quarto-dev/quarto-cli/pull/13031)): Add `.quarto_ipynb` files to `.gitignore` by default. +- ([#13085](https://github.com/quarto-dev/quarto-cli/pull/13085)): Avoid `kbd` shortcode crashes on unknown OS keys. - ([#13164](https://github.com/quarto-dev/quarto-cli/pull/13164)): add `julia` to execute schema to allow autocomplete suggestions. (@mcanouil) + ## Quarto Internals - ([#13155](https://github.com/quarto-dev/quarto-cli/pull/13155)): Process `pandoc-reader-FORMAT` raw blocks through `pandoc.read(FORMAT)` diff --git a/src/resources/extensions/quarto/kbd/kbd.lua b/src/resources/extensions/quarto/kbd/kbd.lua index ae0a8658177..edac0a8547a 100644 --- a/src/resources/extensions/quarto/kbd/kbd.lua +++ b/src/resources/extensions/quarto/kbd/kbd.lua @@ -1,7 +1,7 @@ -- todo: i18n :( return { ['kbd'] = function(args, kwargs, meta) - local function osname(v) + local function get_osname(v) if v == "win" then return "windows" end if v == "mac" then return "mac" end if v == "linux" then return "linux" end @@ -15,8 +15,13 @@ return { local kwargs_strs = {} local title_strs = {} for k, v in pairs(kwargs) do - table.insert(kwargs_strs, string.format('data-%s="%s"', osname(k), pandoc.utils.stringify(v))) - table.insert(title_strs, osname(k) .. ': ' .. pandoc.utils.stringify(v)) + local osname = get_osname(k) + if osname == nil then + quarto.log.warning("unknown os name in kbd shortcode: " .. k .. ", supported names are: win, mac, linux") + return quarto.shortcode.error_output("kbd", "unknown os name: " .. k, "inline") + end + table.insert(kwargs_strs, string.format('data-%s="%s"', osname, pandoc.utils.stringify(v))) + table.insert(title_strs, osname .. ': ' .. pandoc.utils.stringify(v)) end table.sort(kwargs_strs) -- sort so that the output is deterministic local kwargs_str = table.concat(kwargs_strs) @@ -78,7 +83,7 @@ return { if n_kwargs > 0 then table.insert(result, pandoc.Str(' (')) for k, v in pairs(kwargs) do - table.insert(result, pandoc.Str(osname(k))) + table.insert(result, pandoc.Str(get_osname(k))) table.insert(result, pandoc.Str(': ')) table.insert(result, pandoc.Code(pandoc.utils.stringify(v))) n_kwargs = n_kwargs - 1 @@ -98,7 +103,7 @@ return { for k, v in pairs(kwargs) do table.insert(result, pandoc.Code(pandoc.utils.stringify(v))) table.insert(result, pandoc.Str(' (')) - table.insert(result, pandoc.Str(osname(k))) + table.insert(result, pandoc.Str(get_osname(k))) table.insert(result, pandoc.Str(')')) n_kwargs = n_kwargs - 1 if n_kwargs > 0 then diff --git a/tests/docs/smoke-all/2025/07/16/kbd-crash.qmd b/tests/docs/smoke-all/2025/07/16/kbd-crash.qmd new file mode 100644 index 00000000000..3b1b0096b2a --- /dev/null +++ b/tests/docs/smoke-all/2025/07/16/kbd-crash.qmd @@ -0,0 +1,6 @@ +--- +format: html +--- + +{{< kbd windows=alt-f4 >}} +