Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Obsidian type blockquote alerts #12815

Merged
merged 1 commit into from
Sep 1, 2024

Conversation

bep
Copy link
Member

@bep bep commented Sep 1, 2024

  • 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

@jmooring
Copy link
Member

jmooring commented Sep 1, 2024

I created a render hook to handle blockquotes with and without an alert title:

layouts/_default/_markup/render-blockquote.html
{{ $emojis := dict
  "caution" ":exclamation:"
  "important" ":information_source:"
  "note" ":information_source:"
  "tip" ":bulb:"
  "warning" ":information_source:"
  "danger" ":radioactive:"
}}

{{ if eq .Type "alert" }}
  <blockquote class="alert alert-{{ .AlertType }}">
    <p class="alert-heading">
      {{ transform.Emojify (index $emojis .AlertType) }}
      {{ with .AlertTitle }}
        {{ . }}
      {{ else }}
        {{ or (i18n .AlertType) (title .AlertType) }}
      {{ end }}
    </p>
    {{ .Text  }}
  </blockquote>
{{ else }}
  <blockquote>
    {{ .Text }}
  </blockquote>
{{ end }}

Then I tested this Mardown:

> [!danger]
> Do not approach or handle without protective gear.

---

> [!danger] Radiation hazard
> Do not approach or handle without protective gear.

The above was rendered to:

image

In the first example AlertTitle is the same as AlertText. I expected to see this instead:

image

* 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 gohugoio#12805
Closes gohugoio#12801
@bep
Copy link
Member Author

bep commented Sep 1, 2024

@jmooring thanks, I have force pushed a fix.

@jmooring
Copy link
Member

jmooring commented Sep 1, 2024

This looks good to me.

@bep bep merged commit e651d29 into gohugoio:master Sep 1, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend blockquote alerts to support Obsidian AlertTitle Extend blockquote alerts to support Obsidian types
2 participants