Ruby on Rails

Ruby on Rails: Action Text Gets Smarter Markdown

Mike Dalessio delivered two fantastic pull requests that make Action Text's markdown conversion much more intelligent and user-friendly. The biggest win is that blob attachments now generate proper markdown links instead of placeholders, plus better support for Trix editor output with improved strikethrough and whitespace handling.

Duration: PT4M20S

https://podlog.io/listen/ruby-on-rails-87e2c2b6/episode/ruby-on-rails-action-text-gets-smarter-markdown-17ba6eea

Transcript

Hey there, Rails developers! Welcome back to another episode of Ruby on Rails. I'm your host, and wow, do we have some exciting updates from the Rails core team today. If you've been working with Action Text and markdown conversion, you're going to love what's coming your way.

So let's dive right into the main story today, which is all about making Action Text's markdown conversion smarter and more useful. We've got two absolutely stellar pull requests from Mike Dalessio that are going to make your life so much easier if you're working with rich text content.

The first big win is PR 56894, and this one's a game-changer for anyone using blob attachments in Action Text. You know how frustrating it's been when you convert your rich text to markdown and those file attachments just show up as placeholder text like "caption" in square brackets? Well, those days are over, my friends!

Mike noticed that while remote images were already generating proper markdown links like "exclamation-title-parentheses-url" for images, blob attachments were just sitting there as boring placeholders. That didn't make sense, right? So now, when you have a rendering context available - think controller actions or mailer actions - your blob attachments will generate real, clickable markdown links. Images get the full "exclamation-title-url" treatment, and non-image files get clean "title-url" links.

What I love about this implementation is how thoughtful it is about URL generation. Instead of relying on global default URL options, it picks up the host, protocol, and script name directly from the current request context. This is huge for multi-tenant applications where these things might vary per request. It's those kinds of details that show the Rails team really understands real-world use cases.

But wait, there's more! Mike wasn't done making our lives better. PR 56896 tackles something that's been bugging Trix users for a while - better markdown conversion support for Trix-generated HTML. If you've used Trix, you know it has its own way of doing things, like using "del" tags for strikethrough instead of "s" tags, and representing newlines with "br" tags inside "div" blocks.

This update adds proper support for the "del" tag as a strikethrough alias, and includes a smart "visit_div" handler that understands Trix's convention of using divs as default block elements. Plus, and this is really nice, it strips out pretty-print indentation from HTML text nodes. You know how sometimes when you have nicely formatted HTML from templates or serializers, all that extra whitespace can leak into your markdown output? Problem solved! The system is smart enough to collapse indentation to single spaces when needed to preserve word separation.

Now, we also had a smaller but important housekeeping change from Gannon McGibbon in PR 56901. This removes some load hook guards for action_dispatch_request and action_cable that weren't needed anymore. It's one of those behind-the-scenes improvements that keeps the Rails engine running smoothly - not glamorous, but essential.

What really excites me about today's changes is how they show the Rails team's commitment to polish and developer experience. These aren't massive architectural changes, but they solve real pain points that developers face every day. Mike's work on Action Text markdown conversion shows he's been listening to the community and thinking deeply about how these features actually get used in production applications.

Today's Focus: If you're using Action Text in your applications, now's a great time to revisit your markdown conversion workflows. Try out the new attachment_links parameter and see how much cleaner your markdown output becomes. And if you're building rich text features, remember that these kinds of thoughtful improvements happen because developers like you share their experiences and pain points with the community.

That's a wrap for today's episode! Keep building amazing things with Rails, and remember - every small improvement makes our developer experience just a little bit better. Until next time, happy coding!