From a583640a092b145d595424da9bdec75db66a4ebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Sun, 1 Sep 2024 12:00:13 +0200 Subject: [PATCH] Add support for Obsidian type blockquote alerts * 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 --- content/en/render-hooks/blockquotes.md | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/content/en/render-hooks/blockquotes.md b/content/en/render-hooks/blockquotes.md index e0eda5c51..607514f04 100755 --- a/content/en/render-hooks/blockquotes.md +++ b/content/en/render-hooks/blockquotes.md @@ -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: @@ -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