From 6b75881b8cd58b532c36d31893cad8d07355d76f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 6 Nov 2025 22:14:20 +0000 Subject: [PATCH 1/4] Initial plan From abc78c86fa46d8e8ecae759b33bf40d64068fe6c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 6 Nov 2025 22:21:45 +0000 Subject: [PATCH 2/4] Add test fixture for files with spaces in names Co-authored-by: benbalter <282759+benbalter@users.noreply.github.com> --- spec/fixtures/site/page with space.md | 6 ++++++ spec/fixtures/site/page.md | 4 ++++ 2 files changed, 10 insertions(+) create mode 100644 spec/fixtures/site/page with space.md diff --git a/spec/fixtures/site/page with space.md b/spec/fixtures/site/page with space.md new file mode 100644 index 0000000..9e0d376 --- /dev/null +++ b/spec/fixtures/site/page with space.md @@ -0,0 +1,6 @@ +--- +--- + +# Page with space + +[Back to main](page.md) diff --git a/spec/fixtures/site/page.md b/spec/fixtures/site/page.md index b481e24..9334f70 100644 --- a/spec/fixtures/site/page.md +++ b/spec/fixtures/site/page.md @@ -62,3 +62,7 @@ Content end [reference-with-whitespace]: another-page.md [reference-with-title]: another-page.md "This is a reference with a title" + +[Link with raw space](page with space.md) + +[Link with angle brackets]() From fd7525774ba4246e9d0733cd2673c9575d5836cd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 6 Nov 2025 22:27:51 +0000 Subject: [PATCH 3/4] Add support for Markdown links with spaces and angle brackets Co-authored-by: benbalter <282759+benbalter@users.noreply.github.com> --- lib/jekyll-relative-links/generator.rb | 10 +++++++++- spec/fixtures/site/page.md | 4 ++++ spec/jekyll_relative_links/filter_spec.rb | 6 ++++++ spec/jekyll_relative_links/generator_spec.rb | 12 ++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/lib/jekyll-relative-links/generator.rb b/lib/jekyll-relative-links/generator.rb index 0adeeee..88cd888 100644 --- a/lib/jekyll-relative-links/generator.rb +++ b/lib/jekyll-relative-links/generator.rb @@ -78,7 +78,15 @@ def link_parts(matches) relative_path = matches[link_type == :inline ? 3 : last_inline + 2] fragment = matches[link_type == :inline ? 4 : last_inline + 3] title = matches[link_type == :inline ? 5 : last_inline + 4] - Link.new(link_type, link_text, relative_path, fragment, title) + Link.new(link_type, link_text, strip_angle_brackets(relative_path), fragment, title) + end + + # Strip angle brackets from link paths + # Markdown allows angle brackets around URLs: [text]() + def strip_angle_brackets(path) + return path unless path + + path.sub(%r!\A<(.+)>\z!, '\1') end def context diff --git a/spec/fixtures/site/page.md b/spec/fixtures/site/page.md index 9334f70..ddd084b 100644 --- a/spec/fixtures/site/page.md +++ b/spec/fixtures/site/page.md @@ -66,3 +66,7 @@ Content end [Link with raw space](page with space.md) [Link with angle brackets]() + +[Reference with space][ref-space] + +[ref-space]: diff --git a/spec/jekyll_relative_links/filter_spec.rb b/spec/jekyll_relative_links/filter_spec.rb index e2f3497..f551095 100644 --- a/spec/jekyll_relative_links/filter_spec.rb +++ b/spec/jekyll_relative_links/filter_spec.rb @@ -63,6 +63,12 @@ def make_filter expect(filter.rellinks(html)).to eq(html) end + it "handles links with spaces (URL-encoded)" do + html = "

Link with space

" + expected = "

Link with space

" + expect(filter.rellinks(html)).to eq(expected) + end + private def set_subdir_context diff --git a/spec/jekyll_relative_links/generator_spec.rb b/spec/jekyll_relative_links/generator_spec.rb index e11da60..f36e3ed 100644 --- a/spec/jekyll_relative_links/generator_spec.rb +++ b/spec/jekyll_relative_links/generator_spec.rb @@ -55,6 +55,18 @@ expect(page.content).to include("[Page with Symbols?](/page%20with%20symbols?.html)") end + it "converts relative links with raw spaces" do + expect(page.content).to include("[Link with raw space](/page%20with%20space.html)") + end + + it "converts relative links with angle brackets" do + expect(page.content).to include("[Link with angle brackets](/page%20with%20space.html)") + end + + it "converts reference links with angle brackets" do + expect(page.content).to include("[ref-space]: /page%20with%20space.html") + end + it "converts relative links with permalinks" do expect(page.content).to include("[Page with permalink](/page-with-permalink/)") end From 0238688e20e9ce4eb5bf42ceb8fba74e490801c3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 6 Nov 2025 22:29:11 +0000 Subject: [PATCH 4/4] Add detailed documentation for strip_angle_brackets method Co-authored-by: benbalter <282759+benbalter@users.noreply.github.com> --- lib/jekyll-relative-links/generator.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/jekyll-relative-links/generator.rb b/lib/jekyll-relative-links/generator.rb index 88cd888..1a99886 100644 --- a/lib/jekyll-relative-links/generator.rb +++ b/lib/jekyll-relative-links/generator.rb @@ -81,8 +81,21 @@ def link_parts(matches) Link.new(link_type, link_text, strip_angle_brackets(relative_path), fragment, title) end - # Strip angle brackets from link paths - # Markdown allows angle brackets around URLs: [text]() + # Strip angle brackets from link paths to handle GitHub's angle bracket syntax + # + # GitHub UI uses angle brackets to wrap URLs with special characters like spaces: + # [text](). This method removes the wrapping angle brackets + # so the path can be properly matched against files on disk. + # + # @param path [String, nil] The link path that may have angle brackets + # @return [String, nil] The path with angle brackets removed, or the original if no brackets + # + # @example + # strip_angle_brackets("") + # #=> "file with spaces.md" + # + # strip_angle_brackets("regular-file.md") + # #=> "regular-file.md" def strip_angle_brackets(path) return path unless path