Shortcodes
A few examples of shortcodes that can be used with the shortcodes plugin; first comes Lua function for a shortcode, then the shortcode usage in Markdown.
Colored text
function col(c)
return '<span style="color: ' .. c .. '; text-shadow: 1px 1px 3px rgba(0,0,0,0.65);">' .. content .. '</span>'
end
<$ col'red' $>Richard<$ end $>
<$ col'orange' $>Of<$ end $>
<$ col'yellow' $>York<$ end $>
<$ col'green' $>Gave<$ end $>
<$ col'blue' $>Battle<$ end $>
<$ col'indigo' $>In<$ end $>
<$ col'violet' $>Vain<$ end $>
Richard Of York Gave Battle In Vain
Note
function note()
-- Empty lines are added to make Luasmith treat `content` as markdown
-- paragraph and process it, otherwise the whole returned string
-- is treated as raw HTML.
return [[<div style="border: 3px #fcca36 dashed;border-radius: 12px;padding: 0 1em;margin: 2ex 0;">
<p><svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8" data-attribution="cc0-icons" viewBox="0 0 24 24"><path d="M16 18H8m8-4H8m3-4H8m6-8v6h5"></path><path d="M15 2H6.5c-1.09 0-2 .91-2 2v16c0 1.09.91 2 2 2h11c1.09 0 2-.91 2-2V7.5L15 2Z"></path></svg>
<span style="font-size: 1.4em; font-weight: bold;">NOTE</span></p>
]] .. content .. '\n\n</div>'
end
<$ note() $>
This is a **note** with some `markdown` in it
<$ end $>
NOTE
This is a note with some markdown in it
YouTube video embedding
function youtube(id)
return '<iframe width="560" height="315" src="https://www.youtube.com/embed/' .. id .. '" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>'
end
<$ youtube("jCZnFKk6M9A") -$>