Commit 0808f1113ec16484e5211bacd799f29feac42102

Andreas Rohner 2015-12-26T09:11:37

Merge pull request #837 from chriswells0/show-language Allow custom label without a language mapping.

diff --git a/plugins/show-language/index.html b/plugins/show-language/index.html
index 299a73c..57820e9 100644
--- a/plugins/show-language/index.html
+++ b/plugins/show-language/index.html
@@ -34,6 +34,43 @@
 
 	<h2>HTML (Markup)</h2>
 	<pre data-src="plugins/show-language/index.html"></pre>
+
+	<h2>SVG</h2>
+	<p>The <code class="language-markup">data-language</code> attribute can be used to display a specific label whether it has been defined as a language or not.</p>
+	<pre data-language="SVG v1.1"><code class="language-svg">&lt;?xml version="1.0" encoding="utf-8"?>
+&lt;svg version="1.1" xmlns="http://www.w3.org/2000/svg"
+	xmlns:xlink="http://www.w3.org/1999/xlink" width="200px" height="170px"
+	viewBox="0 0 200 170">
+
+	&lt;path fill="#fff" d="M55.371,131.506h-6.976v9.12h6.976c1.664,0,2.923-0.405,
+	3.776-1.216c0.853-0.811,1.28-1.925,1.28-3.344s-0.427-2.533-1.28-3.345C58.293
+	,131.911,57.035,131.506,55.371,131.506zM84.894,137.906c0.32-0.533,0.48-1.216
+	,0.48-2.048c0-1.345-0.459-2.405-1.376-3.185c-0.917-0.778-2.134-1.168-3.648
+	-1.168h-7.456v8.512h7.328C82.483,140.018,84.041,139.314,84.894,137.906zM100,
+	0L0,170h200L100,0zM60.859,141.026c-1.312,1.227-3.088,1.84-5.328,1.84h-7.136v
+	7.552h-2.4v-21.184h9.536c2.24,0,4.021,0.618,5.344,1.855c1.301,1.237,1.952,
+	2.892,1.952,4.96C62.827,138.141,62.171,139.8,60.859,141.026zM85.374,150.418l
+	-5.12-8.128h-7.36v8.128h-2.4v-21.184h10.144c2.155,0,3.883,0.597,5.184,1.792c
+	1.301,1.173,1.952,2.783,1.952,4.832c0,2.646-1.099,4.447-3.296,5.407c-0.619,
+	0.278-1.227,0.48-1.824,0.608l5.568,8.544H85.374zM98.791,150.418h-2.4v-21.184
+	h2.4V150.418zM122.361,149.106c-1.483,1.045-3.536,1.567-6.16,1.567c-2.965,0
+	-5.227-0.618-6.784-1.855c-1.387-1.109-2.176-2.688-2.367-4.736h2.495c0.086,
+	1.451,0.789,2.56,2.112,3.328c1.152,0.661,2.677,0.992,4.576,0.992c3.968,0,
+	5.952-1.248,5.952-3.744c0-0.854-0.357-1.525-1.072-2.017c-0.715-0.49-1.611
+	-0.896-2.688-1.216c-1.078-0.319-2.24-0.618-3.488-0.896s-2.411-0.635-3.488
+	-1.072s-1.974-1.013-2.688-1.729c-0.715-0.714-1.072-1.68-1.072-2.896c0-1.728,
+	0.661-3.136,1.984-4.224c1.322-1.089,3.316-1.633,5.983-1.633c2.688,0,4.769,
+	0.619,6.24,1.856c1.344,1.088,2.059,2.485,2.144,4.192h-2.464c-0.213-1.749
+	-1.344-2.912-3.392-3.488c-0.726-0.213-1.627-0.32-2.704-0.32s-1.984,0.123
+	-2.72,0.368c-0.736,0.245-1.308,0.544-1.712,0.896c-0.406,0.352-0.678,0.741
+	-0.816,1.168s-0.208,0.88-0.208,1.359c0,0.48,0.208,0.923,0.624,1.328s0.965,
+	0.747,1.648,1.024c0.682,0.277,1.461,0.522,2.336,0.735c0.874,0.214,1.765,
+	0.433,2.672,0.656c0.906,0.224,1.797,0.48,2.672,0.768c0.874,0.288,1.653,0.656
+	,2.336,1.104c1.515,0.96,2.271,2.272,2.271,3.936C124.585,146.546,123.844,
+	148.061,122.361,149.106zM151.199,150.418v-17.536l-7.84,10.08l-7.968-10.08v
+	17.536h-2.4v-21.184h2.784l7.584,10.048l7.456-10.048h2.784v21.184H151.199z"/>
+&lt;/svg>
+</code></pre>
 </section>
 
 <footer data-src="templates/footer.html" data-type="text/html"></footer>
diff --git a/plugins/show-language/prism-show-language.js b/plugins/show-language/prism-show-language.js
index 5ab50cf..735d6e1 100644
--- a/plugins/show-language/prism-show-language.js
+++ b/plugins/show-language/prism-show-language.js
@@ -11,7 +11,7 @@ Prism.hooks.add('before-highlight', function(env) {
 	if (!pre || !/pre/i.test(pre.nodeName)) {
 		return;
 	}
-	var language = Languages[env.language] || (env.language.substring(0, 1).toUpperCase() + env.language.substring(1));
+	var language = pre.getAttribute('data-language') || Languages[env.language] || (env.language.substring(0, 1).toUpperCase() + env.language.substring(1));
 
 	/* check if the divs already exist */
 	var sib = pre.previousSibling;