Fix for sprint 21+ compatibility, support HTML nested within other languages

Update for sprint 21's language/mode changes (the LanguageManager refactoring changed the mode name you get back for HTML files, but also added new APIs that insulate you from mode names anyway).  Remains compatible with earlier sprints too.

Also, improved this logic to accept any selection of HTML text, even if it's HTML nested within an overall document mode that's some other type (for example, PHP).