File tree Expand file tree Collapse file tree
lib/docs/filters/tanstack
test/lib/docs/filters/tanstack Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,6 +32,11 @@ def call
3232 flatten_code ( node )
3333 end
3434
35+ css ( 'span.border.rounded[class~="bg-gray-500/10"]' ) . each do |node |
36+ node . name = 'code'
37+ node . remove_attribute ( 'class' )
38+ end
39+
3540 # Copy buttons and any "on this page" control that lived inside the prose.
3641 # External links, including StackBlitz, stay.
3742 css ( 'button' ) . remove
Original file line number Diff line number Diff line change @@ -56,6 +56,23 @@ class TanstackCleanHtmlFilterTest < Minitest::Spec
5656 assert_nil filter_output . at_css ( '._pre-heading' )
5757 end
5858
59+ it 'turns inline markdown code spans into code' do
60+ @body = <<-HTML
61+ < h1 > Important Defaults</ h1 >
62+ < div class ="prose ">
63+ < h3 id ="opts-from "> opts.< span class ="border border-gray-500/20 bg-gray-500/10 rounded px-1 py-0.5 "> from</ span > option</ h3 >
64+ < p > Set < span class ="border border-gray-500/20 bg-gray-500/10 rounded px-1 py-0.5 "> staleTime</ span > to < span class ="font-bold "> avoid</ span > refetches.</ p >
65+ </ div >
66+ HTML
67+
68+ output = filter_output
69+ codes = output . css ( 'code' )
70+ assert_equal %w( from staleTime ) , codes . map ( &:content )
71+ assert codes . none? { |node | node [ 'class' ] }
72+ assert_equal 'opts.from option' , output . at_css ( 'h3' ) . content
73+ assert_equal 'avoid' , output . at_css ( 'p > span' ) . content
74+ end
75+
5976 it 'keeps a code block title that is not the language' do
6077 @body = <<-HTML
6178 < h1 > Routing Concepts</ h1 >
You can’t perform that action at this time.
0 commit comments