diff --git a/_extensions/embedio/_extension.yml b/_extensions/embedio/_extension.yml index 26365fe..efea84c 100644 --- a/_extensions/embedio/_extension.yml +++ b/_extensions/embedio/_extension.yml @@ -5,5 +5,6 @@ version: 0.0.0-dev.1 quarto-required: ">=1.4.549" contributes: shortcodes: + - audio.lua - pdf.lua - revealjs.lua \ No newline at end of file diff --git a/_extensions/embedio/audio.lua b/_extensions/embedio/audio.lua new file mode 100644 index 0000000..db9802d --- /dev/null +++ b/_extensions/embedio/audio.lua @@ -0,0 +1,72 @@ +local function audio(args, kwargs, meta) + + if not quarto.doc.is_format("html") then + return + end + + -- Start of HTML tag + local htmlTable = {"
') + end + + -- Add caption if provided + if caption then + table.insert(htmlTable, '
' .. caption .. '
') + end + + -- Start the audio tag + table.insert(htmlTable, "") + + -- Extract download option + local download = pandoc.utils.stringify(kwargs.download) or "false" + + -- Add download link if provided + if download == "true" then + table.insert(htmlTable, ' Download audio ') + end + + -- Add closing figure tag + table.insert(htmlTable, "
") + + return pandoc.RawBlock('html', table.concat(htmlTable)) +end + + +return { + ['audio'] = audio +} \ No newline at end of file diff --git a/docs/_quarto.yml b/docs/_quarto.yml index f0998ba..c54ee24 100644 --- a/docs/_quarto.yml +++ b/docs/_quarto.yml @@ -21,8 +21,9 @@ website: href: qembedio-embed-pdf.qmd - text: "RevealJS" href: qembedio-embed-revealjs.qmd - - text: "HTML" - text: "Audio" + href: qembedio-embed-audio.qmd + - text: "HTML" - text: "Maps" - text: "Social" - section: "Support" diff --git a/docs/qembedio-embed-audio.qmd b/docs/qembedio-embed-audio.qmd new file mode 100644 index 0000000..09d9da8 --- /dev/null +++ b/docs/qembedio-embed-audio.qmd @@ -0,0 +1,14 @@ +--- +title: "Embed Audio" +--- + +The `audio` short code generates an embedded audio object for HTML websites. You can use it with: + +```markdown +{{{< audio file="assets/test.mp3" >}}} +``` + +For example, we can show the `test.mp3` with: + +{{< audio file="assets/test.mp3" >}} +