From cc33d814738c1fa992a47bb3a4bfc1af7be76887 Mon Sep 17 00:00:00 2001 From: Dawa Ometto Date: Thu, 29 Aug 2019 14:10:54 +0200 Subject: [PATCH] Refactor --- lib/gollum/public/gollum/javascript/gollum.js.erb | 2 +- lib/gollum/views/helpers.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/gollum/public/gollum/javascript/gollum.js.erb b/lib/gollum/public/gollum/javascript/gollum.js.erb index dfccf79b..04dc34dd 100755 --- a/lib/gollum/public/gollum/javascript/gollum.js.erb +++ b/lib/gollum/public/gollum/javascript/gollum.js.erb @@ -486,7 +486,7 @@ $(document).ready(function() { // Set text direction auto $('.markdown-body p, .markdown-body span, .markdown-body pre, .markdown-body table').attr('dir','auto'); - // Copy anchors for each editable header and give it the new anchor the 'edit' class, to display a link to edit the section + // Copy anchors for each editable header and give the new anchor the 'edit' class, to display an "edit section" link $('a.anchor').each(function (index, anchor) { header = $(anchor).closest(':header'); if (header.hasClass('editable')){ diff --git a/lib/gollum/views/helpers.rb b/lib/gollum/views/helpers.rb index 9706b851..77bd39c4 100644 --- a/lib/gollum/views/helpers.rb +++ b/lib/gollum/views/helpers.rb @@ -52,11 +52,11 @@ module Precious Octicons::Octicon.new(symbol, parameters).to_svg end + # Well-formed SVG with XMLNS and height/width removed, for use in CSS def rocticon_css(symbol, parameters = {}) - html = rocticon(symbol, parameters.merge({xmlns: 'http://www.w3.org/2000/svg'})) - html.gsub!(/\s*(width|height)=["']\d+["']\s*/, ' ') # remove height and width attributes so it can be set via CSS - html.gsub!(/\s+/, ' ') - html.force_encoding('UTF-8') + octicon = Octicons::Octicon.new(symbol, parameters.merge({xmlns: 'http://www.w3.org/2000/svg'})) + [:width, :height].each {|option| octicon.options.delete(option)} + octicon.to_svg end def octicon