function convertHTMLtoMarkdown(tag, html) {
  if (tag === 'a') {
    var htmlToRestore = [];
    html = html.replace(/(`+)[\s\S]+?\1/ig, function($0) {
      var replacement = Math.random();
      htmlToRestore.push([replacement, $0]);
      return replacement;
    });
    /*
    Make sure we do *not* convert HTML links that are inside of MD links.
    Otherwise we'll have problems like issue #69.
    We're going to use a regex that mimics a negative lookbehind. For details see: https://blog.stevenlevithan.com/archives/mimic-lookbehind-javascript
    Here's an attempt at an explanation of the regex:
      (                 // begin optional prefix capture group
        (?:\]\([^\)]*)  // match an unclosed URL portion of a MD link -- like "...](..."
        |(?:\[[^\]]*)   // match an unclosed name portion of a MD link -- like "...[..."
        |(?:\[.*\]:.*)  // match the patterns of reflink and nolink -- link "[...]:..."
      )?                // capture group is optional so that we do the "negative" lookbehind -- that is, we can match links that are *not* preceded by the stuff we *don't* want
      <a\s[^>]*href="([^"]*)"[^>]*>(.*?)<\/a>  // an HTML link
    Then the replace callback looks like this:
      return $1 ? $0 : '['+$3+']('+$2+')'
    So, if the first capture group is matched (i.e., $1 has value), then we've
    matched the bad thing -- the indication that the HTML is inside a MD link.
    In that case, we don't modify anything. Otherwise we use our other capture
    groups to create the desired MD link.
    */
    html = html.replace(
      /((?:\]\([^\)]*)|(?:\[[^\]]*)|(?:\[.*\]:.*))?<a\s[^>]*href="([^"]*)"[^>]*>(.*?)<\/a>/ig,
      function($0, $1, $2, $3) {
        return $1 ? $0 : '['+$3+']('+$2+')';
      });

    for (var i = 0; i < htmlToRestore.length; i++) {
      html = html.replace(htmlToRestore[i][0], function() {
          // The replacement argument to `String.replace()` has some magic values: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_string_as_a_parameter
          // Because we don't control the content of that argument, we either
          // need to escape dollar signs in it, or use the function version.
          return htmlToRestore[i][1];
        });
    }
  }
  else {
    throw new Error('convertHTMLtoMarkdown: ' + tag + ' is not a supported tag');
  }

  return html;
}
Converts instances of `tag` in `html` to Markdown and returns the
resulting HTML.