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.split()
print "\n".join(["<ul>"] + [wrap(line) for line in sys.stdin] + ["</ul>"])
Set the input to selection or line. If you want some snippet tab action to enter something in as URL's for the <a>'s, that isn't too hard.
-Jacob