Skip to content

Commit

Permalink
Add support for Obsidian type blockquote alerts
Browse files Browse the repository at this point in the history
* Make the alert type parsing more flexible to support more types
* Add `AlertTitle` and `AlertSign` (for folding)

Note that GitHub will not render callouts with alert title/sign.

See https://help.obsidian.md/Editing+and+formatting/Callouts

Closes #12805
Closes #12801
  • Loading branch information
bep committed Sep 1, 2024
1 parent 3e00808 commit a583640
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions content/en/render-hooks/blockquotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ Blockquote render hook templates receive the following [context]:

(`string`) Applicable when [`Type`](#type) is `alert`, this is the alert type converted to lowercase. See the [alerts](#alerts) section below.

###### AlertTitle

{{< new-in 0.134.0 >}}

(`hstring.HTML`) Applicable when [`Type`](#type) is `alert` when using [Obsidian callouts] syntax, this is the alert title converted to HTML.

###### AlertSign

{{< new-in 0.134.0 >}}

(`string`) Applicable when [`Type`](#type) is `alert` when using [Obsidian callouts] syntax, this is one of "+", "-" or "" (empty string) to indicate the presence of a foldable sign.

[Obsidian callouts]: https://help.obsidian.md/Editing+and+formatting/Callouts

###### Attributes

(`map`) The [Markdown attributes], available if you configure your site as follows:
Expand Down Expand Up @@ -117,13 +131,13 @@ Also known as _callouts_ or _admonitions_, alerts are blockquotes used to emphas

{{% note %}}
This syntax is compatible with the GitHub Alert Markdown extension.
This syntax is compatible with both the GitHub Alert Markdown extension and Obsidian's callout syntax.
But note that GitHub will not recognize callouts with one of Obsidian's extensions (e.g. callout title or the foldable sign).
{{% /note %}}


The first line of each alert is an alert designator consisting of an exclamation point followed by the alert type, wrapped within brackets.

The blockquote render hook below renders a multilingual alert if an alert desginator is present, otherwise it renders a blockquote according to the CommonMark specification.
The blockquote render hook below renders a multilingual alert if an alert designator is present, otherwise it renders a blockquote according to the CommonMark specification.

{{< code file=layouts/_default/_markup/render-blockquote.html copy=true >}}
{{ $emojis := dict
Expand Down

0 comments on commit a583640

Please sign in to comment.