<commit_before>import {BlockQuote, OrderedList, BulletList, CodeBlock, Heading} from "../model"
import {Plugin} from "../edit"
import {InputRule, inputRules} from "./inputrules"

// :: Object<InputRule>
// Base set of input rules, enabled by default when `autoInput` is set
// to `true`.
export const autoInputRules = Object.create(null)

class AutoInput {
  constructor(pm, options) {
    this.rules = []
    let rules = Object.create(null), mod = inputRules.ensure(pm)
    options.specs.forEach(spec => {
      if (spec === "schema") {
        pm.schema.registry("autoInput", (name, rule, type, typeName) => {
          let rname = typeName + ":" + name, handler = rule.handler
          if (handler.bind) handler = handler.bind(type)
          rules[rname] = new InputRule(rule.match, rule.filter, handler)
        })
      } else {
        for (let name in spec) {
          let val = spec[name]
          if (val == null) delete rules[name]
          else rules[name] = val
        }
      }
    })
    for (let name in rules) {
      mod.addRule(rules[name])
      this.rules.push(rules[name])
    }
  }

  detach(pm) {
    let mod = inputRules.ensure(pm)
    this.rules.forEach(rule => mod.removeRule(rule))
  }
}

// :: Plugin
// Controls the [input rules](#InputRule) initially active in the
// editor. Pass an array of sources, which can be either the string
// `"schema"`, to add rules [registered](#SchemaItem.register) on the
// schema items (under the namespace `"autoInput"`), or an object
// containing input rules. To remove previously included rules, you
// can add an object that maps their name to `null`.
//
// The value `false` (the default) is a shorthand for no input rules,
// and the value `true` for `["schema", autoInputRules]`.
export const autoInput = new Plugin(AutoInput, {
  specs: ["schema", autoInputRules]
})

autoInputRules.emDash = new InputRule(/--$/, "-", "—")

autoInputRules.openDoubleQuote = new InputRule(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/, '"', "“")

autoInputRules.closeDoubleQuote = new InputRule(/"$/, '"', "”")<commit_msg>Add "..." --> "…" to autoInputRules<commit_after>import {BlockQuote, OrderedList, BulletList, CodeBlock, Heading} from "../model"
import {Plugin} from "../edit"
import {InputRule, inputRules} from "./inputrules"

// :: Object<InputRule>
// Base set of input rules, enabled by default when `autoInput` is set
// to `true`.
export const autoInputRules = Object.create(null)

class AutoInput {
  constructor(pm, options) {
    this.rules = []
    let rules = Object.create(null), mod = inputRules.ensure(pm)
    options.specs.forEach(spec => {
      if (spec === "schema") {
        pm.schema.registry("autoInput", (name, rule, type, typeName) => {
          let rname = typeName + ":" + name, handler = rule.handler
          if (handler.bind) handler = handler.bind(type)
          rules[rname] = new InputRule(rule.match, rule.filter, handler)
        })
      } else {
        for (let name in spec) {
          let val = spec[name]
          if (val == null) delete rules[name]
          else rules[name] = val
        }
      }
    })
    for (let name in rules) {
      mod.addRule(rules[name])
      this.rules.push(rules[name])
    }
  }

  detach(pm) {
    let mod = inputRules.ensure(pm)
    this.rules.forEach(rule => mod.removeRule(rule))
  }
}

// :: Plugin
// Controls the [input rules](#InputRule) initially active in the
// editor. Pass an array of sources, which can be either the string
// `"schema"`, to add rules [registered](#SchemaItem.register) on the
// schema items (under the namespace `"autoInput"`), or an object
// containing input rules. To remove previously included rules, you
// can add an object that maps their name to `null`.
//
// The value `false` (the default) is a shorthand for no input rules,
// and the value `true` for `["schema", autoInputRules]`.
export const autoInput = new Plugin(AutoInput, {
  specs: ["schema", autoInputRules]
})

autoInputRules.emDash = new InputRule(/--$/, "-", "—")

autoInputRules.ellipsis = new InputRule(/\.\.\.$/, ".", "…")

autoInputRules.openDoubleQuote = new InputRule(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/, '"', "“")

autoInputRules.closeDoubleQuote = new InputRule(/"$/, '"', "”")
{'fraction_non_alphanumeric': 0.1620217288615966, 'fraction_numerical': 0.0033065658951346244, 'mean_word_length': 3.0721153846153846, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 12, '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': '4093083', 'n_tokens_mistral': 1333, 'n_tokens_neox': 1302, 'n_words': 393}