Skip to content

Commit f6b86d1

Browse files
authored
Merge pull request #11980 from mcanouil/fix/issue11664
feat(lipsum): Add option to disable randomisation in `lipsum` shortcode'
2 parents 527c335 + 8117731 commit f6b86d1

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

news/changelog-1.7.md

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ All changes included in 1.7:
5757
- ([#11699](https://github.com/quarto-dev/quarto-cli/issues/11699)): Fix crash with `video` shortcode inside HTML comments.
5858
- 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.
5959
- Fix `pandoc.mediabag` Lua typings so autocompletions work with the Lua LSP integration.
60+
- ([#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.
6061

6162
## Engines
6263

src/resources/extensions/quarto/lipsum/lipsum.lua

+11-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ local barePattern = '^(%d+)$'
3636
return {
3737
['lipsum'] = function(args, kwargs, meta)
3838

39+
local isRandom = false
40+
if kwargs and kwargs["random"] then
41+
local randomVal = pandoc.utils.stringify(kwargs["random"])
42+
if randomVal == "true" then
43+
isRandom = true
44+
end
45+
end
46+
3947
local paraStart = 1
4048
local paraEnd = 5
4149

@@ -58,7 +66,9 @@ return {
5866
-- a number of paragraphs is specified, like 10
5967
local _,_,bareVal = range:find(barePattern)
6068
if bareVal then
61-
paraStart = math.random(1, 17)
69+
if isRandom then
70+
paraStart = math.random(1, 17)
71+
end
6272
local endNumber = tonumber(bareVal)
6373
if endNumber ~= nil then
6474
paraEnd = paraStart + endNumber - 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
format: html
3+
_quarto:
4+
tests:
5+
html:
6+
ensureFileRegexMatches:
7+
- ["Nunc ac dignissim magna. Vestibulum vitae egestas elit."]
8+
---
9+
10+
{{< lipsum 2 >}}

0 commit comments

Comments
 (0)