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

Commit 52690a0

Browse files
feat: fixing some ssr issues with the markdown renderer (#705)
* 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>
1 parent 64a5345 commit 52690a0

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

packages/markdown/components/Code/index.jsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ function Code(props) {
3636

3737
return (
3838
<React.Fragment>
39-
<code className={['rdmd-code', `lang-${language}`].join(' ')} data-lang={language} name={meta}>
40-
{!syntaxHighlighter || <CopyCode className="fa" code={children[0]} />}
39+
<code
40+
className={['rdmd-code', `lang-${language}`].join(' ')}
41+
data-lang={language}
42+
name={meta}
43+
suppressHydrationWarning={true}
44+
>
45+
<CopyCode className="fa" code={children[0]} />
4146
{syntaxHighlighter ? syntaxHighlighter(children[0], language, { tokenizeVariables: true }) : children[0]}
4247
</code>
4348
</React.Fragment>

packages/markdown/processor/parse/flavored/callout.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ function tokenizer(eat, value) {
2222
'\uD83D\uDED1': 'error',
2323
'\u2049\uFE0F': 'error',
2424
'\u203C\uFE0F': 'error',
25-
// NOTE: prettier is desperate to convert this in to an emoji.
26-
// PLEASE DON'T COMMIT THIS OR YOU'LL BREAK README IN IE!
27-
'\u2139\uFE0F': 'info', // prettier-ignore
25+
// prettier-ignore
26+
'\u2139\uFE0F': 'info',
2827
'\u26A0': 'warn',
2928
}[icon];
3029

0 commit comments

Comments
 (0)