Skip to content

Commit

Permalink
Updated custom lua
Browse files Browse the repository at this point in the history
  • Loading branch information
royfrancis committed Mar 24, 2024
1 parent db0289b commit 498754a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
39 changes: 25 additions & 14 deletions assets/custom.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
function RawInline (raw)
if raw.format:match 'html' and raw.text == '<?quarto.version?>'then
return tostring(quarto.version)
end
if raw.format:match 'html' and raw.text == '<?lua.date?>'then
return tostring(os.date("%d-%m-%Y"))
end
if raw.format:match 'html' and raw.text == '<?lua.year?>'then
return tostring(os.date("%Y"))
end
if raw.format:match 'html' and raw.text == '<?lua.time?>'then
return tostring(os.date("%H:%M:%S"))
end
end
-- Import the os and io modules
os = require('os')
io = require('io')

-- The filter function
function Meta(meta)
-- Execute 'quarto version' command and get the output
local quarto_version = io.popen('quarto --version'):read('*all')
if quarto_version then
-- Add the version to the document metadata
meta['quarto_version'] = quarto_version
end

-- Get the current date and time
local current_date = os.date("%d-%m-%Y")
local current_year = os.date("%Y")
local current_time = os.date("%H:%M:%S")

-- Add them to the document metadata
meta['current_date'] = current_date
meta['current_year'] = current_year
meta['current_time'] = current_time

return meta
end
2 changes: 1 addition & 1 deletion index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ Shinylive allows shiny applications to run in the browser wthout the need for a

---

Updated: <?lua.date?>. Quarto v<?quarto.version?>
Updated: {{< meta current_date >}}. Quarto v{{< meta quarto_version >}}

0 comments on commit 498754a

Please sign in to comment.