diff --git a/examples/code-highlighting/index.js b/examples/code-highlighting/index.js
index aa7927b87..f645e6180 100644
--- a/examples/code-highlighting/index.js
+++ b/examples/code-highlighting/index.js
@@ -140,10 +140,21 @@ class CodeHighlighting extends React.Component {
switch (mark.type) {
case 'comment': return {children}
case 'keyword': return {children}
+ case 'tag': return {children}
case 'punctuation': return {children}
}
}
+ tokenToContent = (token) => {
+ if (typeof token == 'string') {
+ return token
+ } else if (typeof token.content == 'string') {
+ return token.content
+ } else {
+ return token.content.map(this.tokenToContent).join('')
+ }
+ }
+
/**
* Decorate code blocks with Prism.js highlighting.
*
@@ -170,7 +181,7 @@ class CodeHighlighting extends React.Component {
startText = endText
startOffset = endOffset
- const content = typeof token == 'string' ? token : token.content
+ const content = this.tokenToContent(token)
const newlines = content.split('\n').length - 1
const length = content.length - newlines
const end = start + length
@@ -180,7 +191,7 @@ class CodeHighlighting extends React.Component {
endOffset = startOffset + remaining
- while (available < remaining) {
+ while (available < remaining && texts.length > 0) {
endText = texts.shift()
remaining = length - available
available = endText.text.length