Difference between revisions of "Command/setregisterentry"
< Command
Jump to navigation
Jump to search
(Summary of the command) |
m (Link to \index command) |
||
(12 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<cd:commandgroup name="setregisterentry" xmlns:cd="http://wiki.contextgarden.net/commanddoc/20200807"> | <cd:commandgroup name="setregisterentry" xmlns:cd="http://wiki.contextgarden.net/commanddoc/20200807"> | ||
<cd:shortdesc><!-- a short command summary goes here --> | <cd:shortdesc><!-- a short command summary goes here --> | ||
− | The command <tt>\setregisterentry</tt> | + | The command <tt>\setregisterentry</tt> writes entry to the register. |
</cd:shortdesc> | </cd:shortdesc> | ||
<cd:variants> | <cd:variants> | ||
Line 66: | Line 66: | ||
</cd:variants> | </cd:variants> | ||
<cd:description><!-- the long description of the command goes here --> | <cd:description><!-- the long description of the command goes here --> | ||
+ | <tt>\setregisterentry</tt> is more structured form of the regular {{cmd|index}} command. With its more complex and robust structure it is suitable for automatic workflows. | ||
+ | |||
+ | When processing the command on Lua end, one has to take care of colons in the <tt>key:1</tt> and <tt>entry:1</tt> parameters by enclosing them inside <tt>["..."]</tt>, which is more robust form of putting key in Lua table, see example bellow. | ||
</cd:description> | </cd:description> | ||
− | <cd:examples></cd:examples> | + | <cd:examples><cd:example title="Three levels, changes in the sorting, comma in the entry"><texcode> |
+ | \setupregister[index][balance=no] | ||
+ | |||
+ | \starttext | ||
+ | |||
+ | \chapter{Alfred Hitchcock} | ||
+ | |||
+ | The Skin Game (1931) \setregisterentry[index] | ||
+ | [keys:1=Hitchcock Alfred, | ||
+ | entries:1={Hitchcock, Alfred}, | ||
+ | keys:2=1931, | ||
+ | entries:2=1931, | ||
+ | keys:3=Skin Game, | ||
+ | entries:3={Skin Game, The}] | ||
+ | |||
+ | Mary (1931) \setregisterentry[index] | ||
+ | [keys:1=Hitchcock Alfred, | ||
+ | entries:1={Hitchcock, Alfred}, | ||
+ | keys:2=1931, | ||
+ | entries:2=1931, | ||
+ | keys:3=Mary, | ||
+ | entries:3=Mary] | ||
+ | |||
+ | Rich and Strange (1931) \setregisterentry[index] | ||
+ | [keys:1=Hitchcock Alfred, | ||
+ | entries:1={Hitchcock, Alfred}, | ||
+ | keys:2=1931, | ||
+ | entries:2=1931, | ||
+ | keys:3=Rich and Strange, | ||
+ | entries:3=Rich and Strange] | ||
+ | |||
+ | Number Seventeen (1932) \setregisterentry[index] | ||
+ | [keys:1=Hitchcock Alfred, | ||
+ | entries:1={Hitchcock, Alfred}, | ||
+ | keys:2=1932, | ||
+ | entries:2=1932, | ||
+ | keys:3=Number Seventeen, | ||
+ | entries:3=Number Seventeen] | ||
+ | |||
+ | |||
+ | \blank | ||
+ | |||
+ | \placeregister[index] % without title | ||
+ | |||
+ | \stoptext | ||
+ | </texcode> | ||
+ | </cd:example><cd:example title="Processing on Lua end"><texcode> | ||
+ | \startluacode | ||
+ | context.setregisterentry({ "index" }, | ||
+ | { ["keys:1"]="sorting key", ["entries:1"]="displayed entry"}) | ||
+ | \stopluacode | ||
+ | </texcode></cd:example></cd:examples> | ||
<cd:notes></cd:notes> | <cd:notes></cd:notes> | ||
<cd:seealso> | <cd:seealso> | ||
<cd:source file="strc-reg.mkiv" originator="system"></cd:source> | <cd:source file="strc-reg.mkiv" originator="system"></cd:source> | ||
− | <cd:wikipage originator="system" page="Category:Structure"></cd:wikipage></cd:seealso> | + | <cd:wikipage originator="system" page="Category:Structure"></cd:wikipage> |
+ | <cd:wikipage page="Registers"></cd:wikipage></cd:seealso> | ||
</cd:commandgroup> | </cd:commandgroup> |
Latest revision as of 10:05, 13 October 2020
Contents
\setregisterentry
Summary
The command \setregisterentry writes entry to the register.
Settings
\setregisterentry[...][...=...,...][...=...,...] | |
[...] | name |
label | name |
keys | text processor->text |
entries | text processor->text |
keys:1 | text |
keys:2 | text |
keys:3 | text |
entries:1 | text |
entries:2 | text |
entries:3 | text |
alternative | text |
key | value |
Description
\setregisterentry is more structured form of the regular \index command. With its more complex and robust structure it is suitable for automatic workflows.
When processing the command on Lua end, one has to take care of colons in the key:1 and entry:1 parameters by enclosing them inside ["..."], which is more robust form of putting key in Lua table, see example bellow.
Examples
Three levels, changes in the sorting, comma in the entry
\setupregister[index][balance=no] \starttext \chapter{Alfred Hitchcock} The Skin Game (1931) \setregisterentry[index] [keys:1=Hitchcock Alfred, entries:1={Hitchcock, Alfred}, keys:2=1931, entries:2=1931, keys:3=Skin Game, entries:3={Skin Game, The}] Mary (1931) \setregisterentry[index] [keys:1=Hitchcock Alfred, entries:1={Hitchcock, Alfred}, keys:2=1931, entries:2=1931, keys:3=Mary, entries:3=Mary] Rich and Strange (1931) \setregisterentry[index] [keys:1=Hitchcock Alfred, entries:1={Hitchcock, Alfred}, keys:2=1931, entries:2=1931, keys:3=Rich and Strange, entries:3=Rich and Strange] Number Seventeen (1932) \setregisterentry[index] [keys:1=Hitchcock Alfred, entries:1={Hitchcock, Alfred}, keys:2=1932, entries:2=1932, keys:3=Number Seventeen, entries:3=Number Seventeen] \blank \placeregister[index] % without title \stoptext
Processing on Lua end
\startluacode context.setregisterentry({ "index" }, { ["keys:1"]="sorting key", ["entries:1"]="displayed entry"}) \stopluacode