File tree Expand file tree Collapse file tree 12 files changed +123
-1
lines changed
tests/docs/smoke-all/2025/08/19/test-lua-shortcode-apis Expand file tree Collapse file tree 12 files changed +123
-1
lines changed Original file line number Diff line number Diff line change @@ -76,12 +76,13 @@ All changes included in 1.8:
7676
7777- ([ #12615 ] ( https://github.com/quarto-dev/quarto-cli/pull/12615 ) ): Adds ` algorithm ` to theorem environments. (author: @jeremy9959 )
7878
79- ## Lua Filters
79+ ## Lua Filters and API
8080
8181- ([ #12727 ] ( https://github.com/quarto-dev/quarto-cli/issues/12727 ) ): Do not crash in the presence of malformed tabset contents.
8282- ([ #12806 ] ( https://github.com/quarto-dev/quarto-cli/pull/12806 ) ): Use pandoc APIs to handle codepage conversion on Windows.
8383- ([ #12811 ] ( https://github.com/quarto-dev/quarto-cli/pull/12811 ) ): Add support for YouTube Shorts in ` video ` shortcode.
8484- ([ #13128 ] ( https://github.com/quarto-dev/quarto-cli/issues/13128 ) ): Meta shortcode could crash on bad input.
85+ - ([ #13246 ] ( https://github.com/quarto-dev/quarto-cli/pull/13246 ) ): Add ` quarto.variables.get() ` and ` quarto.metadata.get() ` APIs.
8586
8687## Commands
8788
Original file line number Diff line number Diff line change 1+ --- @meta
2+
3+ quarto .metadata = {}
4+
5+ --[[
6+ Return the value of a metadata entry in Quarto metadata as a pandoc.MetaValue.
7+ Return nil if the key (or any of its subcomponents) are missing.
8+
9+ This is the Lua equivalent of the {{< meta key >}} shortcode in Quarto documents.
10+ ]]
11+ --- @param key string metadata key , possibly with nested keys separated by dots
12+ --- @return pandoc.MetaValue | nil
13+ function quarto .metadata .get (key ) end
Original file line number Diff line number Diff line change 1+ --- @meta
2+
3+ quarto .variables = {}
4+
5+ --[[
6+ Return the value of a variable in _variables.yml as a string, or nil if name is missing.
7+
8+ This is the Lua equivalent of the {{< var name >}} shortcode in Quarto documents.
9+ ]]
10+ --- @param name string name of variable
11+ --- @return string | nil
12+ function quarto .variables .get (name ) end
Original file line number Diff line number Diff line change @@ -1031,6 +1031,20 @@ quarto = {
10311031 end
10321032 end ,
10331033 },
1034+ metadata = {
1035+ get = function (key )
1036+ return option (key , nil )
1037+ end
1038+ },
1039+ variables = {
1040+ get = function (name )
1041+ local value = var (name , nil )
1042+ if value then
1043+ value = pandoc .utils .stringify (value )
1044+ end
1045+ return value
1046+ end
1047+ }
10341048}
10351049
10361050-- alias old names for backwards compatibility
Original file line number Diff line number Diff line change 1+ /.quarto /
2+
3+ /.luarc.json
Original file line number Diff line number Diff line change 1+ meta_from_metadata : value_from_metadata
Original file line number Diff line number Diff line change 1+ project :
2+ type : website
3+
4+ website :
5+ title : " test-lua-shortcode-apis"
6+ navbar :
7+ left :
8+ - href : index.qmd
9+ text : Home
10+ - about.qmd
11+
12+ format :
13+ html :
14+ theme :
15+ - cosmo
16+ - brand
17+ css : styles.css
18+ toc : true
19+
20+
21+
Original file line number Diff line number Diff line change 1+ var1 : var_value
Original file line number Diff line number Diff line change 1+ ---
2+ title : " About"
3+ ---
4+
5+ About this site
Original file line number Diff line number Diff line change 1+ ---
2+ title : " test-lua-shortcode-apis"
3+ meta1 : meta_value
4+ meta2 : 2
5+ meta3 :
6+ - foo
7+ - bar
8+ meta4 :
9+ key1 : value1
10+ key2 : value2
11+ filters :
12+ - set_span_values.lua
13+ _quarto :
14+ tests :
15+ html :
16+ ensureFileRegexMatches :
17+ -
18+ - meta_value
19+ - var_value
20+ ---
21+
22+ This is a Quarto website.
23+
24+ To learn more about Quarto websites visit < https://quarto.org/docs/websites > .
25+
26+ [ ] {#span1}, [ ] {#span2}
You can’t perform that action at this time.
0 commit comments