Skip to content

Commit 935ce5a

Browse files
committed
feat: optimize scanning mathjax nodes
1 parent a9a7452 commit 935ce5a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/jekyll-spaceship/processors/mathjax-processor.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,19 @@ def scan_mathjax_expression(doc, &block)
123123

124124
# scan mathjax expressions
125125
doc.css('body *').each do |node|
126+
# filter invalid nodes
127+
next if node.children.size == 0
128+
invalid = false
129+
node.children.each do |child|
130+
unless [
131+
'text', 'br', 'span',
132+
'img', 'svg', 'a'
133+
].include? child.name
134+
break invalid = true
135+
end
136+
end
137+
next if invalid
138+
126139
patterns['include'].each do |pattern|
127140
# check normal mathjax expression
128141
node.content.scan(pattern) do |result|

0 commit comments

Comments
 (0)