applies the processors to the bin and generates the html, js, etc based on the appropriate processor. Used in the previews and the API requests.
777201
function(bin) {
    var binSettings = {};

    // self defence against muppertary
    if (typeof bin.settings === 'string') {
      try {
        binSettings = JSON.parse(bin.settings);
      } catch (e) {}
    } else {
      binSettings = bin.settings;
    }

    if (
      binSettings &&
      binSettings.processors &&
      Object.keys(binSettings.processors).length
    ) {
      return Promise.all(
        Object.keys(binSettings.processors).map(function(panel) {
          var processorName = binSettings.processors[panel],
            code = bin[panel];
          if (processors.support(processorName)) {
            bin['original_' + panel] = code;
            return processors
              .run(processorName, {
                source: code,
                url: bin.url,
                revision: bin.revision,
              })
              .then(function(output) {
                var result = '';
                if (output.result) {
                  result = output.result;
                } else {
                  result = output.errors
                    .map(function(error) {
                      return (
                        'Line: ' +
                        error.line +
                        '\nCharacter: ' +
                        error.ch +
                        '\nMessage: ' +
                        error.msg
                      );
                    })
                    .join('\n\n');
                }
                bin[panel] = result;
                return bin;
              })
              .catch(function() {
                return bin;
              });
          } else {
            return Promise.resolve(bin);
          }
        })
      );
    }

    // otherwise default to being resolved
    return Promise.resolve([bin]);
  }
1282311
def generate(self, model, outfolder):
        
        _logger.info('Generating code to {!r}.'.format(outfolder))

        for task in self.tasks:
            for element in task.filtered_elements(model):
                task.run(element, outfolder)
330158
def register_default_processors(cls, frontend_editing=None):
        
        super(Page, cls).register_default_processors()

        if frontend_editing:
            cls.register_request_processor(
                edit_processors.frontendediting_request_processor,
                key='frontend_editing')
            cls.register_response_processor(
                edit_processors.frontendediting_response_processor,
                key='frontend_editing')
488513
def process_templates(input_dir, target_dir, context):
    
    if not target_dir.endswith('/'):
        target_dir = "{}/".format(target_dir)
    if not os.path.exists(target_dir):
        LOGGER.info('Creating: {}'.format(target_dir))
        os.makedirs(target_dir)
    replicate_directory_tree(input_dir, target_dir)
    templates = find_templates(input_dir)
    for templ in templates:
        output_file = templ.replace(input_dir, target_dir)
        output_file = output_file[:-len('.mustache')]
        render_template(templ,  output_file, context)
933115
def generate(self, url, browsers=None, orientation=None, mac_res=None, win_res=None,
                             quality=None, local=None, wait_time=None, callback_url=None):
        
        if isinstance(browsers, dict):
            browsers = [browsers]
        if browsers is None:
            browsers = [self.default_browser]
        data = dict((key, value) for key, value in locals().items() if value is not None and key != 'self')
        return self.execute('POST', '/screenshots', json=data)
145294
def run_processor(
        processorClass,
        ocrd_tool=None,
        mets_url=None,
        resolver=None,
        workspace=None,
        page_id=None,
        log_level=None,
        input_file_grp=None,
        output_file_grp=None,
        parameter=None,
        working_dir=None,
): # pylint: disable=too-many-locals
    
    workspace = _get_workspace(
        workspace,
        resolver,
        mets_url,
        working_dir
    )
    if parameter is not None:
        if not '://' in parameter:
            fname = os.path.abspath(parameter)
        else:
            fname = workspace.download_url(parameter)
        with open(fname, 'r') as param_json_file:
            parameter = json.load(param_json_file)
    else:
        parameter = {}
    log.debug("Running processor %s", processorClass)
    processor = processorClass(
        workspace,
        ocrd_tool=ocrd_tool,
        page_id=page_id,
        input_file_grp=input_file_grp,
        output_file_grp=output_file_grp,
        parameter=parameter
    )
    ocrd_tool = processor.ocrd_tool
    name = '%s v%s' % (ocrd_tool['executable'], processor.version)
    otherrole = ocrd_tool['steps'][0]
    log.debug("Processor instance %s (%s doing %s)", processor, name, otherrole)
    processor.process()
    workspace.mets.add_agent(
        name=name,
        _type='OTHER',
        othertype='SOFTWARE',
        role='OTHER',
        otherrole=otherrole
    )
    workspace.save_mets()
    return processor
