From e0e4efa12aa6b66181b0522a3c3842177256e303 Mon Sep 17 00:00:00 2001 From: Rodrigo Pombo Date: Thu, 7 Feb 2019 20:57:09 -0300 Subject: [PATCH] Fix tag highlighting --- src/slide.js | 2 +- src/tokenizer.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/slide.js b/src/slide.js index 304d53f..a45cbe2 100644 --- a/src/slide.js +++ b/src/slide.js @@ -2,7 +2,7 @@ import React from "react"; import animation from "./animation"; import theme from "./nightOwl"; -const themeStylesByType = {}; +const themeStylesByType = Object.create(null); theme.styles.forEach(({ types, style }) => { types.forEach(type => { themeStylesByType[type] = Object.assign( diff --git a/src/tokenizer.js b/src/tokenizer.js index a53aa45..681445b 100644 --- a/src/tokenizer.js +++ b/src/tokenizer.js @@ -19,14 +19,14 @@ function flattenTokens(tokens) { } // Convert strings to tokens -function tokenizeStrings(prismTokens) { +function tokenizeStrings(prismTokens, parentType = "plain") { return prismTokens.map(pt => typeof pt === "string" - ? { type: "plain", content: pt } + ? { type: parentType, content: pt } : { type: pt.type, content: Array.isArray(pt.content) - ? tokenizeStrings(pt.content) + ? tokenizeStrings(pt.content, pt.type) : pt.content } );