From 8514601d06c6f8342f37c3543c69f1b09e213f4d Mon Sep 17 00:00:00 2001 From: manunamz <75578970+manunamz@users.noreply.github.com> Date: Fri, 11 Jun 2021 20:51:41 -0400 Subject: [PATCH] gsub -> gsub! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In case you were exerting a coding style opinion, feel free to ignore this pull request. The following are equivalent, as far as I understand, so some chars can be deleted 🙂: `current_note.content = current_note.content.gsub()` == `current_note.content.gsub!()` --- _plugins/bidirectional_links_generator.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/_plugins/bidirectional_links_generator.rb b/_plugins/bidirectional_links_generator.rb index 1d89e00..1e739c9 100644 --- a/_plugins/bidirectional_links_generator.rb +++ b/_plugins/bidirectional_links_generator.rb @@ -25,28 +25,28 @@ class BidirectionalLinksGenerator < Jekyll::Generator # Replace double-bracketed links with label using note title # [[A note about cats|this is a link to the note about cats]] - current_note.content = current_note.content.gsub( + current_note.content.gsub!( /\[\[#{title_from_filename}\|(.+?)(?=\])\]\]/i, anchor_tag ) # Replace double-bracketed links with label using note filename # [[cats|this is a link to the note about cats]] - current_note.content = current_note.content.gsub( + current_note.content.gsub!( /\[\[#{note_potentially_linked_to.data['title']}\|(.+?)(?=\])\]\]/i, anchor_tag ) # Replace double-bracketed links using note title # [[a note about cats]] - current_note.content = current_note.content.gsub( + current_note.content.gsub!( /\[\[(#{note_potentially_linked_to.data['title']})\]\]/i, anchor_tag ) # Replace double-bracketed links using note filename # [[cats]] - current_note.content = current_note.content.gsub( + current_note.content.gsub!( /\[\[(#{title_from_filename})\]\]/i, anchor_tag ) @@ -55,7 +55,7 @@ class BidirectionalLinksGenerator < Jekyll::Generator # At this point, all remaining double-bracket-wrapped words are # pointing to non-existing pages, so let's turn them into disabled # links by greying them out and changing the cursor - current_note.content = current_note.content.gsub( + current_note.content.gsub!( /\[\[(.*)\]\]/i, # match on the remaining double-bracket links <<~HTML.chomp # replace with this HTML (\\1 is what was inside the brackets)