-
Notifications
You must be signed in to change notification settings - Fork 48
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
[blog][proposal] Adjust styling/markup for blog post images to better delinate figure and caption from surrounding text #1060
Comments
<figure>
and <figcaption>
and adjust styling
One of the primary and original features of Markdown is that you can inline HTML at-will to do stuff it doesn't have simplified syntax for. Does that not Just Work here? |
That is in fact how I generated the version I took the screenshot of! (After updating the list of tags that sanitize-html allows...) The reason why I think we would want to update to handling this within the Markdown parser is that the ergonomics of |
Hmm. I'm not convinced by the ergonomics argument. I think the modicum of HTML required for While Markdown's inline syntax isn't parsed within HTML blocks, you can surround blocks of Markdown with blocks of HTML and it'll Just Work (intentionally so by design), e.g. *hello*
<figure>
<img src="image.png">
<figcaption>
*hello*
**figure**
</figcaption>
</figure>
**world** |
You're not a grad student rotating through the lab who's been asked to write a blog post and never touched HTML before. Here's a concrete example from a recent blog post to illustrate the ergonomic issue I'm talking about: Current:[![fig1](img/oropouche_host_view.png)](https://nextstrain.org/oropouche/L?c=host)
**Figure 1. Time-resolved phylogeny for the L segment colored by the host the
sample was acquired from.** 98% of sequences in our sample are human, so we have
very limited information into the host reservoir dynamics. Available as
[nextstrain.org/oropouche/L?c=host](https://nextstrain.org/oropouche/L?c=host). Using
|
Right, and I'm not thinking about the ergonomics of it given my experience. That's why I said I think it's teachable and copy-and-pasteable. We wouldn't abandon such a grad student to figure it out on their own and they're already likely going to be copying-and-pasting the current Markdown version of it anyway so doing it for the HTML version doesn't seem like much of a stretch. |
I'd also say the more apples-to-apples comparison is this <figure><a href="https://nextstrain.org/oropouche/L?c=host"><img src="img/oropouche_host_view.png" alt="fig1"></a><figcaption>
**Figure 1. Time-resolved phylogeny for the L segment colored by the host the
sample was acquired from.** 98% of sequences in our sample are human, so we have
very limited information into the host reservoir dynamics. Available as
[nextstrain.org/oropouche/L?c=host](https://nextstrain.org/oropouche/L?c=host).
</figcaption></figure> Is there more syntax? Yes, but not much and it's spelling out things that otherwise opaque (equivalent to named vs. unnamed functions args). Are the two blank lines load-bearing? Yes, and that's unfortunate, but one of the big benefits of using plain Markdown without templating is that it still renders ~correctly in many renderers, e.g. inside someone's editor. That will help make it clear something's wrong when those lines are omitted. |
I think it makes sense to handle on the parser side if:
|
Currently, blog post images are rendered with this HTML markup:
which renders like so:
To my eye, this results in the caption visually "bleeding" into the following paragraph of the post content.
In porting the blog pages to App Router, I experimented with adding a border to the image, to see if that would resolve the "bleeding" issue. My initial attempt was just adding
margin: 1px solid #ccc; padding: 1rem;
to the CSS forimg
tags in blog posts. That looked like this:This helps offset the figure image, but because the caption text is outside the box, the "bleeding" problem is still present.
Thinking about this a little bit more, I realized that, by using some more semantic markup, it would be possible to have the caption inside the box, giving a more distinct delineation of the "figure" content from the surrounding "article" content. The markup would look like:
and then applying the above CSS rule (with
border
andpadding
to the<figure>
tag rather than<img>
, which looks like this:Overall, I think this looks very nice, and is reminiscent of figure rendering in a journal article, which feels appropriate for our blog.
Actually implementing this in an ergonomic way would require either extending the
marked
Markdown parser to recognize some sort of custom markdown syntax, or to interpret the normal![]
image/link syntax so the<figure>
markup was emitted, or switching to a different Markdown parser with more direct support for including<figure>
instead of<img>
, such as markdown-it/markdown-it-figure.I'm soliciting feedback on all of:
marked
versus switching to a different Markdown parserThe text was updated successfully, but these errors were encountered: