<commit_before>local outcounter = 1

local outputMarks = function()
  local page = SILE.getFrame("page")
  SILE.outputter.rule(page:left() - 10, page:top(), -10, 0.5)
  SILE.outputter.rule(page:left(), page:top() - 10, 0.5, -10)
  SILE.outputter.rule(page:right() + 10, page:top(), 10, 0.5)
  SILE.outputter.rule(page:right(), page:top() - 10, 0.5, -10)
  SILE.outputter.rule(page:left() - 10, page:bottom(), -10, 0.5)
  SILE.outputter.rule(page:left(), page:bottom() + 10, 0.5, 10)
  SILE.outputter.rule(page:right() + 10, page:bottom(), 10, 0.5)
  SILE.outputter.rule(page:right(), page:bottom() + 10, 0.5, 10)

  SILE.call("crop:header")
  local hbox = SILE.typesetter.state.nodes[#SILE.typesetter.state.nodes]
  SILE.typesetter.state.nodes[#SILE.typesetter.state.nodes] = nil

  SILE.typesetter.frame.state.cursorX = page:left()
  SILE.typesetter.frame.state.cursorY = page:top() - 30
  outcounter = outcounter + 1

  if hbox then
    for i=1,#(hbox.value) do hbox.value[i]:outputYourself(SILE.typesetter, {ratio=1}) end
  end
end

local function reconstrainFrameset(fs)
  for n,f in pairs(fs) do
    if n ~= "page" then
      if f:isAbsoluteConstraint("right") then
        f.constraints.right = "left(page) + (" .. f.constraints.right .. ")"
      end
      if f:isAbsoluteConstraint("left") then
        f.constraints.left = "left(page) + (" .. f.constraints.left .. ")"
      end
      if f:isAbsoluteConstraint("top") then
        f.constraints.top = "top(page) + (" .. f.constraints.top .. ")"
      end
      if f:isAbsoluteConstraint("bottom") then
        f.constraints.bottom = "top(page) + (" .. f.constraints.bottom .. ")"
      end
      f:invalidate()
    end
  end
end

SILE.registerCommand("crop:header", function (o, c)
  local info = SILE.masterFilename .. " - " .. os.date("%x %X") .. " -  " .. outcounter
  SILE.call("hbox", {}, {info})
end)

SILE.registerCommand("crop:setup", function (o,c)
  local papersize = SU.required(o, "papersize", "setting up crop marks")
  local size = SILE.paperSizeParser(papersize)
  local oldsize = SILE.documentState.paperSize
  SILE.documentState.paperSize = size
  local offsetx = ( SILE.documentState.paperSize[1] - oldsize[1] ) /2
  local offsety = ( SILE.documentState.paperSize[2] - oldsize[2] ) /2
  local page = SILE.getFrame("page")
  page:constrain("right", page:right() + offsetx)
  page:constrain("left", offsetx)
  page:constrain("bottom", page:bottom() + offsety)
  page:constrain("top", offsety)
  if SILE.scratch.masters then
    for k,v in pairs(SILE.scratch.masters) do
      reconstrainFrameset(v.frames)
    end
  else
    reconstrainFrameset(SILE.documentState.documentClass.pageTemplate.frames)
  end
  reconstrainFrameset(SILE.frames)
  if SILE.typesetter.frame then SILE.typesetter.frame:init() end

  local oldEndPage = SILE.documentState.documentClass.endPage
  SILE.outputter:debugFrame(page)
  SILE.documentState.documentClass.endPage = function(self)
    oldEndPage(self)
    outputMarks()
  end
end)<commit_msg>Remove forced frame debug output from cropmark package<commit_after>local outcounter = 1

local outputMarks = function()
  local page = SILE.getFrame("page")
  SILE.outputter.rule(page:left() - 10, page:top(), -10, 0.5)
  SILE.outputter.rule(page:left(), page:top() - 10, 0.5, -10)
  SILE.outputter.rule(page:right() + 10, page:top(), 10, 0.5)
  SILE.outputter.rule(page:right(), page:top() - 10, 0.5, -10)
  SILE.outputter.rule(page:left() - 10, page:bottom(), -10, 0.5)
  SILE.outputter.rule(page:left(), page:bottom() + 10, 0.5, 10)
  SILE.outputter.rule(page:right() + 10, page:bottom(), 10, 0.5)
  SILE.outputter.rule(page:right(), page:bottom() + 10, 0.5, 10)

  SILE.call("crop:header")
  local hbox = SILE.typesetter.state.nodes[#SILE.typesetter.state.nodes]
  SILE.typesetter.state.nodes[#SILE.typesetter.state.nodes] = nil

  SILE.typesetter.frame.state.cursorX = page:left()
  SILE.typesetter.frame.state.cursorY = page:top() - 30
  outcounter = outcounter + 1

  if hbox then
    for i=1,#(hbox.value) do hbox.value[i]:outputYourself(SILE.typesetter, {ratio=1}) end
  end
end

local function reconstrainFrameset(fs)
  for n,f in pairs(fs) do
    if n ~= "page" then
      if f:isAbsoluteConstraint("right") then
        f.constraints.right = "left(page) + (" .. f.constraints.right .. ")"
      end
      if f:isAbsoluteConstraint("left") then
        f.constraints.left = "left(page) + (" .. f.constraints.left .. ")"
      end
      if f:isAbsoluteConstraint("top") then
        f.constraints.top = "top(page) + (" .. f.constraints.top .. ")"
      end
      if f:isAbsoluteConstraint("bottom") then
        f.constraints.bottom = "top(page) + (" .. f.constraints.bottom .. ")"
      end
      f:invalidate()
    end
  end
end

SILE.registerCommand("crop:header", function (o, c)
  local info = SILE.masterFilename .. " - " .. os.date("%x %X") .. " -  " .. outcounter
  SILE.call("hbox", {}, {info})
end)

SILE.registerCommand("crop:setup", function (o,c)
  local papersize = SU.required(o, "papersize", "setting up crop marks")
  local size = SILE.paperSizeParser(papersize)
  local oldsize = SILE.documentState.paperSize
  SILE.documentState.paperSize = size
  local offsetx = ( SILE.documentState.paperSize[1] - oldsize[1] ) /2
  local offsety = ( SILE.documentState.paperSize[2] - oldsize[2] ) /2
  local page = SILE.getFrame("page")
  page:constrain("right", page:right() + offsetx)
  page:constrain("left", offsetx)
  page:constrain("bottom", page:bottom() + offsety)
  page:constrain("top", offsety)
  if SILE.scratch.masters then
    for k,v in pairs(SILE.scratch.masters) do
      reconstrainFrameset(v.frames)
    end
  else
    reconstrainFrameset(SILE.documentState.documentClass.pageTemplate.frames)
  end
  reconstrainFrameset(SILE.frames)
  if SILE.typesetter.frame then SILE.typesetter.frame:init() end

  local oldEndPage = SILE.documentState.documentClass.endPage
  SILE.documentState.documentClass.endPage = function(self)
    oldEndPage(self)
    outputMarks()
  end
end)
{'fraction_non_alphanumeric': 0.15958687323005163, 'fraction_numerical': 0.01999000499750125, 'mean_word_length': 3.7575277337559427, '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': '2094243', 'n_tokens_mistral': 2280, 'n_tokens_neox': 2150, 'n_words': 409}