##// END OF EJS Templates
better regex replacement for MarkdownCell.set_heading_level...
MinRK -
Show More
@@ -226,16 +226,9 b' define(['
226 // make a markdown cell a heading
226 // make a markdown cell a heading
227 level = level || 1;
227 level = level || 1;
228 var source = this.get_text();
228 var source = this.get_text();
229 // \s\S appears to be the js version of multi-line dot-all
229 source = source.replace(/^(#*)\s?/,
230 var match = source.match(/(#*)\s*([\s\S]*)/);
230 new Array(level + 1).join('#') + ' ');
231 // strip the leading `#` if it's already there
231 this.set_text(source);
232 if (match) {
233 source = match[2];
234 }
235 // add `#` markdown heading prefix
236 var new_text = new Array(level + 1).join('#') + ' ' + source;
237
238 this.set_text(new_text);
239 this.refresh();
232 this.refresh();
240 if (this.rendered) {
233 if (this.rendered) {
241 this.render();
234 this.render();
General Comments 0
You need to be logged in to leave comments. Login now