Skip to content

[Bug]: SmartyPants replaces -- into an em-dash in <TerminalBlock> #8140

@smikitky

Description

@smikitky

Summary

In https://react.dev/learn/typescript#adding-typescript-to-an-existing-react-project :

Image

As you can see, -- has been converted to (a non-ASCII em-dash). This happens during the site build step, so when someone copies this and pastes it into a terminal, they get an error.

The root cause is this file:

https://github.com/reactjs/react.dev/blob/b440d6698f6e21d56a78b10f625bd23191183588/plugins/remark-smartypants.js

It applies SmartyPants to all text AST nodes in Markdown. Since <TerminalBlock> is implemented using only simple <div>s and the plugin does not skip contents aside from <style> and <script>, the plugin converts --save-dev to —save-dev in <TerminalBlock>.

I think the fix would involve two steps:

  1. Use <pre> or <code> appropriately to render the contents of <TerminalBlock>
  2. In the plugin above, skip applying SmartyPants not only when the parent tag is <script>/<styule> but also when it's <code> or <pre>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions