lib/compiler-html2.js
function addDescriptionToHead( head, options ) {
  if ( !options || !options.config || typeof options.config.description !== 'string' ) {
    return false;
  }

  if ( !Array.isArray( head.children ) ) {
    head.children = [];
  }
  for ( let i = 0; i < head.children.length; i++ ) {
    const child = head.children[ i ];
    if ( child.type !== Tree.ELEMENT ) continue;
    if ( child.name.toLowerCase() != 'meta' ) continue;
    if ( !child.attribs ) continue;
    if ( typeof child.attribs.name !== 'string' ) continue;
    if ( child.attribs.name.toLowerCase() === 'description' ) {
      // There is already a description. We don't add a new one.
      return false;
    }
  }
  head.children.push( {
    type: Tree.ELEMENT,
    name: 'meta',
    attribs: {
      name: 'description',
      content: options.config.description
    }
  } );
  return true;
}
function addDescriptionToHead( head, options ) {
  if ( !options || !options.config || typeof options.config.description !== 'string' ) {
    return false;
  }

  if ( !Array.isArray( head.children ) ) {
    head.children = [];
  }
  for ( let i = 0; i < head.children.length; i++ ) {
    const child = head.children[ i ];
    if ( child.type !== Tree.ELEMENT ) continue;
    if ( child.name.toLowerCase() != 'meta' ) continue;
    if ( !child.attribs ) continue;
    if ( typeof child.attribs.name !== 'string' ) continue;
    if ( child.attribs.name.toLowerCase() === 'description' ) {
      // There is already a description. We don't add a new one.
      return false;
    }
  }
  head.children.push( {
    type: Tree.ELEMENT,
    name: 'meta',
    attribs: {
      name: 'description',
      content: options.config.description
    }
  } );
  return true;
}
function addDescriptionToHead ( head , options ) { if ( ! options || ! options . config || typeof options . config . description !== 'string' ) { return false ; } if ( ! Array . isArray ( head . children ) ) { head . children = [ ] ; } for ( let i = 0 ; i < head . children . length ; i ++ ) { const child = head . children [ i ] ; if ( child . type !== Tree . ELEMENT ) continue ; if ( child . name . toLowerCase ( ) != 'meta' ) continue ; if ( ! child . attribs ) continue ; if ( typeof child . attribs . name !== 'string' ) continue ; if ( child . attribs . name . toLowerCase ( ) === 'description' ) { // There is already a description. We don't add a new one. return false ; } } head . children . push ( { type : Tree . ELEMENT , name : 'meta' , attribs : { name : 'description' , content : options . config . description } } ) ; return true ; }
Add a description in the header if no one was found.
@param {string} options.config.description - The description to use.
Add a description in the header if no one was found .