Skip to content

Commit 4671fea

Browse files
committed
improves formatting of indented conditionals
1 parent 214ddce commit 4671fea

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/jekyll-theme-cs50.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,12 @@ def relative_url(input)
388388
ENV["TZ"] = $site.config["cs50"]["tz"]
389389
end
390390

391+
# Trim whitespace from indented conditionals, so that LI tags aren't wrapped with P tags
392+
page.content.gsub!(/^(\s+){%\s*(if .*?[^\-])\s*%}(\s*)$/, '\1{% \2 -%}\3')
393+
page.content.gsub!(/^(\s+){%\s*(elsif .*?[^\-])\s*%}(\s*)$/, '\1{%- \2 -%}\3')
394+
page.content.gsub!(/^(\s+){%\s*(else)\s*%}(\s*)$/, '\1{%- \2 -%}\3')
395+
page.content.gsub!(/^(\s+){%\s*(endif)\s*%}(\s*)$/, '\1{%- \2 %}\3')
396+
391397
end
392398

393399
Jekyll::Hooks.register :site, :after_reset do |site|

0 commit comments

Comments
 (0)