/**
 * @license Copyright (c) 2017-2025, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md.
 */

'use strict';

const cheerio = require( 'cheerio' );

hexo.extend.helper.register( 'uSplitToTitleAndContent', data => {
	const $ = cheerio.load( data, null, false );
	const title = $( 'h1:not( .live-snippet h1 )' ).first().remove();

	return {
		title: title.children()
			.remove()
			.end()
			.text()
			.trim()
			.replace( /</g, '&lt;' )
			.replace( />/g, '&gt;' ),
		content: $.html()
	};
} );
