Q:

Sleek way of un/commenting out html tags in markdown

I'm trying to find a nice way of wrapping html tags in html comments without writing 5 functions and 50 lines of code. Using an example code :
<section class="left span9">
### Test
</section>

I need to transform it to :
<!--<section class="left span9">-->
### Test
<!--</section>-->

I have a regex to find the tags
re.findall('<.*?>', str)

but in the last years I wasn't using lambdas too often so now I'm having a hard time getting it to work. 
btw any ideas for the reverse of this process - decommenting the tags ?

A:

You can comment/uncomment using simple replace like this
myString = '<section class="left span9">'
print myString.replace("<", "<!--<").replace(">", ">-->")
print myString.replace("<!--", "").replace("-->", "")

Output:
<!--<section class="left span9">-->
<section class="left span9">

Note: This works because, a valid HTML document should have < and > only in the HTML tags. If they should appear, as they are, in the output, they have to be properly HTML escaped with &gt; and &lt;

