diff --git a/_plugins/bidirectional_links_generator.rb b/_plugins/bidirectional_links_generator.rb index 0826d9b..b7f28ed 100644 --- a/_plugins/bidirectional_links_generator.rb +++ b/_plugins/bidirectional_links_generator.rb @@ -15,15 +15,15 @@ class BidirectionalLinksGenerator < Jekyll::Generator all_docs.each do |note_potentially_linked_to| # Replace double-bracketed links using note title current_note.content = current_note.content.gsub( - /\[\[#{note_potentially_linked_to.data['title']}\]\]/i, - "#{note_potentially_linked_to.data['title']}" + /\[\[(#{note_potentially_linked_to.data['title']})\]\]/i, + "\\1" ) # Replace double-bracketed links using note filename title_from_filename = File.basename(note_potentially_linked_to.basename, File.extname(note_potentially_linked_to.basename)).gsub('_', ' ').gsub('-', ' ').capitalize current_note.content = current_note.content.gsub( - /\[\[#{title_from_filename}\]\]/i, - "#{title_from_filename}" + /\[\[(#{title_from_filename})\]\]/i, + "\\1" ) end