From 498754a9001ba3bc96bd7e17ae83cc74008c16ce Mon Sep 17 00:00:00 2001 From: Roy Francis Date: Sun, 24 Mar 2024 13:31:16 +0100 Subject: [PATCH] Updated custom lua --- assets/custom.lua | 39 +++++++++++++++++++++++++-------------- index.qmd | 2 +- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/assets/custom.lua b/assets/custom.lua index 0389d38..c4e3b4e 100644 --- a/assets/custom.lua +++ b/assets/custom.lua @@ -1,14 +1,25 @@ -function RawInline (raw) - if raw.format:match 'html' and raw.text == ''then - return tostring(quarto.version) - end - if raw.format:match 'html' and raw.text == ''then - return tostring(os.date("%d-%m-%Y")) - end - if raw.format:match 'html' and raw.text == ''then - return tostring(os.date("%Y")) - end - if raw.format:match 'html' and raw.text == ''then - return tostring(os.date("%H:%M:%S")) - end - end \ No newline at end of file +-- 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 diff --git a/index.qmd b/index.qmd index 9cf645b..7b3a9d8 100644 --- a/index.qmd +++ b/index.qmd @@ -50,4 +50,4 @@ Shinylive allows shiny applications to run in the browser wthout the need for a --- -Updated: . Quarto v +Updated: {{< meta current_date >}}. Quarto v{{< meta quarto_version >}}