mastodon.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
The original server operated by the Mastodon gGmbH non-profit

Administered by:

Server stats:

353K
active users

Terence Eden

🆕 blog! “Server-Side Rendering of Embedded Markdown Code Snippets in WordPress”

Because I'm a grumpy old man, I don't use Gutenberg or Block themes on my WordPress. Instead, I write everything in Markdown. When I write code snippets in Markdown, they look like this: ```php $a = 1; echo $a; if ($a < 5) { // Do Something return thing( $a, true …

👀 Read more: shkspr.mobi/blog/2024/04/serve

Terence Eden’s BlogServer-Side Rendering of Embedded Markdown Code Snippets in WordPress

Can't be arsed creating a dark mode for my code-highlighting.

Just going to shove `filter: invert(1);` in the CSS when someone selects Dark.

OK nerds, I'm stuck on a problem.

My `<code>` blocks scroll horizontally when they overflow (good!) but is there any way to slightly fade out the right side *only* if there's further content to be seen?

I want to make it a bit more obvious if there's some more content to be seen. No everyone scrolls down to see the x-axis scroll bar.

(Not looking for Google results, thanks.)

@Edent I do something similar with Craft. Everything in Markdown.

I need to have a code-snippet solution. I’ve only run into the issue once but it caused some headaches for me when trying to publish my email.

@Edent In the Python example, the `datetime` import has a different color than the other imports. Just a random observation.

@tomayac yeah, there is some weird colouring going on.
TBH, everyone seems to have a different theme for their preferred IDE - so I might just go with rainbow colours 🌈

@Edent Yes! A after pseudo element with the same color as the background. Make it relatively small (0.5rem?). And attach it to the right side of the container.

@Edent And add a gradient to transparent obviously 🫠

@OddDev Not a bad plan. But it shows up even when there's nothing to scroll.
And, unless I'm missing something, scrolls with the content.

@Edent @OddDev if you make it the same colour as the background with an alpha channel left-to-right gradient then it should be invisible when there’s nothing behind it

@Edent Yes! That's why it needs to be the same color as the background. And you should add a gradient to transparent.

@Edent Plus it needs to be positioned absolute in relation to the immediate container.

@Edent @Edent codesandbox.io/p/sandbox/polis

@KrijnHoetmer ah! That gets me a bit closer. Thanks 🙂

@Edent one technique is using a certain padding and showing the fading gradient either way.

@Edent Using the pseudo element after or before with absolute positioning and relative positioning on the element itself, that is.