Skip to content

Commit b376452

Browse files
committed
Merge pull request #84 from jbarnette/patch-1
Guard against nil node replacement results
2 parents f778374 + 95350d7 commit b376452

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/html/pipeline/syntax_highlight_filter.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ def call
1919
html = highlight_with_timeout_handling(lexer, text)
2020
next if html.nil?
2121

22-
node = node.replace(html).first
23-
klass = node["class"]
24-
klass = [klass, "highlight-#{lang}"].compact.join " "
22+
if (node = node.replace(html).first)
23+
klass = node["class"]
24+
klass = [klass, "highlight-#{lang}"].compact.join " "
2525

26-
node["class"] = klass
26+
node["class"] = klass
27+
end
2728
end
2829
doc
2930
end

0 commit comments

Comments
 (0)