docs: function doClick(buttonName) {
      var button = buttons[buttonName];
      if (!button) {
        return;
      }
  
      inputBox.focus();
      var linkOrImage = button === buttons.link || button.id === buttons.image;
  
      var state = new TextareaState(input);
  
      if (!state) {
        return;
      }
  
      var chunks = state.getChunks();
  
      // Some commands launch a "modal" prompt dialog.  Javascript
      // can't really make a modal dialog box and the WMD code
      // will continue to execute while the dialog is displayed.
      // This prevents the dialog pattern I'm used to and means
      // I can't do something like this:
      //
      // var link = CreateLinkDialog();
      // makeMarkdownLink(link);
      //
      // Instead of this straightforward method of handling a
      // dialog I have to pass any code which would execute
      // after the dialog is dismissed (e.g. link creation)
      // in a function parameter.
      //
      // Yes this is awkward and I think it sucks, but there's
      // no real workaround.  Only the image and link code
      // create dialogs and require the function pointers.
      var fixupInputArea = function () {
  
        inputBox.focus();
  
        if (chunks) {
          state.setChunks(chunks);
        }
  
        state.restore();
      };
  
      var noCleanup = button(chunks, fixupInputArea);
  
      if (!noCleanup) {
        fixupInputArea();
        if (!linkOrImage) {
          inputBox.adjustCursorPosition();
        }
      }
    }