'use strict'; /* global $:off */ const utils = require( './utils.js' ); /** * Remove extra linebreaks from a wikitext string * * @param {string} wikitext Wikitext * @return {string} */ function sanitizeWikitextLinebreaks( wikitext ) { return utils.htmlTrim( wikitext ) .replace( /\r/g, '\n' ) .replace( /\n+/g, '\n' ); } /** * Given a comment and a reply link, add the reply link to its document's DOM tree, at the end of * the comment. * * @param {CommentItem} comment Comment item * @param {HTMLElement} linkNode Reply link */ function addReplyLink( comment, linkNode ) { const target = comment.range.endContainer; // Insert the link before trailing whitespace. // In the MediaWiki parser output,