Skip to content

Visualize Your Ideas With Code

fix: display newlines in Code correctly (#38)

Jacobdf8f390848d7
diff --git a/src/components/code/Code.tsx b/src/components/code/Code.tsx
index edcfcc7c..60bf9a87 100644
--- a/src/components/code/Code.tsx
+++ b/src/components/code/Code.tsx
@@ -288,7 +288,11 @@ export class Code extends Text {
context.fillText(line, x * letterWidth, (y + 0.5) * lineHeight);
x += line.length;
}
- } else if (typeof token.content === 'string') {
+ } else if (
+ typeof token.content === 'string' &&
+ // FIXME Handle newlines no matter the token type
+ token.type !== 'plain-text'
+ ) {
if (!(token.type in colors)) {
console.warn(`Unstyled token type:`, token.type);
}