Skip to content

Commit

Permalink
Made the language matching a bit more lax. Now it can be on the <pre>…
Browse files Browse the repository at this point in the history
… element even when it has <code> children. Also, it can be lang-xxxx instead of language-xxxx.
  • Loading branch information
LeaVerou committed Jul 16, 2012
1 parent 21b6ea1 commit de85c1a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion components/prism-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

(function(){

// Private helper vars
var langRegex = /lang(?:uage)?-(\w+)/i

var _ = self.Prism = {
tokens: {
url: /[a-z]{3,4}s?:\/\/\S+/g
Expand All @@ -30,7 +33,10 @@ var _ = self.Prism = {
return;
}

var language = (element.className.match(/language-(\w+)/i) || [])[1],
var language = (
element.className.match(langRegex)
|| element.parentNode.className.match(langRegex)
|| [])[1],
tokens = _.languages[language];

if (!tokens) {
Expand Down

0 comments on commit de85c1a

Please sign in to comment.