Skip to content

Commit

Permalink
Regenerate
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 8, 2021
1 parent b97764e commit ba4ad5c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 11 deletions.
6 changes: 1 addition & 5 deletions lang/js-templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,7 @@ export default function jsTemplates(Prism) {
var token = tokens[i]
if (typeof token === 'string' || typeof token.content === 'string') {
var placeholder = placeholders[placeholderCounter]
var s =
typeof token === 'string'
? token
: /** @type {string} */
token.content
var s = typeof token === 'string' ? token : token.content
var index = s.indexOf(placeholder)
if (index !== -1) {
++placeholderCounter
Expand Down
54 changes: 49 additions & 5 deletions lang/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,57 @@ export default function markdown(Prism) {
})
}
} else {
// get the textContent of the given env HTML
var tempContainer = document.createElement('div')
tempContainer.innerHTML = env.content.value
var code = tempContainer.textContent
env.content = Prism.highlight(code, grammar, codeLang)
env.content = Prism.highlight(
textContent(env.content.value),
grammar,
codeLang
)
}
})
var tagPattern = RegExp(Prism.languages.markup.tag.pattern.source, 'gi')
/**
* A list of known entity names.
*
* This will always be incomplete to save space. The current list is the one used by lowdash's unescape function.
*
* @see {@link https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/unescape.js#L2}
*/
var KNOWN_ENTITY_NAMES = {
amp: '&',
lt: '<',
gt: '>',
quot: '"'
} // IE 11 doesn't support `String.fromCodePoint`
var fromCodePoint = String.fromCodePoint || String.fromCharCode
/**
* Returns the text content of a given HTML source code string.
*
* @param {string} html
* @returns {string}
*/
function textContent(html) {
// remove all tags
var text = html.replace(tagPattern, '') // decode known entities
text = text.replace(/&(\w{1,8}|#x?[\da-f]{1,8});/gi, function (m, code) {
code = code.toLowerCase()
if (code[0] === '#') {
var value
if (code[1] === 'x') {
value = parseInt(code.slice(2), 16)
} else {
value = Number(code.slice(1))
}
return fromCodePoint(value)
} else {
var known = KNOWN_ENTITY_NAMES[code]
if (known) {
return known
} // unable to decode
return m
}
})
return text
}
Prism.languages.md = Prism.languages.markdown
})(Prism)
}
2 changes: 1 addition & 1 deletion lang/xquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default function xquery(Prism) {
} else if (
openedTags.length > 0 &&
token.type === 'punctuation' &&
token.content === '{' && // Ignore `{{`
token.content === '{' &&
(!tokens[i + 1] ||
tokens[i + 1].type !== 'punctuation' ||
tokens[i + 1].content !== '{') &&
Expand Down

0 comments on commit ba4ad5c

Please sign in to comment.