         e.context = element
         @errors.push(e)
 
-      lineNum += element.match(/\r\n?|\n/g)?.length or 0
+      lineNum += element.match(reLineEnding)?.length or 0
 
       for lang in @availableLanguages when lang.reClassName.test element
         lang = lang.lang
         break;
 
       lang or= @defaultLanguageCode
-      element = element.replace(/[\r\n]/g, '')
-      element = element.replace(/<br[^>]*>/ig, "\n")
+      element = element.replace(reLineEnding, '')
+      element = element.replace(reBr, "\n")
       innerText = strip_tags(element).trim()
       lang = @getLanguage(element)
       item = {startTime, languages: {}, contents: innerText}

    ret = []

    while true
      startTagIdx = str.search(/<sync/i)
      break if nextStartTagIdx <= 0 || startTagIdx < 0
      nextStartTagIdx = str.slice(startTagIdx+1).search(/<sync/i)+1
      if nextStartTagIdx > 0
        element = str.slice(startTagIdx, startTagIdx+nextStartTagIdx)
      else
        element = str.slice(startTagIdx)

      lineNum += str.slice(0, startTagIdx).match(/\r\n?|\n/g)?.length or 0 
      if isBroken = /<[a-z]*[^>]*<[a-z]*/g.test(element)
        e = new Error('ERROR_BROKEN_TAGS')
        e.line = lineNum
        e.context = element

  });
}`

reOpenSync = /<sync/i
reLineEnding = /\r\n?|\n/g
reBrokenTag = /<[a-z]*[^>]*<[a-z]*/g
reStartTime = /<sync[^>]+?start[^=]*=[^0-9]*([0-9]*)["^0-9"]*/i
reBr = /<br[^>]*>/ig
reStyle = /<style[^>]*>([\s\S]*?)<\/style[^>]*>/i
reComment = /(<!--|-->)/g

class Parser
  @defaultLanguage: {className: 'KRCC', lang: 'ko', reClassName: /class[^=]*?=["']?(KRCC)["']?/i}
  @defaultLanguageCode: 'ko' 
