<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.luatex.org/index.php?action=history&amp;feed=atom&amp;title=T_wo_T_r%3Acommands.lua</id>
	<title>T wo T r:commands.lua - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.luatex.org/index.php?action=history&amp;feed=atom&amp;title=T_wo_T_r%3Acommands.lua"/>
	<link rel="alternate" type="text/html" href="https://wiki.luatex.org/index.php?title=T_wo_T_r:commands.lua&amp;action=history"/>
	<updated>2026-05-31T15:12:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.luatex.org/index.php?title=T_wo_T_r:commands.lua&amp;diff=3563&amp;oldid=prev</id>
		<title>Rkrug: Created page with &quot; &lt;nowiki&gt;   --- Copyright (c) 2021 by Toadstone Enterprises. --- ISC-type license, see License.txt for details.   -------------------------------------------------------------...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.luatex.org/index.php?title=T_wo_T_r:commands.lua&amp;diff=3563&amp;oldid=prev"/>
		<updated>2021-02-22T18:34:15Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot; &amp;lt;nowiki&amp;gt;   --- Copyright (c) 2021 by Toadstone Enterprises. --- ISC-type license, see License.txt for details.   -------------------------------------------------------------...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt; &amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--- Copyright (c) 2021 by Toadstone Enterprises.&lt;br /&gt;
