<commit_before>Mod.require 'Wallapatta.Parser', (Parser) ->
 RATIO = 0
 PAGE_HEIGHT = PAGE_WIDTH = 0

 if (window.location.href.indexOf 'print') isnt -1
  PRINT = true
 else
  PRINT = false

 renderWeb = (render) ->
  render.mediaLoaded ->
   render.setFills()
   n = 0
   int = setInterval ->
    render.setFills()
    n++
    if n is 10
     clearInterval int
   , 1000

 renderPrint = (render) ->
  render.mediaLoaded ->
   setTimeout ->
    render.setPages PAGE_HEIGHT
   , 5000

 process = (n, doc) ->
  code = doc.getElementsByClassName 'wallapatta-code'
  if code.length isnt 1
   throw new Error 'No code element'
  code = code[0]
  main = doc.getElementsByClassName 'wallapatta-main'
  if main.length isnt 1
   throw new Error 'No main element'
  main = main[0]
  sidebar = doc.getElementsByClassName 'wallapatta-sidebar'
  if sidebar.length isnt 1
   throw new Error 'No sidebar element'
  sidebar = sidebar[0]

  parser = new Parser
   text: code.textContent
   id: n * 10000
  parser.parse()
  render = parser.getRender()
  render.collectElements
   main: main<commit_msg>render before img loaded as well<commit_after>Mod.require 'Wallapatta.Parser', (Parser) ->
 RATIO = 0
 PAGE_HEIGHT = PAGE_WIDTH = 0

 if (window.location.href.indexOf 'print') isnt -1
  PRINT = true
 else
  PRINT = false

 renderWeb = (render) ->
  _imagesLoaded = false
  _count = 0
  _interval = null

  _render = ->
   render.setFills()
   if _imagesLoaded
    _count++
    if _count is 10
     clearInterval _interval


  render.mediaLoaded ->
   _imagesLoaded = true
   _render()

  _interval = setInterval _render, 1000

 renderPrint = (render) ->
  render.mediaLoaded ->
   setTimeout ->
    render.setPages PAGE_HEIGHT
   , 5000

 process = (n, doc) ->
  code = doc.getElementsByClassName 'wallapatta-code'
  if code.length isnt 1
   throw new Error 'No code element'
  code = code[0]
  main = doc.getElementsByClassName 'wallapatta-main'
  if main.length isnt 1
   throw new Error 'No main element'
  main = main[0]
  sidebar = doc.getElementsByClassName 'wallapatta-sidebar'
  if sidebar.length isnt 1
   throw new Error 'No sidebar element'
  sidebar = sidebar[0]

  parser = new Parser
   text: code.textContent
   id: n * 10000
  parser.parse()
  render = parser.getRender()
  render.collectElements
   main: main
{'fraction_non_alphanumeric': 0.09740259740259741, 'fraction_numerical': 0.021645021645021644, 'mean_word_length': 3.1120996441281137, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '7413660', 'n_tokens_mistral': 813, 'n_tokens_neox': 744, 'n_words': 222}