diff options
author | Karl Berry <karl@freefriends.org> | 2016-04-22 22:14:39 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-04-22 22:14:39 +0000 |
commit | fc4466b32ed330a956ac603b00fd145524cff49a (patch) | |
tree | 2c50e2b8de13aa9233b2c76dffe201558f169e86 /Master/texmf-dist/tex/context/base/mkiv/strc-lev.lua | |
parent | 50e2368597d5f6fe2057195d0ae6a9f2044923e4 (diff) |
context (22apr16)
git-svn-id: svn://tug.org/texlive/trunk@40691 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/strc-lev.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/strc-lev.lua | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/strc-lev.lua b/Master/texmf-dist/tex/context/base/mkiv/strc-lev.lua new file mode 100644 index 00000000000..d7ffd6af434 --- /dev/null +++ b/Master/texmf-dist/tex/context/base/mkiv/strc-lev.lua @@ -0,0 +1,75 @@ +if not modules then modules = { } end modules ['strc-lev'] = { + version = 1.001, + comment = "companion to strc-lev.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +local insert, remove = table.insert, table.remove + +local context = context +local interfaces = interfaces + +local sections = structures.sections +local implement = interfaces.implement + +local v_default = interfaces.variables.default + +sections.levels = sections.levels or { } + +local level = 0 +local levels = sections.levels +local categories = { } + +local f_two_colon = string.formatters["%s:%s"] + +storage.register("structures/sections/levels", levels, "structures.sections.levels") + +local function definesectionlevels(category,list) + levels[category] = utilities.parsers.settings_to_array(list) +end + +local function startsectionlevel(category) + category = category ~= "" and category or v_default + level = level + 1 + local lc = levels[category] + if not lc or level > #lc then + context.nostarthead { f_two_colon(category,level) } + else + context.dostarthead { lc[level] } + end + insert(categories,category) +end + +local function stopsectionlevel() + local category = remove(categories) + if category then + local lc = levels[category] + if not lc or level > #lc then + context.nostophead { f_two_colon(category,level) } + else + context.dostophead { lc[level] } + end + level = level - 1 + else + -- error + end +end + +implement { + name = "definesectionlevels", + actions = definesectionlevels, + arguments = { "string", "string" } +} + +implement { + name = "startsectionlevel", + actions = startsectionlevel, + arguments = "string" +} + +implement { + name = "stopsectionlevel", + actions = stopsectionlevel, +} |