-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Support GitHub's Alert Markdown extension #12590
Comments
When this was proposed/implemented at GitHub, I suggested they used markdown attributes instead (which is certainly more standard and something Hugo could easily support). They chose not to listen to me. But you could, e.g:
And add a code render hook for it. |
Thank you for your kind reply, @bep. Using markdown attributes is indeed a more Markdown-standard solution, and I will try it in my development. I might also come up with another solution for our Obsidian users to write with ease. I won't close this issue, and if there are any breakthroughs, I will update it. Have a day as amazing as you are :) |
GitHub's documentation for their Alert Markdown extension: GitHub's implementation is OK if you speak English. But for the rest of the planet, not so much. Using English words in the alert designator (e.g.,
Note Das ist meine Notiz. The above is just... rude. We could support this monolignual syntax with a Goldmark extension, or (preferably) provide multilingual support via a blockquote render hook. The blockquote render hook would parse the first line, looking for an alert designator (e.g.,
Ordinal and position are desired but not required. The ordinal is handy for assigning element ids, and the position is handy for error reporting. Example render hook:
This render hook implementation would also allow you to do things like:
|
Have there been any breakthroughs here? I wrote a Python script for an All-in-One regex and S3 image upload, and it works well for me for now. However, I'm still hoping for native support for GitHub alerts. This Markdown syntax does have its quirks, but it's currently the most widely used format. :) PS: My hastily-written Python regex alert_pattern = re.compile(r'^>\s*\[!(.*?)\]\s*\n((?:>.*\n)*)', re.MULTILINE | re.DOTALL)
def replace_alert(match):
alert_type = match.group(1).strip()
content = match.group(2).replace('>', '').strip()
return f'{{{{< alert "{alert_type}" >}}}}\n{content}\n{{{{< /alert >}}}}'
content = alert_pattern.sub(replace_alert, content) |
I've been trying this out following the new documentation and it works great, thanks to @bep and @jmooring. I have however noticed that the alert type's seem to be hardcoded to only accept a few preset types (the five mentioned in GitHub's alerts documentation) - which makes sense because this ticket was for exactly that! However, it would be quite helpful if we could define additional alert types. I use Obsidian and this change is great because Obsidian does alerts the same way as GitHub, but supports a few more alert types, see here for the list (stuff like info, danger etc). Would @bep consider adding functionality to allow the user to manually define their own alert types in |
@jakeprice-me Please open a new issue. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I am currently immersed in the development of a new Hugo theme, which aims to provide users with a seamless experience when writing Hugo blogs using Obsidian. However, when it comes to Callout blocks like this:
Important
This is a Callout.
Things get stuck. While utilizing shortcodes and regex can be a workaround, it tends to be error-prone and lacks elegance.
Thus, I am curious whether the esteemed Hugo development team would consider enhancing the Markdown parsing engine to natively support GitHub-style Callouts.
Yours sincerely.
The text was updated successfully, but these errors were encountered: