comparison src/formats/bbcode.js @ 37:0c4e4b5ef40d

remove fragmentToHtml
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 17 Aug 2022 12:00:57 -0600
parents 21090996a131
children 7491026f7623
comparison
equal deleted inserted replaced
36:21090996a131 37:0c4e4b5ef40d
2446 }; 2446 };
2447 2447
2448 /** 2448 /**
2449 * Converts BBCode into HTML 2449 * Converts BBCode into HTML
2450 * 2450 *
2451 * @param {boolean} asFragment
2452 * @param {string} source 2451 * @param {string} source
2453 * @param {boolean} [legacyAsFragment] Used by fromBBCode() method 2452 */
2454 */ 2453 function toHtml(source) {
2455 function toHtml(asFragment) { 2454 let parser = newBBCodeParser(base.editor);
2456 return function(source, legacyAsFragment) { 2455 let html = parser.toHTML(
2457 var parser = newBBCodeParser(base.editor); 2456 base.opts.bbcodeTrim ? source.trim() : source
2458 var html = parser.toHTML( 2457 );
2459 base.opts.bbcodeTrim ? source.trim() : source 2458 return html;
2460 );
2461
2462 return (asFragment || legacyAsFragment) ?
2463 removeFirstLastDiv(html) : html;
2464 };
2465 } 2459 }
2466 2460
2467 /** 2461 /**
2468 * Converts HTML into BBCode 2462 * Converts HTML into BBCode
2469 * 2463 *
2523 2517
2524 return bbcode; 2518 return bbcode;
2525 }; 2519 };
2526 } 2520 }
2527 2521
2528 base.toHtml = toHtml(false); 2522 base.toHtml = toHtml;
2529 base.fragmentToHtml = toHtml(true);
2530 base.toSource = toSource(false); 2523 base.toSource = toSource(false);
2531 base.fragmentToSource = toSource(true); 2524 base.fragmentToSource = toSource(true);
2532 2525
2533 return base; 2526 return base;
2534 }; 2527 };