···11+---
22+packages:
33+ - maudit
44+release: minor
55+---
66+77+Added support for shortcodes in Markdown. Shortcodes allows you to substitute custom content in your Markdown files. This feature is useful for embedding dynamic content or reusable components within your Markdown documents.
88+99+For instance, you might define a shortcode for embedding YouTube videos using only the video ID, or for inserting custom alerts or notes.
1010+1111+```markdown
1212+{{ youtube id="FbJ63spk48s" }}
1313+```
1414+1515+Would render to:
1616+1717+```html
1818+<iframe
1919+ width="560"
2020+ height="315"
2121+ src="https://www.youtube.com/embed/FbJ63spk48s?si=hUGRndTWIThVY-72"
2222+ title="YouTube video player"
2323+ frameborder="0"
2424+ allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
2525+ referrerpolicy="strict-origin-when-cross-origin"
2626+ allowfullscreen
2727+></iframe>
2828+```
2929+3030+To define and register shortcodes, pass a MarkdownShortcodes instance to the MarkdownOptions when rendering Markdown content.
3131+3232+```rust
3333+let mut shortcodes = MarkdownShortcodes::new();
3434+3535+shortcodes.register("youtube", |args, _ctx| {
3636+ let id: String = args.get_required("id");
3737+ format!(
3838+ r#"<iframe width="560" height="315" src="https://www.youtube.com/embed/{}" frameborder="0" allowfullscreen></iframe>"#,
3939+ id
4040+ )
4141+});
4242+4343+MarkdownOptions {
4444+ shortcodes,
4545+ ..Default::default()
4646+}
4747+4848+// Then pass options to, i.e. glob_markdown in a content source
4949+```
5050+5151+Note that shortcodes are expanded before Markdown is rendered, so you can use shortcodes anywhere in your Markdown content, for instance in your frontmatter. Additionally, shortcodes may expand to Markdown content, which will then be rendered as part of the overall Markdown rendering process.