-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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 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: