Skip to content

Commit b4e0c10

Browse files
committed
Lua - new API quarto.format
.format_identifier()
1 parent 2f24776 commit b4e0c10

4 files changed

Lines changed: 26 additions & 1 deletion

File tree

src/resources/lua-types/quarto/format.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,13 @@ Returns an object with the format name and variants as would be interpreted by P
239239
]]
240240
---@param raw_format string The format's string
241241
---@return quarto.format.ParseFormatResult
242-
function quarto.format.parse_format(raw_format) end
242+
function quarto.format.parse_format(raw_format) end
243+
244+
--[[
245+
Returns a table with the format identifier information, including:
246+
- `target-format`: The full target format name, e.g. `html+variant`
247+
- `base-format`: The base format name, e.g. `html`
248+
- `display-name`: A human-readable display name for the format, e.g. `HTML`
249+
- `extension`: The name of the extension that exposes the format, if present
250+
]]
251+
function quarto.format.format_identifier() end

src/resources/pandoc/datadir/_format.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ local function _main()
288288
end
289289

290290
return {
291+
format_identifier = function()
292+
return param("format-identifier", {})
293+
end,
291294
isAsciiDocOutput = isAsciiDocOutput,
292295
is_asciidoc_output = isAsciiDocOutput,
293296
isRawHtml = isRawHtml,
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function Pandoc(doc)
2+
local identifier = quarto.format.format_identifier()
3+
assert(identifier["target-format"] == "html+test")
4+
assert(identifier["base-format"] == "html")
5+
assert(identifier["display-name"] == "HTML")
6+
return doc
7+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
format: html+test
3+
filters:
4+
- format-identifier.lua
5+
---
6+

0 commit comments

Comments
 (0)