Commit 67b89eaf0ff666573261b7856b262c4cf26f8bc9

Jannik Zschiesche 2015-06-01T18:45:17

Handlebars: support blocks with dashes

diff --git a/components/prism-handlebars.js b/components/prism-handlebars.js
index 3154940..00fe771 100644
--- a/components/prism-handlebars.js
+++ b/components/prism-handlebars.js
@@ -1,7 +1,7 @@
 (function(Prism) {
 
 	var handlebars_pattern = /\{\{\{[\w\W]+?\}\}\}|\{\{[\w\W]+?\}\}/g;
-	
+
 	Prism.languages.handlebars = Prism.languages.extend('markup', {
 		'handlebars': {
 			pattern: handlebars_pattern,
@@ -14,7 +14,7 @@
 				'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,
 				'boolean': /\b(true|false)\b/,
 				'block': {
-					pattern: /^(\s*~?\s*)[#\/]\w+/i,
+					pattern: /^(\s*~?\s*)[#\/]\S+/i,
 					lookbehind: true,
 					alias: 'keyword'
 				},
diff --git a/components/prism-handlebars.min.js b/components/prism-handlebars.min.js
index d303e50..acafd0c 100644
--- a/components/prism-handlebars.min.js
+++ b/components/prism-handlebars.min.js
@@ -1 +1 @@
-!function(e){var a=/\{\{\{[\w\W]+?\}\}\}|\{\{[\w\W]+?\}\}/g;e.languages.handlebars=e.languages.extend("markup",{handlebars:{pattern:a,inside:{delimiter:{pattern:/^\{\{\{?|\}\}\}?$/i,alias:"punctuation"},string:/(["'])(\\?.)+?\1/,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,"boolean":/\b(true|false)\b/,block:{pattern:/^(\s*~?\s*)[#\/]\w+/i,lookbehind:!0,alias:"keyword"},brackets:{pattern:/\[[^\]]+\]/,inside:{punctuation:/\[|\]/,variable:/[\w\W]+/}},punctuation:/[!"#%&'()*+,.\/;<=>@\[\\\]^`{|}~]/,variable:/[^!"#%&'()*+,.\/;<=>@\[\\\]^`{|}~]+/}}}),e.languages.insertBefore("handlebars","tag",{"handlebars-comment":{pattern:/\{\{![\w\W]*?\}\}/,alias:["handlebars","comment"]}}),e.hooks.add("before-highlight",function(e){"handlebars"===e.language&&(e.tokenStack=[],e.backupCode=e.code,e.code=e.code.replace(a,function(a){return e.tokenStack.push(a),"___HANDLEBARS"+e.tokenStack.length+"___"}))}),e.hooks.add("before-insert",function(e){"handlebars"===e.language&&(e.code=e.backupCode,delete e.backupCode)}),e.hooks.add("after-highlight",function(a){if("handlebars"===a.language){for(var n,t=0;n=a.tokenStack[t];t++)a.highlightedCode=a.highlightedCode.replace("___HANDLEBARS"+(t+1)+"___",e.highlight(n,a.grammar,"handlebars"));a.element.innerHTML=a.highlightedCode}})}(Prism);
\ No newline at end of file
+!function(e){var a=/\{\{\{[\w\W]+?\}\}\}|\{\{[\w\W]+?\}\}/g;e.languages.handlebars=e.languages.extend("markup",{handlebars:{pattern:a,inside:{delimiter:{pattern:/^\{\{\{?|\}\}\}?$/i,alias:"punctuation"},string:/(["'])(\\?.)+?\1/,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/,"boolean":/\b(true|false)\b/,block:{pattern:/^(\s*~?\s*)[#\/]\S+/i,lookbehind:!0,alias:"keyword"},brackets:{pattern:/\[[^\]]+\]/,inside:{punctuation:/\[|\]/,variable:/[\w\W]+/}},punctuation:/[!"#%&'()*+,.\/;<=>@\[\\\]^`{|}~]/,variable:/[^!"#%&'()*+,.\/;<=>@\[\\\]^`{|}~]+/}}}),e.languages.insertBefore("handlebars","tag",{"handlebars-comment":{pattern:/\{\{![\w\W]*?\}\}/,alias:["handlebars","comment"]}}),e.hooks.add("before-highlight",function(e){"handlebars"===e.language&&(e.tokenStack=[],e.backupCode=e.code,e.code=e.code.replace(a,function(a){return e.tokenStack.push(a),"___HANDLEBARS"+e.tokenStack.length+"___"}))}),e.hooks.add("before-insert",function(e){"handlebars"===e.language&&(e.code=e.backupCode,delete e.backupCode)}),e.hooks.add("after-highlight",function(a){if("handlebars"===a.language){for(var n,t=0;n=a.tokenStack[t];t++)a.highlightedCode=a.highlightedCode.replace("___HANDLEBARS"+(t+1)+"___",e.highlight(n,a.grammar,"handlebars"));a.element.innerHTML=a.highlightedCode}})}(Prism);
\ No newline at end of file
diff --git a/examples/prism-handlebars.html b/examples/prism-handlebars.html
index ec7d31d..49c5096 100644
--- a/examples/prism-handlebars.html
+++ b/examples/prism-handlebars.html
@@ -26,8 +26,12 @@
 {{/with}}
 &lt;div class="{{#if test}}foo{{else}}bar{{/if}}">&lt;/div>
 {{#list array}}
-  {{@index}}. {{title}}
-{{/list}}</code></pre>
+	{{@index}}. {{title}}
+{{/list}}
+{{#block-with-hyphens args=yep}}
+	This should probably work...
+{{/block-with-hyphens}}
+</code></pre>
 
 <h2>Known failures</h2>
 <p>There are certain edge cases where Prism will fail.
@@ -37,4 +41,4 @@
 </p>
 
 <h3>Handlebars tag in the middle of an HTML tag</h3>
-<pre><code>&lt;div{{#if test}} class="test"{{/if}}>&lt;/div></code></pre>
\ No newline at end of file
+<pre><code>&lt;div{{#if test}} class="test"{{/if}}>&lt;/div></code></pre>