Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
-- This file:
--   http://anggtwu.net/LUA/Output1.lua.html
--   http://anggtwu.net/LUA/Output1.lua
--          (find-angg "LUA/Output1.lua")
-- Author: Eduardo Ochs <eduardoochs@gmail.com>
--
-- This is a rewrite of output.lua for Dednat7. See:
--   (find-angg "LUA/dednat7load.lua")
--   (find-dn6 "output.lua")
--
-- (find-angggrep "grep --color=auto -nH --null -e output LUA/Dednat7.lua")
--
-- «.saexpr»		(to "saexpr")
-- «.saexpr-test»	(to "saexpr-test")
-- «.write_dnt_file»	(to "write_dnt_file")

dnt_log = dnt_log or ""

Output = Class {
  type = "Output",
  __call = function (out,...) output:output(...) end,
  __tostring = function (out) return "(An Output object)" end,
  __index = {
    --
    -- Low-level destinations
    dnt    = function (out,bigstr) dnt_log = dnt_log..bigstr.."\n" end,
    tex    = function (out,bigstr) if tex then tex.print(deletecomments(bigstr)) end end,
    print0 = function (out,bigstr) print(bigstr) end,
    print  = function (out,bigstr) print(bigstr); out:dnt(bigstr) end,
    --
    -- Default action for __call
    output = function (out,bigstr) out:print(bigstr); out:tex(bigstr) end,
    --
    -- Logging
    puinfo = function (out,line)
        out:print("% Running the \\pu at line "..(line or "(nil)"))
      end,
    blockinfo = function (out)
        out:print(format("%% Running the \"%s\"-block in lines %s",
                         thisblock.headstr or "", thisblock:ijtostring()))
      end,
    --
    -- «saexpr»  (to ".saexpr")
    -- See: (find-LATEX "2026-defs.tex" "saexpr")
    -- A hack to convert some uses of \expr{...} into something that
    -- works in Arxiv.
   saexpr  = function (out,code) return out(out:saexpr0(code)) end,
   saexpr0 = function (out,code)
       local name   = code
       local result = expr(code)
       local fmt    = "\n%% \\saexpr{%s}\n\\sa      {%s} {%%\n%s%%\n}"
       local sa     = format(fmt, name, name, result)
       return sa
     end,
  },
}

output = Output {}

--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "Output1.lua"
= output
  output("Hello")
= dnt_log

--]]


-- «saexpr-test»  (to ".saexpr-test")
-- See: (find-LATEX "2026-defs.tex" "saexpr")
--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "Output1.lua"
= output:saexpr0(" 1+2 ")
  output:saexpr (" 1+2 ")

--]]




-- «write_dnt_file»  (to ".write_dnt_file")
-- Based on: (find-dn6 "output.lua" "write_dnt_file")
--
write_dnt_file  = function (fname)
    fname = fname or texlines.name:gsub("%.tex$", "")..".dnt"
    print("% Writing: "..fname)
    writefile(fname, dnt_log)
  end






-- Local Variables:
-- coding:  utf-8-unix
-- End: