lib/stmd.js
function(inlines) {
  if (this.match(/^!/)) {
    var n = this.parseLink(inlines);
    if (n === 0) {
      inlines.push({ t: 'Str', c: '!' });
      return 1;
    } else if (inlines[inlines.length - 1] &&
               inlines[inlines.length - 1].t == 'Link') {
      inlines[inlines.length - 1].t = 'Image';
      return n+1;
    } else {
      throw "Shouldn't happen";
    }
  } else {
    return 0;
  }
}
function(inlines) {
  if (this.match(/^!/)) {
    var n = this.parseLink(inlines);
    if (n === 0) {
      inlines.push({ t: 'Str', c: '!' });
      return 1;
    } else if (inlines[inlines.length - 1] &&
               inlines[inlines.length - 1].t == 'Link') {
      inlines[inlines.length - 1].t = 'Image';
      return n+1;
    } else {
      throw "Shouldn't happen";
    }
  } else {
    return 0;
  }
}
function ( inlines ) { if ( this . match ( / ^! / ) ) { var n = this . parseLink ( inlines ) ; if ( n === 0 ) { inlines . push ( { t : 'Str' , c : '!' } ) ; return 1 ; } else if ( inlines [ inlines . length - 1 ] && inlines [ inlines . length - 1 ] . t == 'Link' ) { inlines [ inlines . length - 1 ] . t = 'Image' ; return n + 1 ; } else { throw "Shouldn't happen" ; } } else { return 0 ; } }
Attempt to parse an image.  If the opening '!' is not followed by a link, add a literal '!' to inlines.
Attempt to parse an image . If the opening ! is not followed by a link add a literal ! to inlines .