old_contents: try:
    import javascript
    import html
  except:
    from . import javascript
    from . import html
  
  def expand(string, start, end, extension=None):
  
    if(extension in ["html", "htm", "xml"]):
      return html.expand(string, start, end)
  
    return javascript.expand(string, start, end)
new_contents: import re
  
  try:
    import javascript
    import html
  except:
    from . import javascript
    from . import html
  
  def expand(string, start, end, extension=None):
  
    if(re.compile("html|htm|xml").search(extension)):
      return html.expand(string, start, end)
  
    return javascript.expand(string, start, end)
subject: Use html strategy for any file that has xml/html in file extension. This will will match shtml, xhtml and so on.