<commit_before>{ Disposable } = require 'atom'

module.exports =
class Syntax extends Disposable
  constructor: (latex) ->
    @latex = latex

  dollarsign: ->
    editor = atom.workspace.getActiveTextEditor()
    selected = editor.getSelectedText()
    if selected
      range = editor.getSelectedBufferRange()
      range.start.column += 1
      range.end.column += 1
      editor.insertText("""$#{selected}$""")
      editor.setSelectedBufferRange(range)
      return

    cursor = editor.getCursorBufferPosition()
    if editor?.buffer?.lines[cursor.row][cursor.column - 1] is ' '
      if editor?.buffer?.lines[cursor.row].length is cursor.column or \
          editor?.buffer?.lines[cursor.row][cursor.column] is ' '
        editor.insertText('$$')
        editor.moveLeft()
        return
    editor.insertText('$')

  backquote: ->
    editor = atom.workspace.getActiveTextEditor()
    selected = editor.getSelectedText()
    if selected
      range = editor.getSelectedBufferRange()
      range.start.column += 1
      range.end.column += 1
      editor.insertText("""`#{selected}'""")
      editor.setSelectedBufferRange(range)
      return

    editor.insertText('`')

  doublequote: ->
    editor = atom.workspace.getActiveTextEditor()
    selected = editor.getSelectedText()
    if selected
      range = editor.getSelectedBufferRange()
      range.start.column += 1
      range.end.column += 1
      editor.insertText("""``#{selected}\'\'""")
      editor.setSelectedBufferRange(range)
      return

    editor.insertText('\"')
<commit_msg>Allow double dollar before period<commit_after>{ Disposable } = require 'atom'

module.exports =
class Syntax extends Disposable
  constructor: (latex) ->
    @latex = latex

  dollarsign: ->
    editor = atom.workspace.getActiveTextEditor()
    selected = editor.getSelectedText()
    if selected
      range = editor.getSelectedBufferRange()
      range.start.column += 1
      range.end.column += 1
      editor.insertText("""$#{selected}$""")
      editor.setSelectedBufferRange(range)
      return

    cursor = editor.getCursorBufferPosition()
    allowedNextChar = [' ', '.']
    if editor?.buffer?.lines[cursor.row][cursor.column - 1] is ' '
      if editor?.buffer?.lines[cursor.row].length is cursor.column or \
          allowedNextChar.indexOf(
            editor?.buffer?.lines[cursor.row][cursor.column]) > -1
        editor.insertText('$$')
        editor.moveLeft()
        return
    editor.insertText('$')

  backquote: ->
    editor = atom.workspace.getActiveTextEditor()
    selected = editor.getSelectedText()
    if selected
      range = editor.getSelectedBufferRange()
      range.start.column += 1
      range.end.column += 1
      editor.insertText("""`#{selected}'""")
      editor.setSelectedBufferRange(range)
      return

    editor.insertText('`')

  doublequote: ->
    editor = atom.workspace.getActiveTextEditor()
    selected = editor.getSelectedText()
    if selected
      range = editor.getSelectedBufferRange()
      range.start.column += 1
      range.end.column += 1
      editor.insertText("""``#{selected}\'\'""")
      editor.setSelectedBufferRange(range)
      return

    editor.insertText('\"')

{'fraction_non_alphanumeric': 0.13637785423834844, 'fraction_numerical': 0.0046918986549890525, 'mean_word_length': 2.933579335793358, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5692721', 'n_tokens_mistral': 933, 'n_tokens_neox': 909, 'n_words': 166}