Jacob Rus wrote:
Dave Foy wrote:
I'm having trouble creating a custom snippet that, for me, would be really useful.
I want to set up a snippet to create an unordered list nav from a plain text list, e.g.
I'd like to highlight the whole list, hit a key combo, which would wrap each list item in <li>, wrap the whole lot in <ul>, and even wrap the text within each list item in <a href=""></a> for good measure.
Here's the command I came up with:
#!/usr/bin/env python import sys def wrap(string): return '\t<li><a href="">%s</a></li>' % string.strip() print "\n".join(["<ul>"] + [wrap(line) for line in sys.stdin] + ["</ul>"])
Actually, the following is probably clearer and easier to change, without any knowledge of python:
#!/usr/bin/env python import sys
for line in sys.stdin: print '\t<li><a href="">' + line.strip() + '</a></li>'