def find_tag(wikitext, tagname, pos=0):
- """Returns the tuple (start, end) of the first occurence of the tag '<tag ...>...</tag>'
+ """Returns position information of the first occurence of the tag '<tag ...>...</tag>'
or '<tag ... />'.
- (None, None) is returned if the tag is not found.
If you are sure that the wikitext contains the tag, the tag could be extracted like follows:
>>> wikitext = u'This is a <tag>mytag</tag> tag.'
- >>> start, end = find_template(wikitext, u'tag')
+ >>> start, content, endtag, end = find_template(wikitext, u'tag')
>>> print wikitext[start:end]
<tag>mytag</tag>