<commit_before>'use strict'

const Compiler = render.Compiler = require('./compiler')
const lazy = require('lazyrequire')(require)
const Parser = require('jade').Parser
const rethrow = require('jade').runtime.rethrow
const beautify = lazy('js-beautify')
const addWith = require('with')

module.exports = render

/**
 * Runtime included when you create a template.
 * You are expected to install these yourself.
 */

render.runtime = `
var h = require('virtual-dom/h');
`

/**
 * Variables that you don't want to bother `with`ing.
 */

render.globals = [
  'require',
]

/**
 * Compile the jade source into a function string with the signature:
 *
 * (locals) => VNode
 *
 * You are expected to `eval()` the result if you want an actual function.
 */

function render(str, options) {
  options = options || {}

  const name = options.name || 'render'

  // parse
  const ParserCls = options.parser || Parser
  const parser = new ParserCls(str, options.filename)
  let tokens
  try {
    tokens = parser.parse()
  } catch (err) {
    const context = parser.context()
    rethrow(err, context.filename, context.lexer.lineno, context.input)<commit_msg>more civilized default option setting<commit_after>'use strict'

const Compiler = render.Compiler = require('./compiler')
const lazy = require('lazyrequire')(require)
const Parser = require('jade').Parser
const rethrow = require('jade').runtime.rethrow
const beautify = lazy('js-beautify')
const addWith = require('with')

module.exports = render

/**
 * Runtime included when you create a template.
 * You are expected to install these yourself.
 */

render.runtime = `
var h = require('virtual-dom/h');
`

/**
 * Variables that you don't want to bother `with`ing.
 */

render.globals = [
  'require',
]

/**
 * Compile the jade source into a function string with the signature:
 *
 * (locals) => VNode
 *
 * You are expected to `eval()` the result if you want an actual function.
 */

const DEFAULT_OPTIONS = {
  name: 'render',
  vdom: 'virtual-dom',
}

function render(str, options) {
  options = Object.assign({}, options, DEFAULT_OPTIONS)

  const name = options.name

  // parse
  const ParserCls = options.parser || Parser
  const parser = new ParserCls(str, options.filename)
  let tokens
  try {
    tokens = parser.parse()
  } catch (err) {
    const context = parser.context()
    rethrow(err, context.filename, context.lexer.lineno, context.input)
{'fraction_non_alphanumeric': 0.13164451827242524, 'fraction_numerical': 0.0, 'mean_word_length': 3.8666666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '705971', 'n_tokens_mistral': 739, 'n_tokens_neox': 726, 'n_words': 230}