-- Modified from jplain
-- Basic! Transitional! In development! Not very good! Don't use it!
local plain = SILE.require("plain", "classes")
local zplain = plain { id = "zplain", base = plain }

SILE.call("bidi-off")

zplain:declareOption("layout", "yoko") -- horizonal = yoko

zplain:loadPackage("hanmenkyoshi")
function zplain:init()
  self:declareHanmenFrame( "content", {
    left = "8.3%pw", top = "11.6%ph",
    gridsize = "1zw", linegap = "1zw", linelength = 50,
    linecount = 30,
    tate = self.options.layout() == "tate"
  })
  SILE.settings.set("document.parskip", SILE.nodefactory.newVglue("1zw"))
  self.pageTemplate.firstContentFrame = self.pageTemplate.frames.content
  return self.base:init()
end

-- zw = the width of a full-width character
SILE.registerUnit("zw", { relative = true, definition = function (v)
  return v * SILE.shaper:measureChar("永").width
end})

-- setting the indent

SILE.languageSupport.loadLanguage("zh")
SILE.settings.set("document.parindent",SILE.nodefactory.newGlue("2zw"))

return zplain
