Trim code snippet comments.

This commit is contained in:
John-David Dalton
2016-09-10 13:08:45 -07:00
parent 8fa23a94a0
commit 0163aae357

View File

@@ -135,12 +135,15 @@ function tidyHighlights($) {
const attr = _.intersection(classes, highlights[ext]).join(' '); const attr = _.intersection(classes, highlights[ext]).join(' ');
$element.attr('class', attr || null); $element.attr('class', attr || null);
}); });
// Collapse nested highlights. // Collapse nested comment highlights.
_.each(['comment', 'string'], cls => { $parent.find(`[class~="comment"]`).each(function() {
$parent.find(`[class~="${ cls }"]`).each(function() { const $element = $(this);
const $element = $(this); $element.text($element.text().trim());
$element.text($element.text()); });
}); // Collapse nested string highlights.
$parent.find(`[class~="string"]`).each(function() {
const $element = $(this);
$element.text($element.text());
}); });
// Collapse nested spans. // Collapse nested spans.
while (($spans = $parent.find('span:not([class])')).length) { while (($spans = $parent.find('span:not([class])')).length) {
@@ -172,7 +175,7 @@ function build() {
const $ = marky(markdown, { 'sanitize': false }); const $ = marky(markdown, { 'sanitize': false });
const $header = $('h1').first().remove(); const $header = $('h1').first().remove();
const version = _.trim($header.find('span').first().text()).slice(1); const version = $header.find('span').first().text().trim().slice(1);
// Auto-link Lodash method references. // Auto-link Lodash method references.
autoLink($); autoLink($);
@@ -198,7 +201,7 @@ function build() {
'', '',
// Wrap in raw tags to avoid Liquid template tag processing. // Wrap in raw tags to avoid Liquid template tag processing.
'{% raw %}', '{% raw %}',
_.trim($.html()), $.html().trim(),
'{% endraw %}', '{% endraw %}',
'' ''
].join('\n'); ].join('\n');