'use strict'; /* global $:off */ var utils = require( './utils.js' ); /** * Add an attribute to a list item to remove pre-whitespace in Parsoid * * @param {HTMLElement} listItem List item element */ function whitespaceParsoidHack( listItem ) { // HACK: Setting data-parsoid removes the whitespace after the list item, // which makes nested lists work. // This is undocumented behaviour and probably very fragile. listItem.setAttribute( 'data-parsoid', '{}' ); } /** * 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 ) { var target = comment.range.endContainer; // Insert the link before trailing whitespace. // In the MediaWiki parser output,