normalizehtml.js 613 B

1234567891011121314151617181920
  1. /**
  2. * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import HtmlDataProcessor from 'ckeditor5/engine/dataprocessor/htmldataprocessor.js';
  6. import { stringify } from 'ckeditor5/engine/dev-utils/view.js';
  7. /**
  8. * Parses given string of HTML and returns normalized HTML.
  9. *
  10. * @param {String} html HTML string to normalize.
  11. * @returns {String} Normalized HTML string.
  12. */
  13. export default function normalizeHtml( html ) {
  14. const processor = new HtmlDataProcessor();
  15. const parsed = processor.toView( html );
  16. return stringify( parsed );
  17. }