Skip to content

Commit

Permalink
Ensure boolean Macro arguments are parsed as boolean. Resolves #441 (#…
Browse files Browse the repository at this point in the history
…447)

* Ensure Macro boolean arguments are parsed as boolean.
* Drop CI support for Ruby 2.6
* Also drop support for JRuby 9.3, which is compatible with Ruby 2.6
  • Loading branch information
dometto authored and Dawa Ometto committed Aug 1, 2023
1 parent b300639 commit 4c7e282
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
7 changes: 7 additions & 0 deletions LATEST_CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,11 @@
>>>>>>> 462ce53 (Implement default branch detection, move away from master as default. (#424))
=======
* Support use of commit notes in Gollum::Committer. (@dometto, @bartkamphorst)
<<<<<<< HEAD
>>>>>>> 8384b51 (Support for git notes (#435))
=======

### Bugfixes

* Fix the use of boolean arguments in Macros. #441. (@dometto)
>>>>>>> 0db2ff5 (Ensure boolean Macro arguments are parsed as boolean. Resolves #441 (#447))
19 changes: 12 additions & 7 deletions lib/gollum-lib/filter/macro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ def extract(data)
argstr.scan(/,?\s*(#{arg})\s*/) do |arguments|
# Stabstabstab
argument = arguments.first

if argument =~ /^([a-z0-9_]+)="(.*?)"/
opts[Regexp.last_match[1]] = Regexp.last_match[2]
elsif argument =~ /^"(.*)"$/
args << Regexp.last_match[1].gsub("\\\"", "\"")
else
args << argument

case argument
in /^([a-z0-9_]+)="(.*?)"/
opts[Regexp.last_match[1]] = Regexp.last_match[2]
in /^"(.*)"$/
args << Regexp.last_match[1].gsub("\\\"", "\"")
in /\s*false\s*/
args << false
in /\s*true\s*/
args << true
else
args << argument
end
end

Expand Down
7 changes: 7 additions & 0 deletions test/test_macros.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ def render(opts)
assert_match /<div class="toc"><div class="toc-title">Navigate this directory<\/div><ul><li><a href="\/NavigationMacroPage.md" rel="nofollow">NavigationMacroPage.md<\/a><\/li><li><a href="\/ZZZZ\/A\.md" rel="nofollow">ZZZZ\/A\.md<\/a><\/li><\/ul><\/div>/, @wiki.pages[0].formatted_data
end

test "Navigation macro does not show full path if parameter full_path is set to false" do
# This is also a regression test against https://github.com/gollum/gollum-lib/issues/446
@wiki.write_page("NavigationMacroPage", :markdown, '<<Navigation("My TOC", "ZZZZ", false)>>', commit_details)
@wiki.write_page("ZZZZ/A", :markdown, "content", commit_details)
assert_match /<div class="toc"><div class="toc-title">My TOC<\/div><ul><li><a href="\/ZZZZ\/A\.md" rel="nofollow">A\.md<\/a><\/li><\/ul><\/div>/, @wiki.pages[0].formatted_data
end

test "Series macro displays series links with and without series prefix" do
@wiki.write_page("test-series1", :markdown, "<<Series(test)>>", commit_details)
testseries1 = @wiki.page("test-series1")
Expand Down

0 comments on commit 4c7e282

Please sign in to comment.