Skip to content

Commit 986f53f

Browse files
committed
fix: HTML5 audio not supported (#49)
1 parent 30fc359 commit 986f53f

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,14 @@ def handle_audio(element, data)
178178
" #{cfg['loop'] ? 'loop' : ''}"\
179179
" src=\"#{cfg['src']}\""\
180180
" style=\"#{cfg['style']}\""\
181-
" controls=\"true\">" \
182-
"<p> Your browser doesn't support HTML5 audio."\
181+
" controls>" \
182+
" Your browser doesn't support HTML5 audio."\
183183
" Here is a <a href=\"#{cfg['src']}\">link to download the audio</a>"\
184-
" instead. </p>"\
184+
" instead."\
185185
"</audio>"
186-
doc = Nokogiri::XML(html)
187-
element.replace(doc.children.first)
186+
doc = Nokogiri::HTML(html)
187+
return if element.parent.nil?
188+
element.replace(doc.at('body').children.first)
188189
end
189190

190191
def handle_iframe(element, data)
@@ -201,8 +202,9 @@ def handle_iframe(element, data)
201202
" frameborder=\"#{cfg['frameborder']}\""\
202203
" allowfullscreen>"\
203204
"</iframe>"
204-
doc = Nokogiri::XML(html)
205-
element.replace(doc.children.first)
205+
doc = Nokogiri::HTML(html)
206+
return if element.parent.nil?
207+
element.replace(doc.at('body').children.first)
206208
end
207209

208210
def get_id_from_html(url, pattern)

0 commit comments

Comments
 (0)