This might be difficult - HTML is weeded out right at the start of processing, and there aren't many useful hooks before it. (At least I don't recall any.) What you could do is add your own BB code with external callback (see hook bbcode_fetch_tags) and use that tag with an ID or something as the parameter. Then in your callback function, use this ID to return the actual content.