function convertHTMLtoMD (text) {
      // Add page title
        var di = diNotify({
          message: 'Converting HTML to Markdown...',
          duration: 2500
        })
        return $http.post('factory/html_to_md', {
          html: text
        }).then(function successCallback (result) {
          if (angular.isDefined(di.$scope)) {
            di.$scope.$close()
          }
          if (result.data.error) {
            return diNotify({
              message: 'An Error occured: ' + result.data.error.message,
              duration: 5000
            })
          } else {
          // Set the new document's body
          // console.log(result.data.convertedMd)
            setCurrentDocumentBody(result.data.convertedMd)

            // Refresh the editor and proview.
            $rootScope.$emit('document.refresh')

            // Track event in GA
            if (window.ga) {
              window.ga('send', 'event', 'click', 'Convert HTML to Markdown', 'Convert To...')
            }
          }
        }, function errorCallback (err) {
          if (angular.isDefined(di.$scope)) {
            di.$scope.$close()
          }
          return diNotify({
            message: 'An Error occured: ' + err.data.error.message,
            duration: 5000
          })
        })
      }
Convert HTML text to markdown.

   @param  {text}  string  The html text to be converted