normalizehtml.js 685 B

1234567891011121314151617181920
  1. /**
  2. * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/htmldataprocessor';
  6. import { stringify } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
  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. }