1206883
def source
      case options[:processors].present?
      when true then HtmlSlicer::Process.iterate(@env.send(@method_name), options[:processors])
      else
        @env.send(@method_name)
      end
    end
806113
function run() {
    generator.load(function(err) {
      if (err) return log(err);

      if (opts.outputOnly) {
        generator.outputPages(function(err, result) {
          if (err) { log(err); }
          log('output %s generated pages', u.flatten(result).length);
        });

        var statics = require('./server/serve-statics')(opts, function(){
          statics.outputAll();
        });
        require('./server/serve-scripts')(opts).outputAll(generator);
        generator.unload();
        return;
      }

      if (opts.logPages) {
        generator.logPages();
        generator.unload();
        return;
      }

      require('./server/watch-sources')(generator);
      generator.listen(true);

      if (!opts['no-server']) { expressApp(); }
    });
  }
469255
def generate(args):
    """"""

    source_files = {args.presentation}

    # Parse the template info
    template_info = Template(args.template)
    if args.css:
        presentation_dir = os.path.split(args.presentation)[0]
        target_path = os.path.relpath(args.css, presentation_dir)
        template_info.add_resource(args.css, CSS_RESOURCE, target=target_path, extra_info='all')
        source_files.add(args.css)
    if args.js:
        presentation_dir = os.path.split(args.presentation)[0]
        target_path = os.path.relpath(args.js, presentation_dir)
        template_info.add_resource(args.js, JS_RESOURCE, target=target_path, extra_info=JS_POSITION_BODY)
        source_files.add(args.js)

    # Make the resulting HTML
    htmldata, dependencies = rst2html(args.presentation, template_info,
                                      args.auto_console, args.skip_help,
                                      args.skip_notes, args.mathjax,
                                      args.slide_numbers)
    source_files.update(dependencies)

    # Write the HTML out
    if not os.path.exists(args.targetdir):
        os.makedirs(args.targetdir)
    with open(os.path.join(args.targetdir, 'index.html'), 'wb') as outfile:
        outfile.write(htmldata)

    # Copy supporting files
    source_files.update(template_info.copy_resources(args.targetdir))

    # Copy images from the source:
    sourcedir = os.path.split(os.path.abspath(args.presentation))[0]
    tree = html.fromstring(htmldata)
    for image in tree.iterdescendants('img'):
        filename = image.attrib['src']
        source_files.add(copy_resource(filename, sourcedir, args.targetdir))

    RE_CSS_URL = re.compile(br"""url\(['"]?(.*?)['"]?[\)\?\#]""")

    # Copy any files referenced by url() in the css-files:
    for resource in template_info.resources:
        if resource.resource_type != CSS_RESOURCE:
            continue
        # path in CSS is relative to CSS file; construct source/dest accordingly
        css_base = template_info.template_root if resource.is_in_template else sourcedir
        css_sourcedir = os.path.dirname(os.path.join(css_base, resource.filepath))
        css_targetdir = os.path.dirname(os.path.join(args.targetdir, resource.final_path()))
        uris = RE_CSS_URL.findall(template_info.read_data(resource))
        uris = [uri.decode() for uri in uris]
        if resource.is_in_template and template_info.builtin_template:
            for filename in uris:
                template_info.add_resource(filename, OTHER_RESOURCE, target=css_targetdir,
                                           is_in_template=True)
        else:
            for filename in uris:
                source_files.add(copy_resource(filename, css_sourcedir, css_targetdir))

    # All done!

    return {os.path.abspath(f) for f in source_files if f}
819161
def apply_postcompilers(root, src_list, dst, processors):
    
    dst_file = os.path.join(root, dst)

    matches = [(pattern, cmds) for pattern, cmds in processors.iteritems() if fnmatch(dst, pattern)]
    if not matches:
        ensure_dirs(dst_file)
        logger.info('Combining [%s] into [%s]', ' '.join(src_list), dst_file)
        # We should just concatenate the files
        with open(dst_file, 'w') as dst_fp:
            for src in src_list:
                with open(os.path.join(root, src)) as src_fp:
                    for chunk in src_fp:
                        dst_fp.write(chunk)
        return True

    params = get_format_params(dst)

    # TODO: probably doesnt play nice everywhere
    src_names = src_list
    for pattern, cmd_list in matches:
        for cmd in cmd_list:
            run_command(cmd, root=root, dst=dst, input=' '.join(src_names), params=params)
            src_names = [dst]

    return True
