Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
-- blogme4.lua
-- Just a handful of ideas thrown together.
-- This file may be executable, or may be not.
-- At some point this will be like blogme3, but cleaner
-- and more general... for example, the same core functions
-- will be used to generate both HTML and TeXinfo code.

-- Current version: 2010aug03.

--------[ The "obj" table ]--------
-- We start with a object system similar to the one in newtrees.lua:
-- (find-dn4 "newtrees.lua" "metatables")
-- (find-dn4 "newtrees.lua" "trees")

objs = {}

string_mt = getmetatable("foo")
string_mt.__index = function (str, key)
    if key == "id" then return str end         -- str.id = str
    if key == "T"  then return objs[str] end   -- str.T  = objs[str]
    return string[key]                         -- str.f  = string.f
  end

obj_mt = obj_mt or {}
obj_mt.__index = function (T, key)
    if key == "T" then return T end
  end

setobjid = function (T, id)
    setmetatable(T, obj_mt)     -- add a metatable to T
    T.id = id                   -- set T.id = id
    objs[id] = T                -- set objs[id] = T
    return T
  end

--------[ ]--------
-- (find-dn4 "newtrees.lua" "trees")
-- (find-angg "TEXINFO/eev.texi")
-- (find-angg "TEXINFO/eev.texi.lua")

obj_newid = function (kind)
    local nkinds = "n"..kind.."s"
    objs[nkinds] = objs[nkinds] + 1
    local n = objs[nkinds]
    local id = "_"..kind..n
    return id
  end
obj_setid = function (kind, T)
    local id = obj_newid(kind)
    objs[id] = T
    T.id = id
    setmetatable(T, obj_mt)
    return T
  end

obj_link = function (obj1, dir1, dir2, obj2)
    obj1.T[dir1] = obj2.id
    obj2.T[dir2] = obj1.id
  end
obj_adjustchildren = function (this, dir)
    this = this.T
    for i=1,#this do
      local child = this[i].T
      this[i]         = child.id
      child[dir]      = this.id
      child[dir.."n"] = i
    end
  end
obj_appendto = function (parent, dir, this)
    tinsert(parent.T, this.id)
    this.T[dir] = parent.id
    this.T[dir.."n"] = #(parent.T)
  end
obj_next = function (this, dir)
    local parent = this.T[dir]
    local n = this.T[dir.."n"]
    return parent.T[n+1]
  end

objs.ntins = 0
newtin = function (nodename, ...)
    local T = obj_setid("tin", {nodename=nodename, ...})
    obj_adjustchildren(T, "L")
    return T
  end



-- Rough map:

--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
ee_dofile "~/blogme3/blogme4.lua"
nin = newtin2
a = nin("Top",
        nin "Zico",
        nin("Dani",
            nin "Ricardo",
            nin "Bruno",
            nin "Fernanda"),
        nin "Mari")
PP(objs)
for key,val in mysortedpairs(objs) do PP(key, val) end

PP(a)
PP(a.id)
PP(a.T.nodename)
PP(a.T[2].T.nodename)






--]]












-- Local Variables:
-- coding: raw-text-unix
-- End: