Curly quotes breaking code copied from your blog or help centre
Short answer: If customers copy a command, API example, configuration line or tracking snippet from your blog or help centre and it fails, look for "smart" typography. Many CMSs and writing tools turn straight quotes into curly quotes, double hyphens into dashes and three dots into an ellipsis, and copying from documents can add non-breaking spaces or invisible characters. Code treats those as different characters, so the copied snippet breaks. Put code in proper code blocks, which tools like WordPress leave untouched, write snippets in a plain-text editor, and test by copying from the live page.
Why it breaks
To a reader, " and “ look nearly the same. To a terminal, a programming language or a configuration parser, they're completely different characters. A straight double quote starts a string; a curly one is just an unknown symbol. The same goes for:
- Apostrophes:
'versus’ - Hyphens and dashes:
--verbosebecoming–verboseor—verbose - Ellipsis:
...becoming the single character… - Spaces: an ordinary space versus a non-breaking space, which looks identical but isn't treated as whitespace by many tools
- Invisible characters: zero-width spaces and similar characters copied from documents or chat apps
Common results include "command not found", "invalid option", JSON parse errors, API keys rejected, or tracking code that silently does nothing.
Where the conversion happens
Your CMS. WordPress's wptexturize() function, documented in the WordPress developer reference, transforms quotes into smart quotes, apostrophes, dashes, ellipses, the trademark symbol and the multiplication symbol. The same documentation notes that text inside <pre>, <code>, <kbd>, <style>, <script> and <tt> tags is skipped, as is text in the [code] shortcode. So code in a proper code block is safe; code pasted into an ordinary paragraph isn't.
Writing tools. Word processors and many note apps apply "smart quotes" and autocorrect as you type. Code written there and pasted into the CMS arrives already converted.
Phones and tablets. Mobile keyboards often insert curly quotes by default. Writing or editing snippets on an iPhone is a common source.
Email and chat. Snippets sent to customers by email or chat can be converted by the app or the recipient's client.
Fix it in your content
- Use code blocks for anything copyable. In the block editor, use the Code or Preformatted block, or inline code formatting. MDN describes
<code>as displaying content as a short fragment of computer code and recommends wrapping multi-line code in<pre>. - Write snippets in a plain-text code editor, then paste them into a code block. Don't write them in a word processor.
- Turn off smart punctuation on devices used for editing technical content, or avoid editing code on phones.
- Search existing posts for curly quotes and en dashes inside commands. Searching your database or exported content for
“,”,’and–near common command words finds most of them. - Add a copy button to code blocks. It copies the exact text and avoids users accidentally selecting extra characters.
Fix it for customers who already copied
If a customer reports a failing command:
- Ask them to paste exactly what they ran into a reply. Curly quotes and odd dashes are often visible once you look.
- Send corrected snippets in a code block or as a plain-text attachment.
- Update the source article immediately so others don't hit it.
Special cases
Tracking and embed codes. Analytics snippets, chat widgets and pixel code pasted into a page builder's text field can be converted. Use the builder's "custom HTML" or "code" element, and check the live page source.
Configuration in admin panels. Some admin fields apply formatting. If a setting expects JSON or a regular expression, paste it from a plain-text editor and test.
Documentation sites and knowledge bases. Check your help-centre tool's editor for a code block option; many have one hidden in a formatting menu.
Translations. Translators' tools may "correct" quotes in code. Mark code as not to be translated.
Testing checklist
- Open the published page in a browser, copy each snippet, paste it into a terminal or code editor and run or validate it.
- Check that dashes in command options are plain hyphens.
- For JSON, paste into a validator.
- Repeat after theme or plugin changes, which can change how content is processed.
Automate a check
If you publish a lot of technical content, add a simple automated check. A small script can scan exported posts or your documentation source for curly quotes, en and em dashes, ellipsis characters, non-breaking spaces and zero-width characters inside code blocks, and flag them for review. Run it before publishing or on a schedule. Developers can add the same check to the documentation repository's continuous integration, so a snippet with a curly quote fails the build instead of reaching a customer.
Product names and copy in emails
The problem also appears in reverse. If customers paste text from your emails into your app, such as a discount code, an account number or a licence key, curly quotes or trailing spaces can make your app reject it. Trim whitespace and normalise quotes when accepting pasted codes, and show codes in emails in a plain, monospace style that's easy to copy.
An illustrative example
A hypothetical Seattle software consultancy published a tutorial with a command containing --dry-run and a JSON configuration example. Readers kept emailing that the command said "unknown option" and the JSON was "invalid". The commands had been written in a word processor and pasted into normal paragraphs, so the double hyphen became an en dash and the quotes curled. The team moved every snippet into code blocks, added a copy button, rewrote the snippets in a code editor, and added "copy and run each snippet" to its publishing checklist.
FAQ
Should I turn off smart quotes across my whole site?
Usually not. Curly quotes look better in normal text. Keep code in code blocks instead.
Can customers see the difference?
Sometimes, in monospace fonts. Often not, which is why it's confusing.
Does this affect SEO?
Not directly, but broken tutorials lead to frustrated readers.
What about non-breaking spaces in prices or names?
Those are fine in normal text; they just shouldn't appear inside code.
If your tutorials, help articles or embed codes break when copied, send us a page where it happens.