From 7ae0d0099d21c049e56eeb8c54e3561ef4255ff0 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 21 Aug 2016 23:01:41 -0700 Subject: [PATCH] Reduce highlights class names. --- lib/main/build-site.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/main/build-site.js b/lib/main/build-site.js index 37c1ab045..eada119c6 100644 --- a/lib/main/build-site.js +++ b/lib/main/build-site.js @@ -21,6 +21,22 @@ function build(type) { $header = $('h1').first().remove(), version = _.trim($header.find('span').first().text()).slice(1); + var highlights = [ + 'comment', + 'constant', + 'delimiter', + 'html', + 'js', + 'method', + 'modifier', + 'numeric', + 'shell', + 'source', + 'string', + 'text', + 'type' + ]; + // Remove docdown horizontal rules. $('hr').remove(); @@ -51,6 +67,14 @@ function build(type) { $code.html($code.html().replace(/<\/?em>/g, '_')); }); + // Cleanup highlights class names. + $('.highlight [class]').each(function() { + var $el = $(this), + className = _.intersection($el.attr('class').split(/\s+/), highlights).join(' '); + + $el.attr('class', className || null); + }); + var html = [ // Append YAML front matter. '---',