Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

Commit

Permalink
feat: fixing some ssr issues with the markdown renderer (#705)
Browse files Browse the repository at this point in the history
* feat: fixing some ssr issues with the markdown renderer

- always render the copy code button, even on the server
Fixes this issue `Warning: Expected server HTML to contain a matching <button> in <code>.`

- Added `suppressHydrationWarning={true}` to the `<code>` element
The rendered content is always going to be different due to one having
syntax highlighting and one not

* fix: add prettier-ignore to line for ie compatibility

Without this, `prettier --write` always updates to an emoji 🤷‍♂️

Co-authored-by: Rafe Goldberg <rafegoldberg@gmail.com>
  • Loading branch information
domharrington and rafegoldberg authored Jun 4, 2020
1 parent 64a5345 commit 52690a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 7 additions & 2 deletions packages/markdown/components/Code/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ function Code(props) {

return (
<React.Fragment>
<code className={['rdmd-code', `lang-${language}`].join(' ')} data-lang={language} name={meta}>
{!syntaxHighlighter || <CopyCode className="fa" code={children[0]} />}
<code
className={['rdmd-code', `lang-${language}`].join(' ')}
data-lang={language}
name={meta}
suppressHydrationWarning={true}
>
<CopyCode className="fa" code={children[0]} />
{syntaxHighlighter ? syntaxHighlighter(children[0], language, { tokenizeVariables: true }) : children[0]}
</code>
</React.Fragment>
Expand Down
5 changes: 2 additions & 3 deletions packages/markdown/processor/parse/flavored/callout.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ function tokenizer(eat, value) {
'\uD83D\uDED1': 'error',
'\u2049\uFE0F': 'error',
'\u203C\uFE0F': 'error',
// NOTE: prettier is desperate to convert this in to an emoji.
// PLEASE DON'T COMMIT THIS OR YOU'LL BREAK README IN IE!
'\u2139\uFE0F': 'info', // prettier-ignore
// prettier-ignore
'\u2139\uFE0F': 'info',
'\u26A0': 'warn',
}[icon];

Expand Down

0 comments on commit 52690a0

Please sign in to comment.