david
public python v1 · immutabledef _in_tag(text, tag): """Extracts text from inside a tag. This function extracts the text from inside a given tag. It's useful to get the text between <body></body> or <pre></pre> when using the validators or the colorizer. """ if text.count('<%s' % tag): text = text.split('<%s' % tag, 1)[1] if text.count('>'): text = text.split('>', 1)[1] if text.count('</%s' % tag): text = text.split('</%s' % tag, 1)[0] text = text.strip().replace('\r\n', '\n') return text