local std = require("core.std") local M = {} M.__index = M function M.fes(header, footer) local config = {} local site_config = {} local fes_mod = package.loaded.fes if fes_mod and fes_mod.config then config = fes_mod.config if config.site then site_config = config.site end end local self = { version = site_config.version or "", title = site_config.title or "Document", copyright = site_config.copyright or "© The Copyright Holder", favicon = "/image/favicon.ico", header = header or [[ {{TITLE}}
]], footer = footer or [[
]], parts = {} } return setmetatable(self, M) end function M:custom(str) table.insert(self.parts, str) return self end for name, func in pairs(std) do if type(func) == "function" then M[name] = function(self, ...) local result = func(...) table.insert(self.parts, result) return self end end end function M:build() local header = self.header header = header:gsub("{{TITLE}}", self.title or "Document") header = header:gsub("{{FAVICON}}", self.favicon or "") local footer = self.footer:gsub("{{COPYRIGHT}}", self.copyright or "© The Copyright Holder") return header .. table.concat(self.parts, "\n") .. footer end M.__tostring = function(self) return self:build() end return M