That one where a slack quotes formatting screws your code up again...

That one where a slack quotes formatting screws your code up again...

Table of Contents

Beautiful Edit: I’ve upgraded to macOS 15.4 (24E248) and the slack native client appears to be honouring the system config!

defaults write NSGlobalDomain Thank you to Michael Schwegel!

Prior: If you’ve ever copied and pasted code snippets to and from Slack, only to find that your code chokes when you excute it, you’re not alone.

The largest culprit? Slack’s auto-formatting of plain double quotes (") into “smart quotes” (“ and ”). We got bit by one during a high stakes database operation just this week!

While this might make your writing look prettier in chat (hot take: it doesn’t), it wreaks havoc in programming. Code expects plain ASCII characters, and these curly quotes are entirely different Unicode characters. They can silently break scripts, JSON, shell commands, and config files — and are especially maddening because they look so similar.

What’s Actually Happening?

Slack tries to help by auto-replacing straight quotes with typographically correct curly quotes. This is arguably great for English prose, but disastrous for code — especially when you’re copying something like:

{ “name”: “Paul” }

This looks fine, but your JSON parser will choke on it.

{ "name": "Paul" }

^^ This is what you wanted. Typography be damned!

Is There a Fix?

Not really. At time of writing, Slack doesn’t provide a setting to turn this off in messages — but code blocks (i.e. wrapping in ```) will work.

you could also set some formatting rules in your editor (see what i did with CSS in this page???), or do something like this:

def fix_quotes(text):
    return text.replace("“", '"').replace("”", '"').replace("‘", "'").replace("’", "'")

but I find myself using find/replace.

Related Posts

 Marimo - a great new tool for building micro- & internal apps

Marimo - a great new tool for building micro- & internal apps

Introduction to Marimo I’m a huge fan of Marimo - a next generation Python “notebook” which, like predecessors such as Jupyter & Hex, provide a useful paradigm that’s more reusable than a script but has great REPL-like interactivity.

Read More
Midi Concertina - my second instrument attempt

Midi Concertina - my second instrument attempt

TLDR: i can play some basic metal on a midi concertina: https://youtu.

Read More
SlackZen - just leave (tm) - and the noise of the modern office

SlackZen - just leave (tm) - and the noise of the modern office

TLDR: Check out the code on GitHub . It even worked at one point in time!

Read More

Get new posts via email

Intuit Mailchimp

Copyright 2024-infinity, Paul Pereyda Karayan. Design by Zeon Studio