--- ISC-type license, see License.txt for details.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-----------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local util = require(&amp;quot;utils&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
local read_group            = util.read_group&lt;br /&gt;
local is_command_terminator = util.is_command_terminator&lt;br /&gt;
local is_whitespace         = util.is_whitespace&lt;br /&gt;
local node_type             = util.node_type&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local reader = require(&amp;quot;reader&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
local push_reader   = reader.push_reader&lt;br /&gt;
local pop_reader    = reader.pop_reader&lt;br /&gt;
local read_value    = reader.read_value&lt;br /&gt;
local unread_value  = reader.unread_value&lt;br /&gt;
local replace_text  = reader.replace_text&lt;br /&gt;
local pos           = reader.pos&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local format = require(&amp;quot;format&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
local update_state         = format.update_state&lt;br /&gt;
local update_locals        = format.update_locals&lt;br /&gt;
local push_tbl             = format.push_tbl&lt;br /&gt;
local pop_tbl              = format.pop_tbl&lt;br /&gt;
local top_tbl              = format.top_tbl&lt;br /&gt;
local push_do_command_stop = format.push_do_command_stop&lt;br /&gt;
local footnote_tbl         = format.footnote_tbl&lt;br /&gt;
local emph_text_font        = format.emph_text_font&lt;br /&gt;
local bold_text_font        = format.bold_text_font&lt;br /&gt;
local title_font            = format.title_font&lt;br /&gt;
local superscript_font      = format.superscript_font&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local pages = require(&amp;quot;pages&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
local process_par = pages.process_par&lt;br /&gt;
local build_par   = pages.build_par&lt;br /&gt;
local build_pages = pages.build_pages&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local main = main or require(&amp;quot;main&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
local main_loop = main.main_loop&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-----------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--- We will keep our various commands in a table, so that we&lt;br /&gt;
--- can retrieve them by name. We use a metatable to throw&lt;br /&gt;
--- a consistent error if a non-existant command is looked&lt;br /&gt;
--- for. The idea was that this would throw the error at that&lt;br /&gt;
--- time, instead of later on when we tried to use it.&lt;br /&gt;
&lt;br /&gt;
local command_table = {}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local mt = {__index = function (_, command)&lt;br /&gt;
              error(&amp;quot;Bad Command:&amp;quot; .. command)&lt;br /&gt;
            end&lt;br /&gt;
           }&lt;br /&gt;
&lt;br /&gt;
setmetatable(command_table, mt)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local register_command = function(name, func)&lt;br /&gt;
  command_table[name] = func&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
-----------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local get_command = function()&lt;br /&gt;
  -- A command in initiated by a &amp;quot;\&amp;quot;, and terminated by a&lt;br /&gt;
  -- &amp;quot;[&amp;quot;, &amp;quot;{&amp;quot;, or whitespace. (But the initiating &amp;quot;\&amp;quot; has&lt;br /&gt;
  -- already been read past.) Return the command as a string.&lt;br /&gt;
  -- We also &amp;#039;eat&amp;#039; any extra following whitespace, and then&lt;br /&gt;
  -- back up by one character, so the command can see the&lt;br /&gt;
  -- terminator; although we may lose the distinction of&lt;br /&gt;
  -- which whitespace terminated the command.&lt;br /&gt;
  -- This backing up will also allow the main_loop to see&lt;br /&gt;
  -- the &amp;quot;{&amp;quot;, if there was one, and so doing the do_command_start.&lt;br /&gt;
&lt;br /&gt;
  local command = &amp;quot;&amp;quot;&lt;br /&gt;
  local value = read_value()&lt;br /&gt;
&lt;br /&gt;
  if is_command_terminator(value) then&lt;br /&gt;
    -- A one character command, consisting solely of a command terminator.&lt;br /&gt;
    command = unicode.utf8.char(value)&lt;br /&gt;
  else&lt;br /&gt;
    while (value and (not is_command_terminator(value))) do&lt;br /&gt;
      command = command .. unicode.utf8.char(value)&lt;br /&gt;
      value = read_value()&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  while is_whitespace(value) do&lt;br /&gt;
    -- eat the white&lt;br /&gt;
    value = read_value()&lt;br /&gt;
  end&lt;br /&gt;
  &lt;br /&gt;
  -- so command can see the &amp;#039;terminator&amp;#039;&lt;br /&gt;
  -- Note that if the command was terminated by whitespace,&lt;br /&gt;
  -- and then followed by more whitespace, we will not be&lt;br /&gt;
  -- distinguishing between the various types of whitespace.&lt;br /&gt;
  -- Does this matter?&lt;br /&gt;
  unread_value()&lt;br /&gt;
  &lt;br /&gt;
  return command&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--- WARNING: An Emph in a Footnote will result in a change of font size!&lt;br /&gt;
--- There should be some notion of a font family where given the current&lt;br /&gt;
--- font, an appropriate Emph font can be chosen. At least consider size.&lt;br /&gt;
&lt;br /&gt;
--- Emph displays most of the standard ways to do a command.&lt;br /&gt;
--- We define a function do_emph, which will then be registered.&lt;br /&gt;
&lt;br /&gt;
local do_emph = function()&lt;br /&gt;
  -- We start off with some initialization. In this case, are we&lt;br /&gt;
  -- emphasizing the following group, or are we (presumably) already&lt;br /&gt;
  -- within a group?&lt;br /&gt;
&lt;br /&gt;
  local value = read_value()&lt;br /&gt;
  unread_value{}&lt;br /&gt;
&lt;br /&gt;
  if value == unicode.utf8.byte(&amp;quot;{&amp;quot;) then&lt;br /&gt;
    -- We emphasize the following group&lt;br /&gt;
&lt;br /&gt;
    -- We now finish the initialization in this branch of the&lt;br /&gt;
    -- if statement.&lt;br /&gt;
    &lt;br /&gt;
    -- We push the current table, to that we can restore it&lt;br /&gt;
    -- at the end, namely in the do_command_stop.&lt;br /&gt;
    push_tbl(copy_table(top_tbl()))&lt;br /&gt;
    &lt;br /&gt;
    -- We have finished the initialization, so we define a&lt;br /&gt;
    -- do_command_start function to be executed upon encountering&lt;br /&gt;
    -- the &amp;quot;{&amp;quot;&lt;br /&gt;
    local do_command_start = function()&lt;br /&gt;
                               -- Switch over to the Emph font.&lt;br /&gt;
                               local tbl = top_tbl()&lt;br /&gt;
                               tbl.font = emph_text_font&lt;br /&gt;
                             end&lt;br /&gt;
 &lt;br /&gt;
    -- We then put this function into the proper place in State.&lt;br /&gt;
    State.do_command_start = do_command_start&lt;br /&gt;
    &lt;br /&gt;
    -- We also define a do_command_stop function, to be executed&lt;br /&gt;
    -- upon encountering the terminating &amp;quot;}&amp;quot;.&lt;br /&gt;
    local do_command_stop  = function()&lt;br /&gt;
                               -- Pop the table, to return to the&lt;br /&gt;
                               -- previous situation.&lt;br /&gt;
                               pop_tbl()&lt;br /&gt;
                             end&lt;br /&gt;
    -- We then put this function into the proper place in State.&lt;br /&gt;
    push_do_command_stop(do_command_stop)&lt;br /&gt;
&lt;br /&gt;
  else&lt;br /&gt;
    -- Emphasize all the following text (presumably within a group)&lt;br /&gt;
    -- This change of font will get reset when the group is exited,&lt;br /&gt;
    -- since State.tbl has been copied and pushed upon entrance into&lt;br /&gt;
    -- the group.&lt;br /&gt;
    local tbl = top_tbl()&lt;br /&gt;
    tbl.font = emph_text_font&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
register_command(&amp;quot;Emph&amp;quot;, do_emph)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local do_bold = function()&lt;br /&gt;
  local value = read_value()&lt;br /&gt;
  unread_value{}&lt;br /&gt;
&lt;br /&gt;
  if value == unicode.utf8.byte(&amp;quot;{&amp;quot;) then&lt;br /&gt;
    push_tbl(copy_table(top_tbl()))&lt;br /&gt;
    local do_command_start = function()&lt;br /&gt;
                               local tbl = top_tbl()&lt;br /&gt;
                               tbl.font = bold_text_font&lt;br /&gt;
                             end&lt;br /&gt;
    State.do_command_start = do_command_start&lt;br /&gt;
    local do_command_stop  = function()&lt;br /&gt;
                               pop_tbl()&lt;br /&gt;
                             end&lt;br /&gt;
    push_do_command_stop(do_command_stop)&lt;br /&gt;
  else&lt;br /&gt;
    local tbl = top_tbl()&lt;br /&gt;
    tbl.font = bold_text_font&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
register_command(&amp;quot;Bold&amp;quot;, do_bold)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local do_input = function()&lt;br /&gt;
  -- Input a file.&lt;br /&gt;
&lt;br /&gt;
  local filename&lt;br /&gt;
&lt;br /&gt;
  local do_command_start = function()&lt;br /&gt;
                             -- so that the following read_group will see the opening &amp;quot;{&amp;quot;&lt;br /&gt;
                             unread_value()&lt;br /&gt;
                             -- Note that with the argument true to read_group&lt;br /&gt;
                             -- Input{filename}&lt;br /&gt;
                             -- Input  {  filename  }&lt;br /&gt;
                             -- Input{file name}&lt;br /&gt;
                             -- wil all read &amp;quot;filename&amp;quot;&lt;br /&gt;
                             -- Do we want this? The second seems useful, the&lt;br /&gt;
                             -- third does not.&lt;br /&gt;
                             filename = read_group(true)&lt;br /&gt;
                             -- So that main_loop will see the closing &amp;quot;}&amp;quot;&lt;br /&gt;
                             -- and call do_command_stop.&lt;br /&gt;
                             unread_value()&lt;br /&gt;
                           end&lt;br /&gt;
  State.do_command_start = do_command_start&lt;br /&gt;
  local do_command_stop = function()&lt;br /&gt;
                            -- We could have done all this above.&lt;br /&gt;
                            -- Now read in the file&lt;br /&gt;
                            push_reader(&amp;quot;file:&amp;quot; .. filename)&lt;br /&gt;
                            -- Recursively call main_loop to typeset the&lt;br /&gt;
                            -- material we have read in. At the end of the&lt;br /&gt;
                            -- files contents, main_loop will terminate,&lt;br /&gt;
                            -- and execution will resume with the call to&lt;br /&gt;
                            -- pop_reader below.&lt;br /&gt;
                            -- Why do I need to qualify this?&lt;br /&gt;
                            main.main_loop()&lt;br /&gt;
                            -- Back to the original reader.&lt;br /&gt;
                            pop_reader()&lt;br /&gt;
                            -- And we now build the pages. We could probably&lt;br /&gt;
                            -- just leave the material there, but I am&lt;br /&gt;
                            -- envisioning each of these input files to&lt;br /&gt;
                            -- represent a chapter, to be typeset as their&lt;br /&gt;
                            -- own set of pages.&lt;br /&gt;
                            build_pages()&lt;br /&gt;
                          end&lt;br /&gt;
 push_do_command_stop(do_command_stop)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
register_command(&amp;quot;Input&amp;quot;, do_input)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local do_fix = function()&lt;br /&gt;
  -- If one is transcribing a document, one may wish to correct&lt;br /&gt;
  -- typos. Three args - {&amp;lt;old&amp;gt;}{&amp;lt;new&amp;gt;}{&amp;lt;reason&amp;gt;}&lt;br /&gt;
  -- Perhaps not too useful in general, but a nice demonstration&lt;br /&gt;
  -- piece.&lt;br /&gt;
&lt;br /&gt;
  -- Read the three groups, and insert the new text.&lt;br /&gt;
  local start  = pos()&lt;br /&gt;
  local old    = read_group(false)&lt;br /&gt;
  local new    = read_group(false)&lt;br /&gt;
  local reason = read_group(false)&lt;br /&gt;
  local stop   = pos()&lt;br /&gt;
  replace_text(new, start, stop-1)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
register_command(&amp;quot;Fix&amp;quot;, do_fix)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local do_nb_space = function()&lt;br /&gt;
  -- Non breaking space. Note that we may have eaten any&lt;br /&gt;
  -- extra following white space, so the char at pos() may not&lt;br /&gt;
  -- be the original space.&lt;br /&gt;
  local cur_pos = pos()&lt;br /&gt;
  replace_text(unicode.utf8.char(0x00A0), cur_pos -2, cur_pos -1)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
register_command(&amp;quot; &amp;quot;, do_nb_space)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--- QUESTION: Why, unlike in Footnote, do we not need to save the&lt;br /&gt;
--- current head and tail? Why do we set them to nil when we return&lt;br /&gt;
--- in do_command_stop?&lt;br /&gt;
&lt;br /&gt;
local do_title = function()&lt;br /&gt;
  local value = read_value()&lt;br /&gt;
  if value == unicode.utf8.byte(&amp;quot;[&amp;quot;) then&lt;br /&gt;
    -- We use the contents of this optional argument to set the&lt;br /&gt;
    -- text of the header.&lt;br /&gt;
    unread_value()&lt;br /&gt;
    local args = read_group(false)&lt;br /&gt;
    -- Set the text of the header.&lt;br /&gt;
    State.header_text = args&lt;br /&gt;
  else&lt;br /&gt;
    -- So that the opening &amp;quot;{&amp;quot; will be seen.&lt;br /&gt;
    unread_value()&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  local old_baselineskip = tex.baselineskip&lt;br /&gt;
  push_tbl(copy_table(top_tbl()))  &lt;br /&gt;
&lt;br /&gt;
  local do_command_start = function()&lt;br /&gt;
                             -- Set the new font and baselineskip&lt;br /&gt;
                             tex.baselineskip   = make_glue_spec(tex.sp(&amp;quot;25pt&amp;quot;))&lt;br /&gt;
                             -- Add a title_tbl in format.lua?&lt;br /&gt;
                             local tbl = top_tbl()&lt;br /&gt;
                             tbl.font      = title_font&lt;br /&gt;
&lt;br /&gt;
                             tbl.parindent = tex.sp(&amp;quot;0pt&amp;quot;)&lt;br /&gt;
                             tbl.leftskip  = filll()&lt;br /&gt;
                             tbl.rightskip = filll()&lt;br /&gt;
                           end&lt;br /&gt;
  State.do_command_start = do_command_start&lt;br /&gt;
  local do_command_stop = function()&lt;br /&gt;
                            -- We have now read the title, so force&lt;br /&gt;
                            -- building a paragraph&lt;br /&gt;
                            local head, tail, _, _ = update_locals()&lt;br /&gt;
                            local par = build_par(head, tail)&lt;br /&gt;
                            process_par(par)&lt;br /&gt;
                            -- Insert the (vertical) space after the title.&lt;br /&gt;
                            local title_sep = make_glue(&amp;quot;userskip&amp;quot;, tex.sp(&amp;quot;0.25in&amp;quot;))&lt;br /&gt;
                            process_par(title_sep)&lt;br /&gt;
                            -- Reset various variables&lt;br /&gt;
                            update_state(nil, nil, false, false)&lt;br /&gt;
                            tex.baselineskip   = old_baselineskip&lt;br /&gt;
                            pop_tbl()&lt;br /&gt;
&lt;br /&gt;
                            -- New chapter started&lt;br /&gt;
                            State.first_paragraph_of_chapter = true&lt;br /&gt;
                            State.first_page_of_chapter      = true&lt;br /&gt;
                            State.notes     = {}&lt;br /&gt;
                            State.max_notes = 0&lt;br /&gt;
                          end&lt;br /&gt;
  push_do_command_stop(do_command_stop)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
register_command(&amp;quot;Title&amp;quot;, do_title)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local do_footnote = function()&lt;br /&gt;
&lt;br /&gt;
  -- See the QUESTION: before do_title.&lt;br /&gt;
  local old_head, old_tail, _, _ = update_locals()&lt;br /&gt;
  local old_baselineskip = tex.baselineskip&lt;br /&gt;
  State.max_notes = State.max_notes + 1&lt;br /&gt;
&lt;br /&gt;
  local do_command_start = function()&lt;br /&gt;
                             -- We want to mark the first preceding glyph&lt;br /&gt;
                             -- node with the Footnote marker.&lt;br /&gt;
                             local to_be_marked = old_tail&lt;br /&gt;
                             -- Search backward&lt;br /&gt;
                             while (node_type(to_be_marked) ~= &amp;quot;glyph&amp;quot;) do&lt;br /&gt;
                               to_be_marked = to_be_marked.prev&lt;br /&gt;
                             end&lt;br /&gt;
                             -- Naked glyphs cannot go into a vlist:&lt;br /&gt;
                             local marker = node.hpack(make_glyph(unicode.utf8.byte(tostring(State.max_notes)),&lt;br /&gt;
                                                       superscript_font,&lt;br /&gt;
                                                       1, 3, 3))&lt;br /&gt;
                             -- Some glue to raise the mark&lt;br /&gt;
                             local marker_glue = make_glue(0, tex.sp(&amp;quot;5pt&amp;quot;))&lt;br /&gt;
                             link_nodes(marker, marker_glue)&lt;br /&gt;
                             -- vpack, so that the glue is on the bottom,&lt;br /&gt;
                             -- not the left.&lt;br /&gt;
                             local packed = node.vpack(marker)&lt;br /&gt;
                             -- Link things back up.&lt;br /&gt;
                             if (to_be_marked == old_tail) then&lt;br /&gt;
                               link_nodes(to_be_marked, packed)&lt;br /&gt;
                               old_tail = packed&lt;br /&gt;
                             else&lt;br /&gt;
                               link_nodes(to_be_marked, packed, to_be_marked.next)&lt;br /&gt;
                             end&lt;br /&gt;
                             -- Add attribute to to_be_marked, so that we can&lt;br /&gt;
                             -- see it while building the page, and get the&lt;br /&gt;
                             -- note.&lt;br /&gt;
                             node.set_attribute(to_be_marked, 444, State.max_notes)&lt;br /&gt;
                             &lt;br /&gt;
                             -- Now, set up the first glyph of the footnote&lt;br /&gt;
                             -- to also receive the footnote mark. Here we need&lt;br /&gt;
                             -- to search forward using the reader.&lt;br /&gt;
                             local pos = pos()&lt;br /&gt;
                             local value = read_value()&lt;br /&gt;
                             -- We make the (possibly false) assumption that&lt;br /&gt;
                             -- the footnote starts with a glyph. There should&lt;br /&gt;
                             -- be some way to identify glyphs. What if the&lt;br /&gt;
                             -- footnote started with an Emph?&lt;br /&gt;
                             replace_text(&amp;quot;\\Mark{&amp;quot; .. unicode.utf8.char(value) .. &amp;quot;}&amp;quot;, pos, pos)&lt;br /&gt;
                             &lt;br /&gt;
                             -- Switch to footnote mode, and call main_loop&lt;br /&gt;
                             -- to typeset the footnote.&lt;br /&gt;
                             State.mode = &amp;quot;footnote&amp;quot;&lt;br /&gt;
                             update_state(nil, nil, false, false)&lt;br /&gt;
                             push_tbl(footnote_tbl)&lt;br /&gt;
                             main.main_loop()&lt;br /&gt;
                           end&lt;br /&gt;
  State.do_command_start = do_command_start&lt;br /&gt;
  local do_command_stop = function()&lt;br /&gt;
                            -- We now build the (final) paragraph of the&lt;br /&gt;
                            -- footnote and process it (put it in&lt;br /&gt;
                            -- State.notes[max_notes]). Note that if the&lt;br /&gt;
                            -- footnote contains multiple paragraphs, the&lt;br /&gt;
                            -- earlier ones have already been processed.&lt;br /&gt;
                            -- Note also that, unlike with Input, where&lt;br /&gt;
                            -- main_loop will terminate on eol, and so&lt;br /&gt;
                            -- build_par, process_par, and build_pages,&lt;br /&gt;
                            -- we have to do some of this now.&lt;br /&gt;
                            local head, tail, _, _ = update_locals()&lt;br /&gt;
                            tex.baselineskip = make_glue_spec(tex.sp(&amp;quot;12pt&amp;quot;))&lt;br /&gt;
                            local par = build_par(head, tail)&lt;br /&gt;
                            process_par(par)&lt;br /&gt;
                            tex.baselineskip = old_baselineskip&lt;br /&gt;
                            -- and restore the previous mode, head, and tail.&lt;br /&gt;
                            pop_tbl()&lt;br /&gt;
                            State.mode = &amp;quot;main_text&amp;quot;&lt;br /&gt;
                            update_state(old_head, old_tail, false, false)&lt;br /&gt;
                          end&lt;br /&gt;
  push_do_command_stop(do_command_stop)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
register_command(&amp;quot;Footnote&amp;quot;, do_footnote)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local do_mark = function()&lt;br /&gt;
&lt;br /&gt;
  -- Even though we do nothing in do_command_start, we&lt;br /&gt;
  -- must define it, so that upon seeing the &amp;quot;{&amp;quot; main_loop&lt;br /&gt;
  -- will know that we are starting a command, and not&lt;br /&gt;
  -- entering a new group.&lt;br /&gt;
  local do_command_start = function()&lt;br /&gt;
                           end&lt;br /&gt;
  State.do_command_start = do_command_start&lt;br /&gt;
  local do_command_stop  = function()&lt;br /&gt;
                             local head, tail, _, _ = update_locals()&lt;br /&gt;
                             -- We should have just read the single chararcter&lt;br /&gt;
                             -- at the start of the footnote. Therefore head&lt;br /&gt;
                             -- and tail should be the same. Check this.&lt;br /&gt;
                             assert((head == tail), &amp;quot;Head and tail are not the same.&amp;quot;)&lt;br /&gt;
                             -- add the mark as in Footnote.&lt;br /&gt;
                             local marker = node.hpack(make_glyph(unicode.utf8.byte(tostring(State.max_notes)),&lt;br /&gt;
                                                         superscript_font,&lt;br /&gt;
                                                         1, 3, 3))&lt;br /&gt;
                             local marker_glue = make_glue(0, tex.sp(&amp;quot;5pt&amp;quot;))&lt;br /&gt;
                             link_nodes(marker, marker_glue)&lt;br /&gt;
                             local packed = node.vpack(marker)&lt;br /&gt;
                             link_nodes(packed, head)&lt;br /&gt;
                             update_state(packed, tail, false, false)&lt;br /&gt;
                           end&lt;br /&gt;
  push_do_command_stop(do_command_stop)&lt;br /&gt;
&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
register_command(&amp;quot;Mark&amp;quot;, do_mark)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local initialize_command = function(command)&lt;br /&gt;
  return command_table[command]()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local commands = {get_command        = get_command,&lt;br /&gt;
                  initialize_command = initialize_command,&lt;br /&gt;
                  }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
return commands&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;/div&gt;</summary>
		<author><name>Rkrug</name></author>
		
	</entry>
</feed>