Edent,
@Edent@mastodon.social avatar

🆕 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: https://shkspr.mobi/blog/2024/04/server-side-rendering-of-embedded-markdown-code-snippets/

#HowTo #php #programming #WordPress

Edent,
@Edent@mastodon.social avatar

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.

Edent,
@Edent@mastodon.social avatar

OK #CSS nerds, I'm stuck on a problem.

My &lt;code&gt; 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.)

OddDev,
@OddDev@floss.social avatar

@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,
@Edent@mastodon.social avatar

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

KrijnHoetmer, (edited )
@KrijnHoetmer@mastodon.social avatar
Edent,
@Edent@mastodon.social avatar

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

CyReVolt,
@CyReVolt@mastodon.social avatar

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

tomayac,
@tomayac@toot.cafe avatar

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

Edent,
@Edent@mastodon.social avatar

@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 🌈

ernie,
@ernie@writing.exchange avatar

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

  • All
  • Subscribed
  • Moderated
  • Favorites
  • HowTo
  • Durango
  • magazineikmin
  • mdbf
  • thenastyranch
  • khanakhh
  • rosin
  • Youngstown
  • ethstaker
  • slotface
  • modclub
  • kavyap
  • DreamBathrooms
  • everett
  • ngwrru68w68
  • JUstTest
  • InstantRegret
  • tacticalgear
  • GTA5RPClips
  • cubers
  • normalnudes
  • osvaldo12
  • tester
  • anitta
  • cisconetworking
  • megavids
  • Leos
  • provamag3
  • lostlight
  • All magazines