Added comments support

This commit is contained in:
benweet 2014-01-21 23:48:21 +00:00
parent a3b8211b42
commit d60e32dd01
3 changed files with 24 additions and 1 deletions

View File

@ -24,6 +24,7 @@ define([
"newlines", "newlines",
], ],
intraword: true, intraword: true,
comments: true,
highlighter: "prettify" highlighter: "prettify"
}; };
@ -42,6 +43,7 @@ define([
utils.setInputChecked("#input-markdownextra-strikethrough", hasExtension("strikethrough")); utils.setInputChecked("#input-markdownextra-strikethrough", hasExtension("strikethrough"));
utils.setInputChecked("#input-markdownextra-newlines", hasExtension("newlines")); utils.setInputChecked("#input-markdownextra-newlines", hasExtension("newlines"));
utils.setInputChecked("#input-markdownextra-intraword", markdownExtra.config.intraword); utils.setInputChecked("#input-markdownextra-intraword", markdownExtra.config.intraword);
utils.setInputChecked("#input-markdownextra-comments", markdownExtra.config.comments);
utils.setInputValue("#input-markdownextra-highlighter", markdownExtra.config.highlighter); utils.setInputValue("#input-markdownextra-highlighter", markdownExtra.config.highlighter);
}; };
@ -56,6 +58,7 @@ define([
utils.getInputChecked("#input-markdownextra-strikethrough") && newConfig.extensions.push("strikethrough"); utils.getInputChecked("#input-markdownextra-strikethrough") && newConfig.extensions.push("strikethrough");
utils.getInputChecked("#input-markdownextra-newlines") && newConfig.extensions.push("newlines"); utils.getInputChecked("#input-markdownextra-newlines") && newConfig.extensions.push("newlines");
newConfig.intraword = utils.getInputChecked("#input-markdownextra-intraword"); newConfig.intraword = utils.getInputChecked("#input-markdownextra-intraword");
newConfig.comments = utils.getInputChecked("#input-markdownextra-comments");
newConfig.highlighter = utils.getInputValue("#input-markdownextra-highlighter"); newConfig.highlighter = utils.getInputValue("#input-markdownextra-highlighter");
}; };
@ -76,7 +79,14 @@ define([
}; };
converter.setOptions(converterOptions); converter.setOptions(converterOptions);
} }
if(markdownExtra.config.comments === true) {
converter.hooks.chain("postConversion", function(text) {
return text.replace(/<!--.*?-->/g, function(wholeMatch) {
return wholeMatch.replace(/^<!---(.+?)-?-->$/, ' <span class="comment label label-danger">$1</span> ');
});
});
}
var extraOptions = { var extraOptions = {
extensions: markdownExtra.config.extensions extensions: markdownExtra.config.extensions
}; };

View File

@ -35,6 +35,15 @@
</div> </div>
</div> </div>
</div> </div>
<div class="form-group">
<label class="col-lg-4 control-label"
for="input-markdownextra-comments">Comments</label>
<div class="col-lg-7">
<div class="checkbox">
<input type="checkbox" id="input-markdownextra-comments">
</div>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="col-lg-4 control-label" <label class="col-lg-4 control-label"
for="input-markdownextra-smartypants">SmartyPants</label> for="input-markdownextra-smartypants">SmartyPants</label>

View File

@ -1291,6 +1291,10 @@ input[type="file"] {
height: 120px; height: 120px;
} }
.label.comment {
white-space: inherit;
}
/********************* /*********************
* Bootstrap tour * Bootstrap tour