index.js
/**
 * Cleans up Markdown string from trailing spaces and excessive line breaks.
 * @param  {string}  input A Markdown string
 * @return {string}        A cleaned up Markdown string
 */
Cleans up Markdown string from trailing spaces and excessive line breaks.
Cleans up Markdown string from trailing spaces and excessive line breaks .
function cleanupMarkdown(input) {
  const trailingSpaces = / +\n/g
  const excessiveNewLines = /\n{3,}/g
  if (!input) {
    return input
  }
  var result = input.replace(trailingSpaces, '\n')
  result = result.replace(excessiveNewLines, '\n\n')
  return result
}
function cleanupMarkdown ( input ) { const trailingSpaces = /  +\n / g const excessiveNewLines = / \n{3,} / g if ( ! input ) { return input } var result = input . replace ( trailingSpaces , '\n' ) result = result . replace ( excessiveNewLines , '\n\n' ) return result }
Cleans up Markdown string from trailing spaces and excessive line breaks.
Cleans up Markdown string from trailing spaces and excessive line breaks .