Fix tag highlighting

This commit is contained in:
Rodrigo Pombo 2019-02-07 20:57:09 -03:00
parent f5f28a6f24
commit e0e4efa12a
2 changed files with 4 additions and 4 deletions

View File

@ -2,7 +2,7 @@ import React from "react";
import animation from "./animation"; import animation from "./animation";
import theme from "./nightOwl"; import theme from "./nightOwl";
const themeStylesByType = {}; const themeStylesByType = Object.create(null);
theme.styles.forEach(({ types, style }) => { theme.styles.forEach(({ types, style }) => {
types.forEach(type => { types.forEach(type => {
themeStylesByType[type] = Object.assign( themeStylesByType[type] = Object.assign(

View File

@ -19,14 +19,14 @@ function flattenTokens(tokens) {
} }
// Convert strings to tokens // Convert strings to tokens
function tokenizeStrings(prismTokens) { function tokenizeStrings(prismTokens, parentType = "plain") {
return prismTokens.map(pt => return prismTokens.map(pt =>
typeof pt === "string" typeof pt === "string"
? { type: "plain", content: pt } ? { type: parentType, content: pt }
: { : {
type: pt.type, type: pt.type,
content: Array.isArray(pt.content) content: Array.isArray(pt.content)
? tokenizeStrings(pt.content) ? tokenizeStrings(pt.content, pt.type)
: pt.content : pt.content
} }
); );