Algorithm to Extract HTML from script tag content

Job ID: 34475394

Budget: $15 – $16 USD

I have written an HTML parser that extracts tag names and contents, skipping comment, script and style contents altogether. (I gave up on free parsers and it's better to write one yourself anyway.) I now see that some script content contains HTML. I need to know the format for stepping through the script content to get to any HTML content. Just explain it in English. I know only a minimal amount of HTML and only want to extract the text.
Related categories: HTML XHTML