653654
def preprocessor(dom):
    ""
    options = {
        "processing_instructions": False,
        "remove_unknown_tags": False,
        "safe_attrs_only": False,
        "page_structure": False,
        "annoying_tags": False,
        "frames": False,
        "meta": False,
        "links": False,
        "javascript": False,
        "scripts": True,
        "comments": True,
        "style": True,
        "embedded": True,
        "forms": True,
        "kill_tags": ("head",),
    }
    cleaner = Cleaner(**options)

    return cleaner.clean_html(dom)
130879
def compile(self):
        
        self.content = "".join(map(lambda x: x.compile(), self.children))
        return self._generate_html()
1132994
function renderStream() {
    es.addEventListener('css:processed', function (event) {
      // Inject the CSS
      var style = document.getElementById('jsbin-css');
      if (style.styleSheet) {
        style.styleSheet.cssText = event.data;
      } else {
        style.innerHTML = event.data;
      }
    });

    es.addEventListener('reload', reload);
    // Update the url when the revision is bumped
    es.addEventListener('bump-revision', function (event) {
      window.location.pathname = cleanPath(event.data);
    });
    // Javascript and HTML cause a reload. Would be nice to make it possible to
    // inject HTML changes in future.
    es.addEventListener('javascript:processed', reload);
    es.addEventListener('html:processed', reload);
  }
1010043
protected function preProcess(): void
    {
        Router::process();

        // disable Layout for XmlHttpRequests
        if (Request::isXmlHttpRequest()) {
            $this->layoutFlag = false;
        }

        // switch to JSON response based on Accept header
        if (Request::checkAccept([Request::TYPE_HTML, Request::TYPE_JSON]) === Request::TYPE_JSON) {
            $this->layoutFlag = false;
            Response::setType('JSON');
        }
    }
1094425
public final void execute() throws ParseException, GenerateException {

        LOG.info("Executing full build");

        enhanceClasspath();

        cleanFolders();

        // Parse models & generate
        final Parsers parsers = config.getParsers();
        if (parsers == null) {
            LOG.warn("No parsers element");
        } else {
            final List<ParserConfig> parserConfigs = parsers.getList();
            if (parserConfigs == null) {
                LOG.warn("No parsers configured");
            } else {
                for (final ParserConfig pc : parserConfigs) {
                    final Parser<Object> parser = pc.getParser();
                    final Object model = parser.parse();
                    final List<GeneratorConfig> generatorConfigs = config.findGeneratorsForParser(pc.getName());
                    for (final GeneratorConfig gc : generatorConfigs) {
                        final Generator<Object> generator = gc.getGenerator();
                        generator.generate(model, false);
                    }
                }
            }
        }

    }
468388
private void renderRecipe() throws IOException {
		StringBuilder sb = new StringBuilder();

		// First pages
		if( ! Constants.GENERATED.equalsIgnoreCase( this.applicationTemplate.getName())) {
			sb.append( renderDocumentTitle());
			sb.append( renderPageBreak());

			sb.append( renderParagraph( this.messages.get( "intro" ))); //$NON-NLS-1$
			sb.append( renderPageBreak());

			sb.append( renderDocumentIndex());
			sb.append( renderPageBreak());

			sb.append( startTable());
			sb.append( addTableLine( this.messages.get( "app.name" ), this.applicationTemplate.getName())); //$NON-NLS-1$
			sb.append( addTableLine( this.messages.get( "app.qualifier" ), this.applicationTemplate.getVersion())); //$NON-NLS-1$
			sb.append( endTable());

			sb.append( renderApplicationDescription());
			sb.append( renderPageBreak());
			sb.append( renderSections( new ArrayList<String>( 0 )));

		} else {
			sb.append( renderDocumentIndex());
			sb.append( renderPageBreak());
		}

		// Render information about components
		sb.append( renderComponents());

		// Render information about facets
		sb.append( renderFacets());

		writeFileContent( sb.toString());
	}
961349
function(processors) {
        var that = this;
        _.each(processors, function(processor, name) {
            if (name in that._processors) {
                throw new Error('Processor "' + name + '" already exists!');
            }
            that._processors[name] = processor;
        });

        return this;
    }