Pretty print with nokogiri
This commit is contained in:
@@ -1,2 +1,5 @@
|
||||
<ol class="tree">
|
||||
<li class="file"><a href="0"><span class="icon"></span>0</a></li></ol>
|
||||
<li class="file">
|
||||
<a href="0"><span class="icon"></span>0</a>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
<ol class="tree">
|
||||
<li>
|
||||
<label>folder0</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="folder0/0"><span class="icon"></span>0</a></li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
<li>
|
||||
<label>folder0</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li class="file">
|
||||
<a href="folder0/0"><span class="icon"></span>0</a>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
<ol class="tree">
|
||||
<li>
|
||||
<label>.</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="folder0"><span class="icon"></span>folder0</a></li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
<li>
|
||||
<label>.</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li class="file">
|
||||
<a href="folder0"><span class="icon"></span>folder0</a>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
<ol class="tree">
|
||||
<li>
|
||||
<label>folder0</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="folder0/0"><span class="icon"></span>0</a></li></ol></li>
|
||||
<li>
|
||||
<label>folder1</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="folder1/1"><span class="icon"></span>1</a></li></ol>
|
||||
<li>
|
||||
<label>folder0</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li class="file">
|
||||
<a href="folder0/0"><span class="icon"></span>0</a>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<label>folder1</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li class="file">
|
||||
<a href="folder1/1"><span class="icon"></span>1</a>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
@@ -1,9 +1,23 @@
|
||||
<ol class="tree">
|
||||
<li class="file"><a href="root"><span class="icon"></span>root</a></li> <li>
|
||||
<label>folder0</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="folder0/0"><span class="icon"></span>0</a></li></ol></li>
|
||||
<li>
|
||||
<label>folder1</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="folder1/1"><span class="icon"></span>1</a></li></ol>
|
||||
<li class="file">
|
||||
<a href="root"><span class="icon"></span>root</a>
|
||||
</li>
|
||||
<li>
|
||||
<label>folder0</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li class="file">
|
||||
<a href="folder0/0"><span class="icon"></span>0</a>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<label>folder1</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li class="file">
|
||||
<a href="folder1/1"><span class="icon"></span>1</a>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
@@ -1,21 +1,41 @@
|
||||
<ol class="tree">
|
||||
<li>
|
||||
<label>folder0</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li>
|
||||
<label>folder0</label> <input type="checkbox" checked />
|
||||
<label>folder1</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li>
|
||||
<label>folder1</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li>
|
||||
<label>folder2</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="folder0/folder1/folder2/0"><span class="icon"></span>0</a></li></ol></li>
|
||||
<li>
|
||||
<label>folder3</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="folder0/folder1/folder3/1"><span class="icon"></span>1</a></li></ol></li>
|
||||
</ol></li>
|
||||
</ol></li>
|
||||
<li>
|
||||
<label>folder4</label> <input type="checkbox" checked />
|
||||
<ol>
|
||||
<li class="file"><a href="folder4/2"><span class="icon"></span>2</a></li></ol>
|
||||
<li>
|
||||
<label>folder2</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li class="file">
|
||||
<a href="folder0/folder1/folder2/0"><span class="icon"></span>0</a>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<label>folder3</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li class="file">
|
||||
<a href="folder0/folder1/folder3/1"><span class="icon"></span>1</a>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
<li>
|
||||
<label>folder4</label>
|
||||
<input type="checkbox" />
|
||||
<ol>
|
||||
<li class="file">
|
||||
<a href="folder4/2"><span class="icon"></span>2</a>
|
||||
</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
+13
-1
@@ -68,10 +68,22 @@ def write file, content
|
||||
end
|
||||
end
|
||||
|
||||
@@format_xslt = File.expand_path(File.join(File.dirname(__FILE__), 'format.xslt'))
|
||||
|
||||
def to_html html
|
||||
# Remove blank nodes for proper formatting
|
||||
doc = Nokogiri.XML(html) do |cfg|
|
||||
cfg.default_xml.noblanks
|
||||
end
|
||||
|
||||
# Save as XHTML
|
||||
doc.to_xml( { :save_with => Nokogiri::XML::Node::SaveOptions::DEFAULT_XHTML, :indent => 2, :encoding => 'UTF-8' } )
|
||||
end
|
||||
|
||||
def check name, pages_array
|
||||
pages = FakePages.new pages_array
|
||||
expected = read name
|
||||
actual = view pages
|
||||
actual = to_html view pages
|
||||
|
||||
# Uncomment when updating tests
|
||||
# write name, actual
|
||||
|
||||
Reference in New Issue
Block a user