From 06bb8b9ea68568b0432fb87590cb63fbf05fd8b1 Mon Sep 17 00:00:00 2001 From: Elliot Wirrick Date: Tue, 23 Feb 2021 02:46:05 -0500 Subject: [PATCH] moneropedia.rb: replace hyperlink text with regex match --- _plugins/moneropedia.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/_plugins/moneropedia.rb b/_plugins/moneropedia.rb index 0370037e..47ddcc7f 100644 --- a/_plugins/moneropedia.rb +++ b/_plugins/moneropedia.rb @@ -120,14 +120,14 @@ module Jekyll if lang != "en" @@moneropedia[lang].each do |entry| entry[:terms].each do |term| - content = content.gsub(/(\@#{term})((?=-#{lookahead})|(?![\w-]))/i, '' + term.gsub('-',' ') + '') + content = content.gsub(/(\@#{term})((?=-#{lookahead})|(?![\w-]))/i) { |match_term| '' + match_term.gsub(/[@-]/, '@' => '', '-' => ' ') + '' } end end end # For English and as a default (in case an entry has been forgotten in a non-English moneropedia folder) @@moneropedia["en"].each do |entry| entry[:terms].each do |term| - content = content.gsub(/(\@#{term})((?=-#{lookahead})|(?![\w-]))/i, '' + term.gsub('-',' ') + '') + content = content.gsub(/(\@#{term})((?=-#{lookahead})|(?![\w-]))/i) { |match_term| '' + match_term.gsub(/[@-]/, '@' => '', '-' => ' ') + '' } end end end @@ -136,4 +136,4 @@ module Jekyll end end end -end \ No newline at end of file +end