From af46adfa416937e9348514c931ac52d158ca7a16 Mon Sep 17 00:00:00 2001 From: MasterEnoc Date: Sun, 13 Dec 2020 11:27:09 -0600 Subject: [PATCH] Improve syntax highlight of Sass --- lib/docs/filters/sass/clean_html.rb | 56 +++-------------------------- 1 file changed, 5 insertions(+), 51 deletions(-) diff --git a/lib/docs/filters/sass/clean_html.rb b/lib/docs/filters/sass/clean_html.rb index db5c11ab..9f6c53fe 100644 --- a/lib/docs/filters/sass/clean_html.rb +++ b/lib/docs/filters/sass/clean_html.rb @@ -39,62 +39,16 @@ module Docs css('.visuallyhidden').remove ### Syntax Highlight ### - css('.kt').each do |node| - node.remove_attribute('class') - node.add_class('token constant') + css('.highlight.scss', '.highlight.sass').each do |node| + node['data-language'] = 'scss' end - css('.k, .kn, .kc, .cp, .ow').each do |node| - node.remove_attribute('class') - node.add_class('token keyword') - end - - css('.nv, .no').each do |node| - node.remove_attribute('class') - node.add_class('token variable') - end - - css('.nb, .n').each do |node| - node.remove_attribute('class') - node.add_class('token string') - end - - css('.p').each do |node| - node.remove_attribute('class') - node.add_class('token punctuation') - end - - css('.nf').each do |node| - node.remove_attribute('class') - node.add_class('token function') - end - - css('.o').each do |node| - node.remove_attribute('class') - node.add_class('token operator') - end - - css('.c1, .cm, .c').each do |node| - node.remove_attribute('class') - node.add_class('token comment') - end - - css('.mh, .m, .mi').each do |node| - node.remove_attribute('class') - node.add_class('token number') - end - - css('.nc, .nt').each do |node| - node.remove_attribute('class') - node.add_class('token selector') - end - - css('.nl').each do |node| - node.remove_attribute('class') - node.add_class('token property') + css('.highlight.css').each do |node| + node['data-language'] = 'css' end doc + end end end