<commit_before>local typesetterPool = {}
local calculations = {}
local folioOrder = {}

local allTypesetters = function (f)
  local o = SILE.typesetter
for k,v in pairs(typesetterPool) do
  SILE.typesetter = v
  f(k,v)
end
  SILE.typesetter = o
end

local nulTypesetter = SILE.typesetter {} -- we ignore this
nulTypesetter.outputLinesToPage = function() end

local parallelPagebreak = function ()
  for i = 1,#folioOrder do
    local thisPageFrames = folioOrder[i]
    for j = 1,#thisPageFrames do
      local n = thisPageFrames[j]
      local t = typesetterPool[n]
      local thispage = {}
      for i = 1, calculations[n].mark do
        thispage[i] = table.remove(t.state.outputQueue, 1)
      end
      t:outputLinesToPage(thispage)
    end
    SILE.documentState.documentClass:endPage()
    for j = 1,#thisPageFrames do
      local n = thisPageFrames[j]
      local t = typesetterPool[n]
      t:initFrame(t.frame)
    end
    SILE.documentState.documentClass:newPage()
  end
end

local setupParallel = function (klass, options)
  nulTypesetter:init(SILE.getFrame("page"))
  for k,v in pairs(options.frames) do
    typesetterPool[k] = SILE.typesetter {}
    typesetterPool[k].id = v
    typesetterPool[k]:init(SILE.getFrame(v))
    typesetterPool[k].pageBuilder = function()
      -- No thank you, I will do that.
    end
    -- Fixed leading here is obviously a bug, but n-way leading calculations
    -- get very complicated...
    typesetterPool[k].leadingFor = function() return SILE.nodefactory.newVglue(SILE.settings.get("document.lineskip")) end
    SILE.registerCommand(k, function (o,c) -- \left ...<commit_msg>At present it looks like using provided leading does work OK. Needs further investigation.<commit_after>local typesetterPool = {}
local calculations = {}
local folioOrder = {}

local allTypesetters = function (f)
  local o = SILE.typesetter
for k,v in pairs(typesetterPool) do
  SILE.typesetter = v
  f(k,v)
end
  SILE.typesetter = o
end

local nulTypesetter = SILE.typesetter {} -- we ignore this
nulTypesetter.outputLinesToPage = function() end

local parallelPagebreak = function ()
  for i = 1,#folioOrder do
    local thisPageFrames = folioOrder[i]
    for j = 1,#thisPageFrames do
      local n = thisPageFrames[j]
      local t = typesetterPool[n]
      local thispage = {}
      for i = 1, calculations[n].mark do
        thispage[i] = table.remove(t.state.outputQueue, 1)
      end
      t:outputLinesToPage(thispage)
    end
    SILE.documentState.documentClass:endPage()
    for j = 1,#thisPageFrames do
      local n = thisPageFrames[j]
      local t = typesetterPool[n]
      t:initFrame(t.frame)
    end
    SILE.documentState.documentClass:newPage()
  end
end

local setupParallel = function (klass, options)
  nulTypesetter:init(SILE.getFrame("page"))
  for k,v in pairs(options.frames) do
    typesetterPool[k] = SILE.typesetter {}
    typesetterPool[k].id = v
    typesetterPool[k]:init(SILE.getFrame(v))
    typesetterPool[k].pageBuilder = function()
      -- No thank you, I will do that.
    end
    -- Fixed leading here is obviously a bug, but n-way leading calculations
    -- get very complicated...
    -- typesetterPool[k].leadingFor = function() return SILE.nodefactory.newVglue(SILE.settings.get("document.lineskip")) end
    SILE.registerCommand(k, function (o,c) -- \left ...
{'fraction_non_alphanumeric': 0.1092436974789916, 'fraction_numerical': 0.003001200480192077, 'mean_word_length': 3.414569536423841, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '771806', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1070, 'n_words': 277}