Skip to content

Commit 7b6c4e3

Browse files
committed
fix: wrong backreference in excluded content (#56)
As Ruby substitution functions (i.e `sub` and `gsub`) support regex. Hence, the backreference of substitution will be performed, so that we should escape any backreference of the substitution (i.e. "\0" to "\\0" ).
1 parent 5004160 commit 7b6c4e3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/jekyll-spaceship/cores/processor.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,10 @@ def post_exclude(content)
192192
while @exclusion_store.size > 0
193193
match = @exclusion_store.pop
194194
id = @exclusion_store.size
195-
content = content.sub("<!JEKYLL@#{object_id}@#{id}>", match)
195+
content = content.sub(
196+
"<!JEKYLL@#{object_id}@#{id}>",
197+
match.gsub(/(\\\d)/,'\\\\\1')
198+
)
196199
end
197200
@exclusion_store = []
198201
content

0 commit comments

Comments
 (0)