<commit_before>'use strict';

var assert = require('assert');
var walk = require('jade-walk');

function error() {
  throw require('jade-error').apply(null, arguments);
}

module.exports = link;
function link(ast) {
  assert(ast.type === 'Block', 'The top level element should always be a block');
  var extendsNode = null;
  if (ast.nodes.length && ast.nodes[0].type === 'Extends') {
    extendsNode = ast.nodes.shift();
  }
  ast = applyIncludes(ast);
  ast.declaredBlocks = findDeclaredBlocks(ast);
  if (extendsNode) {
    var mixins = [];
    var expectedBlocks = [];
    function addNode(node) {
      if (node.type === 'NamedBlock') {
        expectedBlocks.push(node.name);
      } else if (node.type === 'Mixin' && node.call === false) {
        mixins.push(node);<commit_msg>Allow blocks as top-level nodes in extend<commit_after>'use strict';

var assert = require('assert');
var walk = require('jade-walk');

function error() {
  throw require('jade-error').apply(null, arguments);
}

module.exports = link;
function link(ast) {
  assert(ast.type === 'Block', 'The top level element should always be a block');
  var extendsNode = null;
  if (ast.nodes.length && ast.nodes[0].type === 'Extends') {
    extendsNode = ast.nodes.shift();
  }
  ast = applyIncludes(ast);
  ast.declaredBlocks = findDeclaredBlocks(ast);
  if (extendsNode) {
    var mixins = [];
    var expectedBlocks = [];
    function addNode(node) {
      if (node.type === 'NamedBlock') {
        expectedBlocks.push(node.name);
      } else if (node.type === 'Block') {
        node.nodes.forEach(addNode);
      } else if (node.type === 'Mixin' && node.call === false) {
        mixins.push(node);
{'fraction_non_alphanumeric': 0.16815742397137745, 'fraction_numerical': 0.0011926058437686344, 'mean_word_length': 3.5474254742547426, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4760771', 'n_tokens_mistral': 534, 'n_tokens_neox': 533, 'n_words': 130}