Commits

Anonymous committed 85517b7

partial rewrite; syntax now accepts line comments

  • Participants
  • Parent commits e08f605

Comments (0)

Files changed (6)

 *.tuo
 *.ted
 *.bib
+./testing/*
+./tmp.tex
+*–rst_temporary*
+./tmp/*
+./test/*

File makedummy.lua

-local outlang = arg[2] or "en" -- or “de” if you please
+local mathrandom = math.random
+local iowrite    = io.write
+
+------------------------------------------------------------------------
+-- strings
+------------------------------------------------------------------------
+
+local long_lorem = [[
+-l: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
+eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
+minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
+ex ea commodo consequat.
+
+]]
+local short_lorem = [[
+text: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
+eiusmod
+
+]]
 
 local strings = { }
-
 strings["en"] = {
     ["abbrev"]   = "abbrev",
     ["location"] = "location",
     ["keys"]     = "schlüssel",
 }
 
-local separator = "--------------------------------------------------\n"
+local separator = string.rep("-", 72) .. "\n"
 local keys = {
     "dummy1",
     "dummy2",
     "dummy5",
 }
 
-local function makekeys()
-    local howmany = math.random(1,#keys)
+------------------------------------------------------------------------
+-- key generator, emits random labels
+------------------------------------------------------------------------
+local makekeys = function ()
+    local howmany = mathrandom(1,#keys)
     local done = {}
     local tmp = {}
     for i=1, howmany do
-        local this = math.random(1,#keys)
+        local this = mathrandom(1,#keys)
         if not done[this] then
             tmp[#tmp+1] = keys[this]
             done[this] = true
     return result
 end
 
-for i=1, arg[1] or 50 do
-    if i ~= 1 then
-        io.write(separator .. "\n")
-    end
+------------------------------------------------------------------------
+-- main functionality
+------------------------------------------------------------------------
+local selected_comments = {
+  "this is a comment",
+  "nothing happened here, please do go on",
+  "I am invisible",
+  "you’re not supposed to be reading this, you know?",
+}
 
-    local rands = {}
-    for r=1, 3 do rands[r] = math.random(1,2) end
+local n_comments  = #selected_comments
+local comment_pfx = "; "
 
-    if rands[1] == 1 then -- standard
-        io.write(strings[outlang]["abbrev"] .. ": st" .. i .. "\n\n")
-    else    -- long variant
-        io.write(strings[outlang]["abbrev"] .. "-l: *LONG* st" .. i .. "\n\n")
-    end
+local random_comment = function ()
+  if mathrandom() < .05 then
+    iowrite(comment_pfx .. selected_comments[mathrandom(n_comments)] .. "\n")
+  end
+end
 
-    if rands[2] == 1 then -- standard
-        io.write(strings[outlang]["location"] .. ": Langform von st" .. i .. "\n\n")
-    else    -- long variant
-        io.write(strings[outlang]["location"] .. "-l: *LONG* Langform von st" .. i .. "\n\n")
-    end
+local do_main = function (outlang, times)
+  for i=1, times do
+      if i ~= 1 then iowrite(separator .. "\n") end
 
-    if rands[3] == 1 then -- standard
-        io.write([[
-text: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
+      local rands = { }
+      for r=1, 3 do rands[r] = mathrandom(1,2) end
 
-]])
-    else
-        io.write(strings[outlang]["text"] .. [[
--l: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
-tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
-quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
-consequat.
+      --- combine elements randomly
+      if rands[1] == 1 then -- standard
+          iowrite(strings[outlang]["abbrev"]
+                  .. ": st"
+                  .. i
+                  .. "\n\n")
+      else    -- long variant
+          iowrite(strings[outlang]["abbrev"]
+                  .. "-l: *LONG* st"
+                  .. i
+                  .. "\n\n")
+      end
 
-]])
-    end
-    
-    io.write(strings[outlang]["keys"] .. ": " .. makekeys() .. "\n\n")
+      random_comment()
+      if rands[2] == 1 then -- standard
+          iowrite(strings[outlang]["location"]
+                  .. ": Langform von st"
+                  .. i
+                  .. "\n\n")
+      else    -- long variant
+          iowrite(strings[outlang]["location"]
+                  .. "-l: *LONG* Langform von st"
+                  .. i
+                  .. "\n\n")
+      end
+
+      random_comment()
+      if rands[3] == 1 then -- standard
+          iowrite(short_lorem)
+      else
+          iowrite(strings[outlang]["text"] .. long_lorem)
+      end
+      random_comment()
+
+      iowrite(strings[outlang]["keys"] .. ": " .. makekeys() .. "\n\n")
+  end
 end
+
+
+local main = function ()
+  local times   = arg[1] or 50
+  local outlang = arg[2] or "en" -- or “de” if you please
+  do_main(outlang, times)
+  return 0
+end
+
+------------------------------------------------------------------------
+-- entry
+------------------------------------------------------------------------
+
+return main()
-=======
- What?
-=======
+========================================================================
+                                 What?
+========================================================================
 This module enables you to *typeset passages from books* together with
-abbreviations on printable and cuttable pages. Input is given in a plaintext
-database by means of key-value markup (TeX-markup is permitted on the content
-side). The output will resemble on-sided flashcards.
+abbreviations on printable and cuttable pages. Input is given in a
+plaintext database by means of key-value markup (TeX-markup is permitted
+on the content side). The output will resemble on-sided flashcards.
 
-======
- Why?
-======
-The project originated in late 2010 when the author was asked for assistance by
-a user from the ConTeXt mailing list (ntg-context@ntg.nl) who was trying to
-accomplish the task using a bibliography database. At the expense of readily
-available GUI-tools for editing a single-task plaintext markup was introduced
-instead of the bib format. After some debugging and expanding, t-bibelstellen
-seems to fulfill the needs of the original asker.
+========================================================================
+                                  Why?
+========================================================================
+The project originated in late 2010 when the author was asked for
+assistance by a user from the ConTeXt mailing list (ntg-context@ntg.nl)
+who was trying to accomplish the task using a bibliography database. At
+the expense of readily available GUI-tools for editing a single-task
+plaintext markup was introduced instead of the bib format. After some
+debugging and expanding, t-bibelstellen seems to fulfill the needs of
+the original asker.
 
-======
- How?
-======
+========================================================================
+                                  How?
+========================================================================
 Installation
-------------
-Install the module to the texmf-local tree of your *Minimals Distribution*,
-e.g.: ::
+------------------------------------------------------------------------
+Install the module to the texmf-local tree of your *Minimals
+Distribution*, e.g.: ::
 
-    cp -r ./tex ~/context/tex/texmf-local
+    cp -r ./tex ~/context/tex/texmf-local/
 
 The actual path may vary depending on where you installed the Minimals.
-Don’t forget to update ConTeXt’s file database by running ``context --generate``
-afterwards.
+Don’t forget to update ConTeXt’s file database by running ``context
+--generate`` afterwards.
 
 Usage
------
-The main documentation with examples can be found in ``testfile.tex``. To get an
-impression what well formed markup looks like, generate a testfile using: ::
+------------------------------------------------------------------------
+The main documentation with examples can be found in ``testfile.tex``.
+To get an impression what well formed markup looks like, generate a
+testfile using: ::
 
     texlua makedummy 100 > dummyfile.txt
 
 This should generate 100 fields of random markup. Have a look at
-``dummyfile.txt``, it should demonstrate all possible fields. Then process this
-via ``context testfile.tex``; don’t forget to play around with the parameters in
-``testfile.tex`` as they determine how the output will look like.
+``dummyfile.txt``, it should demonstrate all possible fields. Then
+process this via ``context testfile.tex``; don’t forget to play around
+with the parameters in ``testfile.tex`` as they determine how the output
+will look like.
 
-======
- Who?
-======
-Written by Philipp Gesang, string.format("%s@%s", "megas.kapaneus", "gmail.com");
-bitbucket page: http://bitbucket.org/phg/ .
+========================================================================
+                              Whose fault?
+========================================================================
+|rstcontext| was written by Philipp Gesang, ``megas.kapaneus`` at
+``gmail`` dot ``com`` (find me on BitBucket_).
 
-==========
- Can I …?
-==========
+========================================================================
+                                Can I …?
+========================================================================
 The license (*2-clause BSD*) can be read next to the top of
 ``t-bibelstellen.mkiv``.
 
+.. _BitBucket:  http://bitbucket.org/phg

File testfile.tex

 \setuppapersize[A4,landscape][A4,landscape]
 \showframe
-\setuplayout[%
-  backspace=0mm,
-  topspace=0mm, 
-  header=0mm,
-  footer=0mm,
-  width=297mm,
-  height=210mm, 
-]
+\setuplayout[page]
 
 \setupwhitespace[none]
 

File tex/context/third/bstellen/bibelstellen.lua

 #!/usr/bin/env texlua
---------------------------------------------------------------------------------
+------------------------------------------------------------------------
 --         FILE:  bibelstellen.lua
 --        USAGE:  part of ConTeXt module “t-bibelstellen.mkiv”
 --  DESCRIPTION:  typeset bible quotations automagically
 -- REQUIREMENTS:  context mkiv
 --       AUTHOR:  Philipp Gesang (Phg), <megas.kapaneus@gmail.com>
---      VERSION:  hg tip
+--      VERSION:  hg tip, rev20+
 --      CREATED:  13/10/10 01:15:28 CEST
---------------------------------------------------------------------------------
+------------------------------------------------------------------------
 --
 
-local   C, Ct, P, S, V = lpeg.C, lpeg.Ct, lpeg.P, lpeg.S, lpeg.V
+require "lpeg"
+require "unicode"
 
-local utf = unicode.utf8
+local C, Ct, P, S, V = lpeg.C, lpeg.Ct, lpeg.P, lpeg.S, lpeg.V
+local lpegmatch      = lpeg.match
 
-local warn = function(...)
-    io.write("*t-bs*>")
-    for _,str in ipairs({...}) do
-        io.write(" " .. str)
+local contextframed       = context.framed
+local contextpage         = context.page
+local contextpar          = context.par
+local contextbgroup       = context.bgroup
+local contextegroup       = context.egroup
+local contextendgraf      = context.endgraf
+local contextstopcolumns  = context.stopcolumns
+local contextstartcolumns = context.startcolumns
+
+local ioopen        = io.open
+local iowrite       = io.write
+local stringexplode = string.explode
+local stringfind    = string.find
+local stringmatch   = string.match
+local stringsub     = string.sub
+local utflower      = unicode.utf8.lower
+
+local warn = function (...)
+    local args = { ... }
+    iowrite("*t-bs*>")
+    for i=1, #args do
+        iowrite(" " .. args[i])
     end
-    io.write("\n")
+    iowrite"\n"
     return 0
 end
 
 local td
 if context then
     thirddata = thirddata or { }
-    td = thirddata
+    td        = thirddata
 else
-    td = {}
+    td = { }
 end
-td.stellen = {}
-td.stellen.data = {}
-td.stellen.keywords = {}
-td.stellen.parameters = {}
-td.stellen.warn = warn
 
+--td.stellen.escape = function (str)
+--    return str:gsub("\\","\\\\")
+--end
+
+td.stellen              = { }
+td.stellen.data         = { }
+td.stellen.keywords     = { }
+td.stellen.parameters   = { }
+td.stellen.warn         = warn
+
+------------------------------------------------------------------------
+-- aux functions
+------------------------------------------------------------------------
 do
     local stripper = P{
         [1] = "stripper",
-        stripper = V"space"^0 * C((V"space"^0 * (V"escaped" + V"nospace")^1)^0),
-        space    = S(" \t\v\n"),
+        stripper = V"space"^0 * C((V"space"^0
+                                 * (V"escaped" + V"nospace")^1)^0),
+        space    = S(" \t\v\n\r"),
         nospace  = 1 - V"space",
         escaped  = P"\\" * V"space"
-    }    
-    function string.strip(str)
-        return stripper:match(str) or ""
-    end  
+    }
+    string.strip = function (str)
+        return lpegmatch(stripper, str) or ""
+    end
 end
+local stringstrip = string.strip
+
+
+local string_of_file = function (fname)
+    local h = assert(ioopen(fname, "r"), "Not a file: " .. fname)
+    local result = h:read"*all"
+    h:close()
+    if stringmatch(result, "^\239\187\191") then
+        --- utf8 BOM is evil
+        return stringsub(result, 4)
+    end
+    return result
+end
+
+------------------------------------------------------------------------
+-- strings
+------------------------------------------------------------------------
 
 local localized_strings = { -- all except “keys” have a long alternative
     ["keys"]       = "schlüssel",
     ["text"]       = "text",
 }
 
-local function localize (str)
+local localize = function (str)
     return localized_strings[str] or str
 end
 
-function td.stellen.add_entry (...)
+------------------------------------------------------------------------
+-- directives, for use with parser
+------------------------------------------------------------------------
+
+local add_entry = function (...)
     local all = { ... }
-    local new = {}
+    local new = { }
     local id, keywords
 
     local n = 1
     while n <= #all do
         local this = all[n]
         local long = false
-        local key, value = utf.lower(this[1]), string.strip(this[2])
+        local key, value = utflower(this[1]), stringstrip(this[2])
 
-        if key:find("%-l$") then
+        if stringfind(key, "%-l$") then
             long = true
-            key = key:match("^(.*)-l$")
+            key = stringmatch(key, "^(.*)-l$")
         end
 
         key = localize(key)
         end
 
         if key == "schlüssel" then
-            keywords = string.explode(value, ",")
+            keywords = stringexplode(value, ",")
         end
 
         --new[key] = value
     end
     warn("adding entry:", id)
 
-    for _, key in next,keywords do
-        key = string.strip(key)
+    local tdsk = td.stellen.keywords
+    for _, key in next, keywords do
+        key = stringstrip(key)
         -- this *does* look awful
-        local tdskk = td.stellen.keywords[key] or {}
+        local tdskk = tdsk[key] or {}
         tdskk[#tdskk+1] = id
-        td.stellen.keywords[key] = tdskk
+        tdsk[key]       = tdskk
     end
     td.stellen.data[id] = new
 end
 
+------------------------------------------------------------------------
+-- stellen input parser
+------------------------------------------------------------------------
 local b_parser = P{
     [1] = "file",
+    file             = V"block" * (V"separator"^1 * V"block")^0,
 
-    file = V"block" * (V"separator"^1 * V"block")^0,
+    dash             = P"-",
+    colon            = P":",
+    comment_char     = P";",
+    eol              = P"\n\r" + P"\r\n" + P"\r" + P"\n", -- you never know
+    eof              = -P(1),
+    space            = P" ",
+    tabs             = S"\t\v",
+    whitespace       = (V"space" + V"tabs"),
+    blank_line       = V"whitespace"^0 * V"eol",
+    rest_of_line     = (1 - V"eol")^0  * V"eol",
+    blank_or_comment = V"blank_line" + V"comment_line",
+    comment_line     = V"comment_char"^1 * V"rest_of_line",    -- ignored
 
-    dash = P"-",
-    colon = P":",
-    eol = P"\n",
-    eof = -P(1),
-    space = P" ",
-    tabs = S"\t\v",
-    whitespace = (V"space" + V"tabs"),
-    blank_line = V"whitespace"^0 * V"eol",
+    separator        = V"blank_or_comment"^0
+                     * V"dash"^1
+                     * V"eol"
+                     * V"blank_or_comment"^0
+                     ,
+    block            = V"blank_or_comment"^0  * V"line"
+                     * (V"blank_or_comment"^1 * V"line")^0
+                     * (V"blank_or_comment"^0 + V"whitespace"^0 * V"eof")
+                     / add_entry
+                     ,
+    line             = V"comment_line" + V"entry",
+    entry            = Ct(C(V"key") * V"colon" * C(V"value")),
+    key              = V"schluessel"
+                     + ((V"stelle" + V"sigle" + V"text")
+                     * V"longsuffix"^-1)
+                     ,
+    stelle           = V"stelle_en"     + V"stelle_de",
+    sigle            = V"sigle_en"      + V"sigle_de",
+    text             = V"text_en"       + V"text_de",
+    schluessel       = V"schluessel_en" + V"schluessel_de",
 
-    separator = V"dash"^1 * V"eol",
+    --- TODO make strings configurable
+    stelle_en        = P"LOCATION"  + P"Location" + P"location",
+    sigle_en         = P"ABBREV"    + P"Abbrev"   + P"abbrev",
+    text_en          = P"TEXT"      + P"Text"     + P"text",
+    schluessel_en    = P"KEYS"      + P"Keys"     + P"keys",
 
-    block = V"blank_line"^0 * V"entry"
-          * (V"blank_line"^1 * V"entry")^0
-          * (V"blank_line"^0 + V"eof")
-          / td.stellen.add_entry
-          ,
+    stelle_de        = P"STELLE"    + P"Stelle"    + P"stelle",
+    sigle_de         = P"SIGLE"     + P"Sigle"     + P"sigle",
+    text_de          = P"TEXT"      + P"Text"      + P"text",
+    schluessel_de    = P"SCHLÜSSEL" + P"Schlüssel" + P"schlüssel",
 
-    entry = Ct(C(V"key") * V"colon" * C(V"value")),
-
-    key = V"schluessel" + ((V"stelle" + V"sigle" + V"text") * V"longsuffix"^-1),
-
-    stelle      = V"stelle_en"     + V"stelle_de",
-    sigle       = V"sigle_en"      + V"sigle_de",
-    text        = V"text_en"       + V"text_de",
-    schluessel  = V"schluessel_en" + V"schluessel_de",
-
-    stelle_en      = P"LOCATION" + P"Location" + P"location",
-    sigle_en       = P"ABBREV"   + P"Abbrev"   + P"abbrev",
-    text_en        = P"TEXT"     + P"Text"     + P"text",
-    schluessel_en  = P"KEYS"     + P"Keys"     + P"keys",
-
-    stelle_de      = P"STELLE"    + P"Stelle"    + P"stelle",
-    sigle_de       = P"SIGLE"     + P"Sigle"     + P"sigle",
-    text_de        = P"TEXT"      + P"Text"      + P"text",
-    schluessel_de  = P"SCHLÜSSEL" + P"Schlüssel" + P"schlüssel",
-
-    longsuffix = V"dash" * P"l",
-
-    value = (1 - (V"blank_line" * (V"key" + V"separator")))^1,
+    longsuffix       = V"dash" * P"l",
+    --value            = (1 - (V"blank_or_comment"
+    --                       * (V"key" + V"separator")))^1,
+    value_illegal    = V"eol" * V"blank_or_comment",
+    value            = (1 - V"value_illegal")^1,
 }
 
-function td.stellen.get_data (filename)
+------------------------------------------------------------------------
+-- input file processing
+------------------------------------------------------------------------
+
+local get_data = function (filename)
     local files = {}
-    if filename:match(",") then
+    if stringmatch(filename, ",") then
         -- multiple files
-        files = filename:explode(",+")
+        files = stringexplode(filename, ",+")
     else
         files = { filename }
     end
 
     for _,file in next, files do
         warn("Processing file " .. file)
-        local f = assert(io.open(file, "r"), "No such file: " .. file)
-        local data = f:read("*all")
-        f:close()
-        b_parser:match(data)
+        local data = string_of_file(file)
+        lpegmatch(b_parser, data)
     end
 
     return 0
 end
 
-function td.stellen.escape (str)
-    return str:gsub("\\","\\\\")
-end
+------------------------------------------------------------------------
+-- typesetting routines
+------------------------------------------------------------------------
 
-function td.stellen.do_do_one(entry)
+local do_do_one = function (entry)
     local tdsp = td.stellen.parameters
 
     local thishead = entry[tdsp.head]["value"]
     local thisbody = entry.text.value
     local thisbodystyle = entry.text.long and tdsp.longbodystyle or tdsp.bodystyle
 
-    context.bgroup()
+    contextbgroup()
         context(thisheadstyle)
         context(thishead)
-    context.egroup()
-    context.endgraf()
+    contextegroup()
+    contextendgraf()
     context(tdsp.inbetween)
-    context.bgroup()
+    contextbgroup()
         context(thisbodystyle)
         context(thisbody)
-    context.egroup()
-    context.endgraf()
+    contextegroup()
+    contextendgraf()
     return ""
 end
 
-function td.stellen.do_one(entry)
+local do_one = function (entry)
     local tdsp = td.stellen.parameters
-    context.framed( {
-            frame  = "off",
-            topframe = "off",
-            bottomframe = tdsp.frame,
-            leftframe = tdsp.frame,
-            rightframe = tdsp.frame,
-            width  = "\\hsize",
-            height = td.stellen.parameters.boxheight .. "sp",
-            align  = "lohi", --"right",
-            loffset = tdsp.foffset,
-            roffset = tdsp.foffset,
+    contextframed( {
+            frame        = "off",
+            topframe     = "off",
+            bottomframe  = tdsp.frame,
+            leftframe    = tdsp.frame,
+            rightframe   = tdsp.frame,
+            width        = "\\hsize",
+            height       = td.stellen.parameters.boxheight .. "sp",
+            align        = "lohi", --"right",
+            loffset      = tdsp.foffset,
+            roffset      = tdsp.foffset,
         }, 
-        function()
-                td.stellen.do_do_one(entry)
+        function ()
+                do_do_one(entry)
             return ""
         end
     )
     return 0
 end
 
-function td.stellen.typeset (filename, categories)
-    td.stellen.get_data(filename)
+td.stellen.typeset = function (filename, categories)
+    get_data(filename)
     warn("done processing file:", filename)
 
-    local done = {}
+    local done = { }
     local cnt  = 1
     local tdsk = td.stellen.keywords
     local tdsd = td.stellen.data
     local tdsp = td.stellen.parameters
-    context.startcolumns({
-        n = tdsp.columns,
+    contextstartcolumns({
+        n        = tdsp.columns,
         distance = "0mm"
     })
     context.offinterlineskip()
-    for _,category in next,string.explode(categories, ",") do
-        category = string.strip(category)
+    for _,category in next,stringexplode(categories, ",") do
+        category = stringstrip(category)
         if tdsk[category] then
             local keys = tdsk[category]
             for _,key in next,keys do
                 if not done[key] then
                     if cnt > 1 and cnt % (tdsp.columns * tdsp.rows) == 1 then
                         warn("starting new page at entry nr.", cnt)
-                        context.page()
+                        contextpage()
                     elseif cnt > 1 and cnt % 6 == tdsp.rows then
-                        context.par()
+                        contextpar()
                     end
-                    td.stellen.do_one(tdsd[key])
+                    do_one(tdsd[key])
                     done[key] = true
-                    cnt = cnt + 1
+                    cnt       = cnt + 1
                 end
             end
         end
     end
-    context.stopcolumns()
+    contextstopcolumns()
     return 0
 end
 
+------------------------------------------------------------------------
+-- wrapper for cli
+------------------------------------------------------------------------
 if not context then
-    return td.stellen.get_data(arg[1])
+    return get_data(arg[1])
 end
 
+-- vim:tw=72:ts=4:sw=4:expandtab

File tex/context/third/bstellen/t-bibelstellen.mkiv

 %D \module [
 %D         file=t-bibelstellen,
-%D      version=hg-r12+ 2011-01-03 09:04:44+0100,
+%D      version=hg-r20+ 2012-04-30 18:19:04+0200,
 %D        title=\CONTEXT\ User Module,
 %D       author=Philipp Gesang,
 %D         date=\currentdate,
 %D      license=2-clause BSD,
 %D ]
 
-%D Copyright 2011 Philipp Gesang. All rights reserved.
-
-%D Redistribution and use in source and binary forms, with or without
-%D modification, are permitted provided that the following conditions are met:
-%D     1. Redistributions of source code must retain the above copyright notice,
-%D     this list of conditions and the following disclaimer.
-
-%D     2. Redistributions in binary form must reproduce the above copyright
-%D     notice, this list of conditions and the following disclaimer in the
-%D     documentation and/or other materials provided with the distribution.
-
-%D THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR
-%D IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-%D MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-%D EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
-%D INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-%D BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-%D DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-%D LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
-%D OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-%D ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+%D Copyright 2011--2012 Philipp Gesang. All rights reserved.
+%D
+%D Redistribution and use in source and binary forms, with or
+%D without modification, are permitted provided that the
+%D following conditions are met:
+%D     1. Redistributions of source code must retain the above
+%D        copyright notice, this list of conditions and the
+%D        following disclaimer.
+%D
+%D     2. Redistributions in binary form must reproduce the above
+%D        copyright notice, this list of conditions and the
+%D        following disclaimer in the documentation and/or other
+%D        materials provided with the distribution.
+%D
+%D THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER ``AS IS''
+%D AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+%D LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+%D FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
+%D SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
+%D DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+%D CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+%D PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+%D DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+%D ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+%D LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+%D IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+%D THE POSSIBILITY OF SUCH DAMAGE.
 
 
 %M \usemodule[bibelstellen]
 %M \loadsetups[t-bibelstellen.xml]
 
 
-\writestatus{loading} {Quotation Pretty Printer ;-)}
+\writestatus {loading} {Quotation Pretty Printer ;-)}
 
-\startmodule[bibelstellen]
+\startmodule [bibelstellen]
 
-%\startinterface all
-  %\setinterfacevariable {bibelstellen} {bibelstellen}
-%\stopinterface
+\startinterface all
+  \setinterfacevariable {bstellen} {bstellen}
+\stopinterface
 
 \unprotect
 
 \definenamespace [BS] [
+  command=no,
+  comment=typeset snippets from reference works using KISS markup,
+  name=\v!bstellen,
+  parent=\v!bstellen,
+  setup=list,
+  style=no,
   type=module,
-  comment=typeset snippets from reference works using KISS markup,
   version=hg-r12+,
-  name=bstellen,
-  style=no,
-  command=no,
-  setup=list,
-  parent=bstellen
 ]
 
 \ctxlua{environment.loadluafile("bibelstellen")}
   \setuppapersize[\bstellenparameter{paper},landscape][\bstellenparameter{paper},landscape]%
   \startluacode
     local td = thirddata or {}
-    td.stellen.parameters.columns   = tonumber("\bstellenparameter{columns}")
-    td.stellen.parameters.rows      = tonumber("\bstellenparameter{rows}")
-    td.stellen.parameters.headstyle = "\luaescapestring{\bstellenparameter{headstyle}}"
-    td.stellen.parameters.bodystyle = "\luaescapestring{\bstellenparameter{bodystyle}}"
-    td.stellen.parameters.head      = "\bstellenparameter{head}"
-    td.stellen.parameters.frame     = "\bstellenparameter{frame}"
-    td.stellen.parameters.foffset   = "\bstellenparameter{frameoffset}"
-    td.stellen.parameters.inbetween = "\luaescapestring{\bstellenparameter{inbetween}}"
-    td.stellen.parameters.boxheight = tex.vsize / td.stellen.parameters.rows
+    local tdsp = td.stellen.parameters
+    tdsp.columns   = tonumber("\bstellenparameter{columns}")
+    tdsp.rows      = tonumber("\bstellenparameter{rows}")
+    tdsp.headstyle = "\luaescapestring{\bstellenparameter{headstyle}}"
+    tdsp.bodystyle = "\luaescapestring{\bstellenparameter{bodystyle}}"
+    tdsp.head      = "\bstellenparameter{head}"
+    tdsp.frame     = "\bstellenparameter{frame}"
+    tdsp.foffset   = "\bstellenparameter{frameoffset}"
+    tdsp.inbetween = "\luaescapestring{\bstellenparameter{inbetween}}"
+    tdsp.boxheight = tex.vsize / td.stellen.parameters.rows
   \stopluacode
 %
   \doifsomethingelse{\bstellenparameter{longheadstyle}}
 %\def\dosetupstellen{\dosingleargument\getparameters[BS]}
 
 \setupbstellen[
-  paper=A4,
-  columns=2,
-  rows=6,
-  %longheadstyle={\tfx\sc},
-  %longbodystyle={\tfx},
-  headstyle=\sc,  % any style switch
-  bodystyle=\tf,  % any style switch
-  head=stelle,   % sigle|stelle
-  file=\jobname.txt,
-  frame=off,
-  frameoffset=1em,
-  inbetween={\blank[small]}
+      bodystyle=\tf,              % any style switch
+        columns=2,
+           file=\jobname.txt,
+          frame=off,
+    frameoffset=1em,
+           head=stelle,           % sigle|stelle
+      headstyle=\sc,              % any style switch
+      inbetween={\blank[small]},
+% longbodystyle={\tfx},
+% longheadstyle={\tfx\sc},
+          paper=A4,
+           rows=6,
 ]
 
 \def\typesetstellen[#1]#2{%