lib/textblock.js
function(source, type) {
  if (source.hasOwnProperty('format')) {
    if (source.format !== type) {
      if (source.format === 'section') {
        var blocks = [];
        source.blocks.forEach(function(val, index, array) {
          var block = deleteTextBlockFormat(val, type);
          if (block) {
            blocks.push(block);
          }
        });
        if (blocks.length) {
          return {format: 'section', blocks: blocks};
        } else {
          return null;
        }
      } else {
        return source;
      }
    } else {
      return null;
    }
  }
  throw new Error('invalid format for textblock (did you pass an Object in?)');
}
function(source, type) {
  if (source.hasOwnProperty('format')) {
    if (source.format !== type) {
      if (source.format === 'section') {
        var blocks = [];
        source.blocks.forEach(function(val, index, array) {
          var block = deleteTextBlockFormat(val, type);
          if (block) {
            blocks.push(block);
          }
        });
        if (blocks.length) {
          return {format: 'section', blocks: blocks};
        } else {
          return null;
        }
      } else {
        return source;
      }
    } else {
      return null;
    }
  }
  throw new Error('invalid format for textblock (did you pass an Object in?)');
}
function ( source , type ) { if ( source . hasOwnProperty ( 'format' ) ) { if ( source . format !== type ) { if ( source . format === 'section' ) { var blocks = [ ] ; source . blocks . forEach ( function ( val , index , array ) { var block = deleteTextBlockFormat ( val , type ) ; if ( block ) { blocks . push ( block ) ; } } ) ; if ( blocks . length ) { return { format : 'section' , blocks : blocks } ; } else { return null ; } } else { return source ; } } else { return null ; } } throw new Error ( 'invalid format for textblock (did you pass an Object in?)' ) ; }
Delete all blocks with a given format.
@param {String} source The source untrusted text block
@param {String} type The type of block to remove
@return {Object} a cleaned text block
Delete all blocks with a given format .