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

Rework alert shortcode #941

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

chalin
Copy link
Collaborator

@chalin chalin commented Mar 21, 2022

This 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 the markdownify shortcode argument -- but any further changes will be submitted through another PR.

Preview links:

@deining
Copy link
Collaborator

deining commented Feb 10, 2023

I'll continue to explore if/how this shortcode can further be simplified -- ideally, so that we can avoid the use of the markdownify shortcode argument

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 markdownify.

This topic is a bit tricky: the key to the solution is the common mark spec:

An HTML block is a group of lines that is treated as raw HTML
...
It ends with the first subsequent line that meets a matching end condition

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:

{{% alert title="Note" color="info" %}}**Bold** content{{% /alert %}}

that weren't covered with your first approach. Everything else did work already (even without shortcode argument markdownify!).

but any further changes will be submitted through another PR.

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.

@fekete-robert
Copy link
Collaborator

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.

@deining deining marked this pull request as ready for review February 10, 2023 13:33
@deining
Copy link
Collaborator

deining commented Feb 10, 2023

I'd suggest getting rid of the h4 heading, and replacing it with a non-heading styling.

Great suggestion, done.

@fekete-robert: can you comment on/review this PR?

@fekete-robert
Copy link
Collaborator

I'm swamped by work right now, but I hope to take a look during the weekend

Copy link
Collaborator

@fekete-robert fekete-robert left a 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!

@chalin
Copy link
Collaborator Author

chalin commented Aug 18, 2023

Thanks for the updates @deining. I've revisited this PR, making the following adjustments:

  • Recovered the .h4 styling of the alert header, without making it heading element
  • Changed the shortcode file suffix to .md

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.

@chalin
Copy link
Collaborator Author

chalin commented Aug 18, 2023

Hmm, given that this is potentially a breaking change, it should be postponed until:

I'll update the CHANGELOG.

/cc @geriom

@chalin chalin mentioned this pull request Aug 18, 2023
21 tasks
@deining
Copy link
Collaborator

deining commented Aug 19, 2023

Thanks for the updates @deining. I've revisited this PR, making the following adjustments:

* Recovered the `.h4` _styling_ of the alert header, without making it heading element

That's great, I was aware of this defect already, your solution is great!

* Changed the shortcode file suffix to `.md`

Fine for me.

Note that I still can't get the alert shortcode to play well when used in lists, for example.

I got aware of this defect recently, too.

I'm unsure if this is a Hugo bug/feature or due to the shortcode itself.

This is a bug in the shortcode itself. Whitespace handling inside the shortcode is really trick.
I addressed this issue in an additional commit which hopefully resolves this problem.

I don't have time to investigate this further now, so I've opened the following issue to track the problem:

* [Alert shortcode in markdown not playing nice when indented #1672](https://github.com/google/docsy/issues/1672)

This PR hopefully closes #1672.

PTAL @deining @fekete-robert. Note that I'm OOO next week so feel free to merge this if you judge that it's ready.

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?

Copy link
Collaborator

@deining deining left a 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 😄.

@chalin chalin modified the milestones: 24Q1, 23Q4 Nov 29, 2023
@deining deining force-pushed the chalin-gitpod-alert-rework-2022-03-21 branch from f45fdaf to c722dfc Compare December 18, 2023 20:12
@chalin chalin modified the milestones: 23Q4, 24Q1 Jan 11, 2024
@deining deining force-pushed the chalin-gitpod-alert-rework-2022-03-21 branch from d17d346 to c4574c8 Compare February 3, 2024 13:42
@deining
Copy link
Collaborator

deining commented Feb 3, 2024

Rebased PR and fixed code style issues. IMHO this PR is eventually ready for merging.

@deining deining force-pushed the chalin-gitpod-alert-rework-2022-03-21 branch 2 times, most recently from 74c3122 to 95e2f72 Compare February 3, 2024 13:53
@chalin chalin modified the milestones: 24Q1, 24Q2 Apr 2, 2024
@deining deining force-pushed the chalin-gitpod-alert-rework-2022-03-21 branch from 95e2f72 to c03f1a3 Compare April 8, 2024 05:42
@deining
Copy link
Collaborator

deining commented Apr 8, 2024

I move breaking change note to the correct section in the CHANGELOG.
With two approving reviews given, any reason to not include this in the upcoming 0.10.0 release?

@chalin
Copy link
Collaborator Author

chalin commented Apr 8, 2024

I move breaking change note to the correct section in the CHANGELOG.

Thanks.

With two approving reviews given, any reason to not include this in the upcoming 0.10.0 release?

When I last tested this, it unexpectedly broke some use cases on the OTel website. I investigated, and couldn't figure out why it wasn't working. It occurred to me that it might be a bug in Hugo. I haven't had the time to investigate further nor create a small enough repro, and so let this slide until a later release.

@deining
Copy link
Collaborator

deining commented Apr 8, 2024

I move breaking change note to the correct section in the CHANGELOG.

Thanks.

You are welcome.

With two approving reviews given, any reason to not include this in the upcoming 0.10.0 release?

When I last tested this, it unexpectedly broke some use cases on the OTel website.

Yes, I remember you raised an according issue.

I investigated, and couldn't figure out why it wasn't working. It occurred to me that it might be a bug in Hugo.

As mentioned in my reply, I investigated this and it turned out it was a whitespace issue in the shortcode, which was fixed meanwhile with commit 4da2600a504. I'm quite sure this is not an Hugo issue.

I haven't had the time to investigate further nor create a small enough repro, and so let this slide until a later release.

Can you please test the latest version of this shortcode on the OTel website again? I'm pretty confident it won't cause any problems any more!

@chalin chalin modified the milestones: 24Q2, 24Q3 Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alert shortcode in markdown not playing nice when indented
4 participants