-
Couldn't load subscription status.
- Fork 953
A better alert shortcode more markdown friendly #941
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
A better alert shortcode more markdown friendly #941
Conversation
b0f82c2 to
2996bd1
Compare
2996bd1 to
e3b96d6
Compare
I rebased your PR to HEAD of repo and added a second commit, that exactly does what you wished/proposed: discarding/avoiding the shortcode argument This topic is a bit tricky: the key to the solution is the common mark spec: We do introduce html blocks with our shortcode, so if we want to get our markup evaluated, we have to make sure that within our shortcode, an end condition for the introduced html block is met again. The easiest way to fulfill the end condition is to insert a blank line (number 7 in the spec), and that's exactly what my second commit does. The irony is that the solution proposed with your first commit worked quite well already (were you aware of that?). In the end my second commit is only a reinforcement of your original approach in the sense that it now allows even corner cases like: that weren't covered with your first approach. Everything else did work already (even without shortcode argument
I hope my change is small enough to justify adding a second commit here. I now wonder whether you still considering this a breaking change? I hope we can finalize this issue soon, I don't think we can do any better here. |
|
Hi, since you are already working on this shortcode, I'd suggest getting rid of the h4 heading, and replacing it with a non-heading styling. Currently such alerts can appear in the page-level toc, and they also break the heading structure (for example, a h4 heading from the alert appears under a h2 heading), which is against best practices. |
Great suggestion, done. @fekete-robert: can you comment on/review this PR? |
|
I'm swamped by work right now, but I hope to take a look during the weekend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to work fine to me, thanks!
53126a1 to
8a1b927
Compare
|
Thanks for the updates @deining. I've revisited this PR, making the following adjustments:
Note that I still can't get the alert shortcode to play well when used in lists, for example. I'm unsure if this is a Hugo bug/feature or due to the shortcode itself. I don't have time to investigate this further now, so I've opened the following issue to track the problem: PTAL @deining @fekete-robert. Note that I'm OOO next week so feel free to merge this if you judge that it's ready. |
|
Hmm, given that this is potentially a breaking change, it should be postponed until: I'll update the CHANGELOG. /cc @geriom |
That's great, I was aware of this defect already, your solution is great!
Fine for me.
I got aware of this defect recently, too.
This is a bug in the shortcode itself. Whitespace handling inside the shortcode is really trick.
This PR hopefully closes #1672.
Yes, I think it's ready for merging now, but from my understanding, this should go into the v0.8 release, correct? What is the time schedule date for this release? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this PR is eventually ready for merging 😄.
5142655 to
5035d81
Compare
|
Ok, after 3+ years, I think I've got it :). This shortcode does everything I want it to do: it supports markdown content, and can be used in, e.g., markdown lists. It can even contain other shortcodes. @LisaFC @deining @fekete-robert PTAL when you have a moment. |
- Discard shortcode parameter 'markdownify' - Replace <h4> heading tag with <div> tag - Recover heading h4 styling - Update changelog
5035d81 to
768961b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't believe that this PR is going to be merged eventually :-).
My opinion hasn't changed: I consider this PR ready for merging.
243d518 to
7413f28
Compare
5933c88 to
7d1b1e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
{{% %}}#939This doesn't offer as clean a solution as I would have liked, but I feel that it is a step in the right direction. Note that this will introduce a breaking change. I'll continue to explore if/how this shortcode can further be simplified -- ideally, so that we can avoid the use of themarkdownifyshortcode argument -- but any further changes will be submitted through another PR.Edit 2025-06-10: got it to work the way I want. See the UG alert section for details.
Preview
Screenshot