@financial-times/o-syntax-highlight
Advanced tools
Comparing version 3.0.5 to 3.0.6
@@ -79,5 +79,6 @@ "use strict"; | ||
_getLanguage(element) { | ||
var className = element.className; | ||
var highlightClassNames = [...element.classList].filter(c => c.includes('o-syntax-highlight--')); | ||
var highlightClassName = highlightClassNames ? highlightClassNames[0] : null; | ||
if (!className.includes('o-syntax-highlight--')) { | ||
if (!highlightClassName) { | ||
console.warn("In order to highlight a codeblock, the '<code>' " + "requires a specific class to define a language. E.g. " + "class=\"o-syntax-highlight--html\" or " + "class=\"o-syntax-highlight--js\"", element); | ||
@@ -87,3 +88,3 @@ return null; | ||
this.opts.language = className.replace('o-syntax-highlight--', ''); | ||
this.opts.language = highlightClassName.replace('o-syntax-highlight--', ''); | ||
@@ -90,0 +91,0 @@ this._checkLanguage(); |
@@ -28,3 +28,3 @@ { | ||
"name": "@financial-times/o-syntax-highlight", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"description": "syntax highlighter for FT products", | ||
@@ -31,0 +31,0 @@ "homepage": "https://github.com/Financial-Times/o-syntax-highlight", |
@@ -55,6 +55,7 @@ import throwError from './helpers'; | ||
*/ | ||
_getLanguage (element) { | ||
const className = element.className; | ||
_getLanguage(element) { | ||
const highlightClassNames = [...element.classList].filter(c => c.includes('o-syntax-highlight--')); | ||
const highlightClassName = highlightClassNames ? highlightClassNames[0]: null; | ||
if (!className.includes('o-syntax-highlight--')) { | ||
if (!highlightClassName) { | ||
console.warn( | ||
@@ -68,3 +69,3 @@ `In order to highlight a codeblock, the '<code>' ` + | ||
this.opts.language = className.replace('o-syntax-highlight--', ''); | ||
this.opts.language = highlightClassName.replace('o-syntax-highlight--', ''); | ||
@@ -71,0 +72,0 @@ this._checkLanguage(); |
31961
402