Skip to content

Commit

Permalink
Merge pull request quarto-dev#11980 from mcanouil/fix/issue11664
Browse files Browse the repository at this point in the history
feat(lipsum): Add option to disable randomisation in `lipsum` shortcode'
  • Loading branch information
cscheid authored Jan 31, 2025
2 parents 527c335 + 8117731 commit f6b86d1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/changelog-1.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ All changes included in 1.7:
- ([#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.
- Fix `pandoc.mediabag` Lua typings so autocompletions work with the Lua LSP integration.
- ([#11664](https://github.com/quarto-dev/quarto-cli/issues/11664)): `lipsum` shortcode is no longer randomly generated by default, use `{{< lipsum random=true >}}` to restore randomness.

## Engines

Expand Down
12 changes: 11 additions & 1 deletion src/resources/extensions/quarto/lipsum/lipsum.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ local barePattern = '^(%d+)$'
return {
['lipsum'] = function(args, kwargs, meta)

local isRandom = false
if kwargs and kwargs["random"] then
local randomVal = pandoc.utils.stringify(kwargs["random"])
if randomVal == "true" then
isRandom = true
end
end

local paraStart = 1
local paraEnd = 5

Expand All @@ -58,7 +66,9 @@ return {
-- a number of paragraphs is specified, like 10
local _,_,bareVal = range:find(barePattern)
if bareVal then
paraStart = math.random(1, 17)
if isRandom then
paraStart = math.random(1, 17)
end
local endNumber = tonumber(bareVal)
if endNumber ~= nil then
paraEnd = paraStart + endNumber - 1
Expand Down
10 changes: 10 additions & 0 deletions tests/docs/smoke-all/2025/01/29/issue-11664.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
format: html
_quarto:
tests:
html:
ensureFileRegexMatches:
- ["Nunc ac dignissim magna. Vestibulum vitae egestas elit."]
---

{{< lipsum 2 >}}

0 comments on commit f6b86d1

Please sign in to comment.