Currently, if using the HTML (or PHP) filetype and you're inside a client or server side script block, Geany comments it as HTML when instead it should use the comment style of the embedded language (ex. JS, VB, Python, etc).
The attached patch uses the Scintilla style at the beginning of the current line to determine which language is being used, and if it's a language embedded in HTML, it switches the filetype to use comment characters of the embedded language.
One (existing) bug is that if you have a line with '<script>' or '<?php' for example, that line gets commented with HTML comments, leaving the rest of the document invalid. One way to work around this might be to see if the Scintilla style is a 'start' for an embedded language and if it is, scan the text until the proper end is found and then comment the whole block with HTML comments. I didn't even try this because it seemed too magical.
This fixes bug #2863829.