silverbullet/website/Markdown/Code Widgets.md

40 lines
1.5 KiB
Markdown
Raw Normal View History

2023-01-21 20:37:55 +08:00
Code widgets are a SilverBullet specific “extensions” to [[Markdown]]. Technically, its not an extension — it just gives new semantics to markdowns native fenced code blocks — code blocks that start with a triple backtick, specifying a programming language.
Currently, SilverBullet provides two code widgets as part of its built in [[🔌 Plugs]]:
* `embed`
* `markdown`
In addition, plugs like [[🔌 KaTeX]] and [[🔌 Mermaid]] add additional ones.
## Embed
This allows you to embed internet content into your page inside of an iframe. This is useful to, for instance, embed youtube videos. In fact, there is specific support for those.
Two examples.
First, embedding the silverbullet.md website into the silverbullet.md website (inception!):
```embed
url: https://silverbullet.md
```
and a Youtube video:
```embed
url: https://www.youtube.com/watch?v=VemS-cqAD5k
```
Note, there is specific support for youtube videos — it automatically will set width, height and replace the URL with an embed URL.
The body of an `embed` block is written in [[YAML]] and supports the following attributes:
* `url` (mandatory): the URL of the content to embed
* `height` (optional): the height of the embedded page in pixels
* `width` (optional): the width of the embedded page in pixels
## Markdown
You can embed markdown inside of markdown and live preview it. Is this useful? 🤷 not really, its more of a demo of how this works. Nevertheless, to each their own, heres an example:
```markdown
This is going to be **bold**
```