Remove fancy quotes

When you surround something in single quotes, for example:

print(‘Hello world’)

the website replaces the normal single-quote ascii character with some fancy characters ‘ and ’.

This can cause issues when copying and pasting code, because those literals are not going to be recognized. For example if I copy the above into python I’m going to get the following error:

>>> print(‘Hello world’)
  File "<stdin>", line 1
    print(‘Hello world’)
               ^
SyntaxError: invalid character in identifier

These should be removed to avoid confusing users in the future.

1 Like

Hi @sagendor - thanks for pointing this out. Did you notice this in the MATLAB guide? That’s the only place I’ve found single quotes in code, but I want to be sure they all get fixed.

I imagine it will be a fairly common use case for someone to type something like:

“Hey, try this: <<some code containing single quotes>>

In those cases if you don’t happen to notice that the quote characters aren’t the actually ASCII quotes, you’ll get error messages that may be confusing if you aren’t anticipating it.

1 Like

Ah, I thought you were saying this happens on our website, not the user forum. Yes, I can see this issue in some of the post replies. We’ll see if we can change this, although I’m not sure if Discourse will allow for customization like that.

A guideline for posting code on Discourse: Use the pre-formatted text button in the toolbar (</>) to enclose your code to avoid issues with formatting of quotes.

Example:

‘Hello’ (Quotes get changed to fancy quotes)

'Hello' (Quotes don’t get changed!)

You can also use Markdown syntax:

Inline code like python -c "print('Hello world')" using:

`python -c “print(‘Hello world’)”`

Or code blocks like

python -c "print('Hello world')"

using:

```
python -c “print(‘Hello world’)”
```

1 Like