summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-02-01 21:57:57 +0000
committerKarl Berry <karl@freefriends.org>2015-02-01 21:57:57 +0000
commit6dbca1c4c7c8c6b66c16baccd89f0867cbcfd945 (patch)
tree3fa9f85165d45b7f609f1ae9842df220b6a6d337 /Master
parent87932dd0df7362d66a73e360f64c91a41b95ebd0 (diff)
context-annotation (1feb15)
git-svn-id: svn://tug.org/texlive/trunk@36187 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/context/third/annotation/README35
-rw-r--r--Master/texmf-dist/doc/context/third/annotation/annotation-doc.pdfbin0 -> 50341 bytes
-rw-r--r--Master/texmf-dist/tex/context/interface/third/t-annotation.xml163
-rw-r--r--Master/texmf-dist/tex/context/third/annotation/t-annotation.lua151
-rw-r--r--Master/texmf-dist/tex/context/third/annotation/t-annotation.mkvi1077
-rwxr-xr-xMaster/tlpkg/bin/tlpkg-ctan-check2
-rwxr-xr-xMaster/tlpkg/libexec/ctan2tds1
-rw-r--r--Master/tlpkg/tlpsrc/collection-context.tlpsrc1
-rw-r--r--Master/tlpkg/tlpsrc/context-annotation.tlpsrc3
9 files changed, 1432 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/context/third/annotation/README b/Master/texmf-dist/doc/context/third/annotation/README
new file mode 100644
index 00000000000..74907e98ac6
--- /dev/null
+++ b/Master/texmf-dist/doc/context/third/annotation/README
@@ -0,0 +1,35 @@
+Modulename : t-annotation
+Author : Wolfgang Schuster
+License : GNU General Public License
+
+Description
+-----------
+
+Annotate text blocks.
+
+Usage
+-----
+
+\usemodule[annotation]
+
+\starttext
+... \annotation{...} ...
+
+... \startannotation ...\stopannotation ...
+\stoptext
+
+Options
+-------
+
+- alternative
+- before
+- after
+- inbetween
+- headstyle
+- headcolor
+- command
+- text
+- title
+- number
+- next
+- ... \ No newline at end of file
diff --git a/Master/texmf-dist/doc/context/third/annotation/annotation-doc.pdf b/Master/texmf-dist/doc/context/third/annotation/annotation-doc.pdf
new file mode 100644
index 00000000000..131665ac310
--- /dev/null
+++ b/Master/texmf-dist/doc/context/third/annotation/annotation-doc.pdf
Binary files differ
diff --git a/Master/texmf-dist/tex/context/interface/third/t-annotation.xml b/Master/texmf-dist/tex/context/interface/third/t-annotation.xml
new file mode 100644
index 00000000000..58f3c5e1623
--- /dev/null
+++ b/Master/texmf-dist/tex/context/interface/third/t-annotation.xml
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="en" version="2010.12.31">
+
+<cd:command name="defineannotation" file="t-annotation.mkvi">
+ <cd:sequence>
+ <cd:string value="defineannotation"/>
+ </cd:sequence>
+ <cd:arguments>
+ <cd:keywords n="1">
+ <cd:constant type="cd:name"/>
+ </cd:keywords>
+ <cd:keywords n="2" optional="yes">
+ <cd:constant type="cd:name"/>
+ </cd:keywords>
+ <cd:assignments n="3" list="yes" optional="yes">
+ <cd:inherit name="setupannotation" n="2"/>
+ </cd:assignments>
+ </cd:arguments>
+</cd:command>
+
+<cd:command name="annotation" generated="yes" file="t-annotation.mkvi">
+ <cd:sequence>
+ <cd:variable value="annotation"/>
+ </cd:sequence>
+ <cd:arguments>
+ <cd:assignments n="1" list="yes" optional="yes">
+ <cd:inherit name="setupannotation"/>
+ </cd:assignments>
+ <cd:content n="2" optional="yes"/>
+ <cd:content n="3"/>
+ </cd:arguments>
+</cd:command>
+
+<cd:command name="annotation" generated="yes" type="environment" file="t-annotation.mkvi">
+ <cd:sequence>
+ <cd:variable value="annotation"/>
+ </cd:sequence>
+ <cd:arguments>
+ <cd:assignments n="1" list="yes" optional="yes">
+ <cd:inherit name="setupannotation"/>
+ </cd:assignments>
+ <cd:content n="2" optional="yes"/>
+ </cd:arguments>
+</cd:command>
+
+<cd:command name="setupannotation" file="t-annotation.mkvi">
+ <cd:sequence>
+ <cd:string value="setupannotation"/>
+ </cd:sequence>
+ <cd:arguments>
+ <cd:keywords n="1" list="yes" optional="yes">
+ <cd:constant type="cd:name"/>
+ </cd:keywords>
+ <cd:assignments n="2" list="yes">
+ <cd:parameter name="alternative">
+ <cd:constant type="text"/>
+ <cd:constant type="paragraph" default="yes"/>
+ <cd:constant type="comment"/>
+ <cd:constant type="tooltip"/>
+ <cd:constant type="inmargin"/>
+ <cd:constant type="inleft"/>
+ <cd:constant type="inright"/>
+ <cd:constant type="margin"/>
+ <cd:constant type="leftmargin"/>
+ <cd:constant type="rightmargin"/>
+ <cd:constant type="innermargin"/>
+ <cd:constant type="outermargin"/>
+ <cd:constant type="footnote"/>
+ <cd:constant type="endnote"/>
+ <cd:constant type="command"/>
+ </cd:parameter>
+ <cd:parameter name="before">
+ <cd:constant type="cd:command"/>
+ </cd:parameter>
+ <cd:parameter name="after">
+ <cd:constant type="cd:command"/>
+ </cd:parameter>
+ <cd:parameter name="inbetween">
+ <cd:constant type="cd:command" default="\blank"/>
+ </cd:parameter>
+ <cd:parameter name="style">
+ <cd:resolve name="style"/>
+ </cd:parameter>
+ <cd:parameter name="headstyle">
+ <cd:resolve name="style" default="bold"/>
+ </cd:parameter>
+ <cd:parameter name="textstyle">
+ <cd:resolve name="style"/>
+ </cd:parameter>
+ <cd:parameter name="color">
+ <cd:constant type="cd:name"/>
+ </cd:parameter>
+ <cd:parameter name="headcolor">
+ <cd:constant type="cd:name"/>
+ </cd:parameter>
+ <cd:parameter name="textcolor">
+ <cd:constant type="cd:name"/>
+ </cd:parameter>
+ <cd:parameter name="title">
+ <cd:constant type="yes" default="yes"/>
+ <cd:constant type="no"/>
+ </cd:parameter>
+ <cd:parameter name="number">
+ <cd:constant type="yes"/>
+ <cd:constant type="no" default="yes"/>
+ </cd:parameter>
+ <cd:parameter name="next">
+ <cd:constant type="cd:command" default="\autoinsertnextspace"/>
+ </cd:parameter>
+ <cd:parameter name="command">
+ <cd:constant type="cd:twoarguments"/>
+ </cd:parameter>
+ <cd:parameter name="counter">
+ <cd:constant type="cd:name"/>
+ </cd:parameter>
+ <cd:parameter name="reference">
+ <cd:constant type="cd:name"/>
+ </cd:parameter>
+ <cd:parameter name="export">
+ <cd:constant type="yes"/>
+ <cd:constant type="no" default="yes"/>
+ </cd:parameter>
+ <cd:parameter name="list">
+ <cd:constant type="cd:text"/>
+ </cd:parameter>
+ <cd:parameter name="display">
+ <cd:constant type="yes"/>
+ <cd:constant type="no"/>
+ <cd:constant type="auto" default="yes"/>
+ </cd:parameter>
+ <cd:parameter name="paragraph">
+ <cd:constant type="yes"/>
+ <cd:constant type="no" default="yes"/>
+ </cd:parameter>
+ <cd:parameter name="spacebefore">
+ <cd:inherit name="blank" n="1" default="line"/>
+ </cd:parameter>
+ <cd:parameter name="spaceafter">
+ <cd:inherit name="blank" n="1" default="line"/>
+ </cd:parameter>
+ <cd:parameter name="left">
+ <cd:constant type="cd:text" default="("/>
+ </cd:parameter>
+ <cd:parameter name="right">
+ <cd:constant type="cd:text" default=")"/>
+ </cd:parameter>
+ <cd:parameter name="indentnext">
+ <cd:constant type="yes" default="yes"/>
+ <cd:constant type="no"/>
+ <cd:constant type="auto"/>
+ </cd:parameter>
+ <cd:parameter name="indenting">
+ <cd:inherit name="setupindenting" n="1" default="never"/>
+ </cd:parameter>
+ <cd:parameter name="align">
+ <cd:inherit name="setupalign" n="1"/>
+ </cd:parameter>
+ </cd:assignments>
+ </cd:arguments>
+</cd:command>
+
+</cd:interface> \ No newline at end of file
diff --git a/Master/texmf-dist/tex/context/third/annotation/t-annotation.lua b/Master/texmf-dist/tex/context/third/annotation/t-annotation.lua
new file mode 100644
index 00000000000..0221cc4a772
--- /dev/null
+++ b/Master/texmf-dist/tex/context/third/annotation/t-annotation.lua
@@ -0,0 +1,151 @@
+if not modules then modules = { } end modules ['t-annotation'] = {
+ version = 1.000,
+ comment = "Annotations",
+ author = "Wolfgang Schuster",
+ copyright = "Wolfgang Schuster",
+ license = "GNU General Public License"
+}
+
+thirddata = thirddata or {}
+thirddata.annotation = thirddata.annotation or {}
+
+local annotation = thirddata.annotation
+
+local variables = interfaces.variables
+
+local format = string.format
+local gsub = string.gsub
+local rep = string.rep
+local validstring = string.valid
+
+local datasets = job.datasets
+
+local v_yes = variables.yes
+local v_no = variables.no
+local v_auto = variables.auto
+local v_paragraph = variables.paragraph
+local v_text = variables.text
+local v_command = variables.command
+local v_vertical = variables.vertical
+local v_horizontal = variables.horizontal
+local v_annotation = variables.annotation
+local v_buffer = variables.buffer
+
+local texsprint = tex.sprint
+local ctxcatcodes = tex.ctxcatcodes
+local txtcatcodes = tex.txtcatcodes
+
+-- Collect the content of the environment
+
+local data = { }
+
+function annotation.erasedata(name)
+ data[name] = nil
+end
+
+function annotation.getdata(name)
+ local data = data[name]
+ return data and data.content or ""
+end
+
+function annotation.printdata(environment,name)
+ local content, catcodes
+ if tex.conditionals['c_annotation_buffer'] and name ~= "" then
+ content = datasets.getdata(environment,name,"content") or ""
+ catcodes = datasets.getdata(environment,name,"catcodes") or ""
+ else
+ content = data[name] and data[name]["content"] or ""
+ catcodes = data[name] and data[name]["catcodes"] or ""
+ end
+ if catcodes == txtcatcodes then
+ context.pushcatcodes(txtcatcodes)
+ else
+ context.pushcatcodes(ctxcatcodes)
+ end
+ if tex.conditionals['c_annotation_inline'] then
+ context(content:strip()) -- remove leading/trailing spaces
+ else
+ context.viafile(content,format("annotation.%s",validstring(name,"noname")))
+ end
+ context.popcatcodes()
+end
+
+function annotation.parameters(environment,name)
+ local data = data[name]
+ local parameters = data and data.parameters or ""
+ texsprint(ctxcatcodes,parameters)
+end
+
+function annotation.dataset(environment,name,parameters,content,catcodes)
+ datasets.setdata {
+ name = environment,
+ tag = name,
+ data = {
+ parameters = parameters,
+ content = content,
+ catcodes = catcodes
+ }
+ }
+end
+
+function annotation.collectdata(environment,name,parameters,content,begintag,endtag,catcodes)
+ local oldcontent = annotation.getdata(name)
+ local content = content
+ local parameters = parameters
+ local catcodes = catcodes
+ local nesting = false
+ if oldcontent == "" then
+ -- no nested environment
+ else
+ content = oldcontent .. endtag .. " " .. content
+ end
+ if select(2,gsub(content,begintag,begintag)) > select(2,gsub(content,endtag,endtag)) then
+ nesting = true
+ else
+ nesting = false
+ end
+ if not nesting and name ~= "" then
+ annotation.dataset(environment,name,parameters,content,catcodes)
+ end
+ data[name] = { parameters = parameters, content = content, catcodes = catcodes }
+ commands.doifelse(nesting)
+end
+
+function annotation.savedata(environment,name,parameters,content,catcodes)
+ data[name] = { parameters = parameters, content = content, catcodes = catcodes }
+end
+
+-- Write the content of the environment to a file
+
+annotation.empty = true
+
+function annotation.open()
+ annotation.export = io.open(file.addsuffix(table.concat({tex.jobname,"annotation"},"-"),"txt"),"wb")
+end
+
+function annotation.write(title,content)
+ local title, content = title:strip(), content
+ if annotation.empty == true then
+ annotation.open()
+ annotation.empty = false
+ else
+ annotation.export:write("\n\n")
+ end
+ if title ~= "" then
+ annotation.export:write(title)
+ annotation.export:write("\n",rep("-",#title),"\n\n")
+ content = content:gsub(" \\par ","\n\n")
+ annotation.export:write(content)
+ end
+end
+
+--~ function annotation.write(title,content)
+--~ local title, content = title:strip(), content
+--~ if annotation.empty == true then
+--~ annotation.open()
+--~ annotation.empty = false
+--~ else
+--~ annotation.export:write("\n")
+--~ end
+--~ annotation.export:write(title.." "..content)
+--~ end
diff --git a/Master/texmf-dist/tex/context/third/annotation/t-annotation.mkvi b/Master/texmf-dist/tex/context/third/annotation/t-annotation.mkvi
new file mode 100644
index 00000000000..41ca1531752
--- /dev/null
+++ b/Master/texmf-dist/tex/context/third/annotation/t-annotation.mkvi
@@ -0,0 +1,1077 @@
+%D \module
+%D [ file=t-annotation,
+%D version=2013.05.27,
+%D title=\CONTEXT\ User Module,
+%D subtitle=Annotations,
+%D author=Wolfgang Schuster,
+%D date=\currentdate,
+%D copyright=Wolfgang Schuster,
+%D email=schuster.wolfgang@googlemail.com,
+%D license=GNU General Public License]
+
+%C Copyright (C) 2011 Wolfgang Schuster
+%C
+%C This program is free software: you can redistribute it and/or modify
+%C it under the terms of the GNU General Public License as published by
+%C the Free Software Foundation, either version 3 of the License, or
+%C (at your option) any later version.
+%C
+%C This program is distributed in the hope that it will be useful,
+%C but WITHOUT ANY WARRANTY; without even the implied warranty of
+%C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+%C GNU General Public License for more details.
+%C
+%C You should have received a copy of the GNU General Public License
+%C along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+% begin info
+%
+% title : annotate text blocks
+% comment : create todo commands and environments and inline buffers
+% status : under development, mkiv only
+%
+% end info
+
+%M \usemodule[annotation]
+%M \loadsetups[t-annotation.xml]
+%M
+%M \setupbodyfont[calluna]
+%M
+%M \definedescription[description][alternative=margin]
+%M
+%M \setuptyping[typing][bodyfont=]
+
+%D \subject{\textbackslash defineannotation}
+%D
+%D \showsetup{defineannotation}
+%D
+%D \subject{The \tex{setupannotation} command}
+%D
+%D \showsetup{setupannotation}
+%D
+%D \startdescription {alternative}
+%D With the “alternative” you can control the placement of the anootation block.
+%D
+%D \starttabulate[|l|p|]
+%D \NC \bf Name \NC \bf Description \NC\NR
+%D \NC text \EQ inline \NC\NR
+%D \NC paragraph \EQ Separate paragraph \NC\NR
+%D \NC comment \EQ pdf comment \NC\NR
+%D \NC tooltip \EQ \type{\tooltip} \NC\NR
+%D \NC inmargin \EQ \type{\inmargin} \NC\NR
+%D \NC inleft \EQ \type{\inleft} \NC\NR
+%D \NC inright \EQ \type{\inright} \NC\NR
+%D \NC margin \EQ \type{\inmargin} \NC\NR
+%D \NC leftmargin \EQ \type{\inleft} \NC\NR
+%D \NC rightmargin \EQ \type{\inright} \NC\NR
+%D \NC innermargin \EQ \type{\ininner} \NC\NR
+%D \NC outermargin \EQ \type{\inouter} \NC\NR
+%D \NC footnote \EQ \type{\footnote} \NC\NR
+%D \NC endnote \EQ \type{\endnote} \NC\NR
+%D \NC command \EQ use the “command” key \NC\NR
+%D \stoptabulate
+%D \stopdescription
+%D
+%D \startdescription {title}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {text}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {number}
+%D The “number” key let you control whether to show a number or not. Each time
+%D you show a number the associated counter is incremented by one.
+%D \stopdescription
+%D
+%D \startdescription {list}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {counter}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {reference}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {left}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {right}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {next}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {display}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {paragraph}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {command}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {export}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {before}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {after}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {inbetween}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {spacebefore}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {spaceafter}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {style}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {color}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {headstyle}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {headcolor}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {textstyle}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {textcolor}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {align}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {indenting}
+%D …
+%D \stopdescription
+%D
+%D \startdescription {indentnext}
+%D This key let you control whether the next paragraph after the annotation block
+%D is indented or not. The option is only used for annotation which are set with
+%D the “paragraph” or “command” alternative, for “command” this is only true when
+%D display is set to “yes” or “auto”.
+%D \stopdescription
+%D
+%D \subject{The \textbackslash annotation command}
+%D
+%D \showsetup{annotation}
+%D \showsetup{startannotation}
+%D
+%D \subject{Accesing values}
+%D
+%D As you saw before you can get the content of the title and content blocks
+%D with the “command” alternative but there is another way to access
+%D the raw values of each element with the following for commands.
+%D
+%D \startitemize[packed]
+%D \item \type{\placeannotationtext}
+%D \item \type{\placeannotationtitle}
+%D \item \type{\placeannotationnumber}
+%D \item \type{\placeannotationcontent}
+%D \stopitemize
+%D
+%D The following example shows you how you can use the commands for yourself
+%D in your own defintions for the annotation environment. The \type{\placeannotationtext}
+%D commands holds the value you set with the “title” key while \type{\placeannotationnumber}
+%D let you access the number countervalue.
+%D
+%D \subject{Customized Layouts}
+%D
+%D \subsubject{Example 1}
+%D
+%D \startbuffer
+%D \define[2]\AnnotationCommand
+%D {\starttabulate[|l|p|]
+%D \NC Text \EQ \rawannotationtext \NC\NR
+%D \NC Number \EQ \rawannotationcounter \NC\NR
+%D \NC Title \EQ \rawannotationtitle \NC\NR
+%D \NC Content \EQ \rawannotationcontent \NC\NR
+%D \stoptabulate}
+%D
+%D \setupannotation
+%D [alternative=command,
+%D command=\AnnotationCommand,
+%D text=Annotation ,
+%D number=yes]
+%D
+%D \startannotation {Peter D. Ward}
+%D The Earth, as a habitat for animal life, is in old age and
+%D has a fatal illness. Several, in fact. It would be happening
+%D whether humans had ever evolved or not. But our presence is
+%D like the effect of an old-age patient who smokes many packs
+%D of cigarettes per day – and we humans are the cigarettes.
+%D \stopannotation
+%D \stopbuffer
+%D
+%D \start \typebuffer[option=tex] \getbuffer \stop
+%D
+%D \subsubject{Example 2}
+%D
+%D \startbuffer
+%D \define[2]\AnnotationCommand
+%D {\textrule{#1}#2\textrule}
+%D
+%D \setupannotation
+%D [alternative=command,
+%D command=\AnnotationCommand,
+%D text=Annotation]
+%D
+%D \startannotation
+%D The Earth, as a habitat for animal life, is in old age and
+%D has a fatal illness. Several, in fact. It would be happening
+%D whether humans had ever evolved or not. But our presence is
+%D like the effect of an old-age patient who smokes many packs
+%D of cigarettes per day – and we humans are the cigarettes.
+%D \stopannotation
+%D \stopbuffer
+%D
+%D \start \typebuffer \getbuffer \stop
+%D
+%D \subsubject{Example 3}
+%D
+%D \startbuffer
+%D \define[2]\AnnotationCommand
+%D {\startblockquote
+%D “#2”\wordright{\placeannotationtitle}%
+%D \stopblockquote}
+%D
+%D \setupannotation
+%D [alternative=command,
+%D command=\AnnotationCommand]
+%D
+%D \startannotation {Peter D. Ward}
+%D The Earth, as a habitat for animal life, is in old age and
+%D has a fatal illness. Several, in fact. It would be happening
+%D whether humans had ever evolved or not. But our presence is
+%D like the effect of an old-age patient who smokes many packs
+%D of cigarettes per day – and we humans are the cigarettes.
+%D \stopannotation
+%D \stopbuffer
+%D
+%D \start \typebuffer \getbuffer \stop
+
+\writestatus{loading}{ConTeXt User Module / Annotations}
+
+\unprotect
+
+\startinterface all
+ \setinterfacevariable {annotation} {annotation}
+ \setinterfacevariable {tooltip} {tooltip}
+\stopinterface
+
+\startinterface all
+ \setinterfaceconstant {content} {content}
+ \setinterfaceconstant {leftsymbol} {leftsymbol}
+ \setinterfaceconstant {rightsymbol} {rightsymbol}
+\stopinterface
+
+\newconditional\c_annotation_header
+\newconditional\c_annotation_display
+\newconditional\c_annotation_inline
+\newconditional\c_annotation_number
+\newconditional\c_annotation_title
+\newconditional\c_annotation_paragraph
+\newconditional\c_annotation_buffer
+\newconditional\c_annotation_rightpage
+
+\installnamespace {annotation}
+\installnamespace {annotationalternative}
+\installnamespace {annotationrenderings}
+\installnamespace {annotationmethod}
+\installnamespace {annotationlevel}
+
+\installcommandhandler \????annotation {annotation} \????annotation
+
+\ctxloadluafile{t-annotation}
+
+\appendtoks
+ \expandafter\newcount\csname\????annotationlevel\currentannotation\endcsname
+ \setuevalue {\currentannotation}{\annotation_cmd{\currentannotation}}%
+ \setuevalue{\e!start\currentannotation}{\annotation_beg{\currentannotation}}%
+ \setuevalue{\e!stop \currentannotation}{\annotation_end }%
+ \setuevalue{\e!get \currentannotation}{\annotation_get{\currentannotation}}%
+\to \everydefineannotation
+
+\appendtoks
+ \definedataset[\currentannotation]%
+\to \everydefineannotation
+
+% each new environment creates a list and a counter with the same,
+% one can also use the counter of another environment but in this
+% case it has to be set with the “counter” key
+
+\appendtoks
+ \letannotationparameter\s!counter\currentannotation
+\to \everypresetannotation
+
+\appendtoks
+ \edef\p_annotation_counter{\annotationparameter\s!counter}%
+ \ifx\p_annotation_counter\currentannotation
+ \registerannotationcounter\currentannotation
+ \definelist [\currentannotation]%
+ \definecounter[\currentannotation]%
+ \synchronizeannotationcounters
+ \fi
+\to \everydefineannotation
+
+% the \setupannotation command inherits all keys from \setupstructurecounter,
+% to do this a single line is necessary which takes care of this
+
+\installcounterassociation{annotation}
+
+\appendtoks
+ \synchronizeannotationcounters
+\to \everysetupannotation
+
+% Code for the annotation environment and command
+
+\def\annotation_initialize
+ {\let\m_annotation_name \empty
+ \let\m_annotation_parameters\empty
+ %
+ \setfalse\c_annotation_header
+ \setfalse\c_annotation_display
+ \setfalse\c_annotation_inline
+ \setfalse\c_annotation_number
+ \setfalse\c_annotation_title
+ \setfalse\c_annotation_paragraph
+ \setfalse\c_annotation_buffer
+ \setfalse\c_annotation_rightpage
+ %
+ \let\currentannotationheader \annotation_header_formatted_indeed
+ \let\currentannotationcontent\annotation_content_formatted_indeed
+ \let\currentannotationtext \annotation_text_formatted
+ \let\currentannotationcounter\annotation_counter_formatted
+ \let\currentannotationtitle \annotation_title_formatted
+ %
+ \let\rawannotationheader \annotation_header_raw
+ \let\rawannotationcontent\annotation_content_raw
+ \let\rawannotationtext \annotation_text_raw
+ \let\rawannotationcounter\annotation_counter_raw
+ \let\rawannotationtitle \annotation_title_raw}
+
+\unexpanded\def\annotation_beg#environment%
+ {\begingroup
+ \annotation_initialize
+ \edef\currentannotation{#environment}%
+ \dodoubleempty\annotation_beg_parameters}
+
+\def\annotation_beg_parameters
+ {\iffirstargument
+ \ifsecondargument
+ \doubleexpandafter\annotation_beg_parameters_two
+ \else
+ \doubleexpandafter\annotation_beg_parameters_one
+ \fi
+ \else
+ \expandafter\annotation_beg_parameters_zero
+ \fi}
+
+\def\annotation_beg_parameters_two[#name][#parameters]%
+ {\edef\m_annotation_name {#name}%
+ \edef\m_annotation_parameters{#parameters}%
+ \dosinglegroupempty\annotation_beg_title}
+
+\def\annotation_beg_parameters_one[#name][#parameters]%
+ {\doifassignmentelse{#name}
+ {\edef\m_annotation_parameters{#name}}
+ {\edef\m_annotation_name {#name}}%
+ \dosinglegroupempty\annotation_beg_title}
+
+\def\annotation_beg_parameters_zero[#name][#parameters]%
+ {\dosinglegroupempty\annotation_beg_title}
+
+\def\annotation_beg_title#title%
+ {\ctxlua{thirddata.annotation.erasedata("\m_annotation_name")}%
+ \edef\m_annotation_parameters{\c!reference=,\c!list=,\c!title={#title},\m_annotation_parameters}%
+ \normalexpanded
+ {\annotation_environment
+ \expandafter\noexpand\csname\e!start\currentannotation\endcsname
+ \expandafter\noexpand\csname\e!stop \currentannotation\endcsname}}
+
+\unexpanded\def\annotation_environment#1#2%
+ {\begingroup\obeylines
+ \def\annotation_collect##1#2%
+ {\ctxlua{thirddata.annotation.collectdata("\currentannotation","\m_annotation_name",\!!bs\m_annotation_parameters\!!es,\!!bs\normalunexpanded{##1}\!!es,\!!bs#1\!!es,\!!bs#2\!!es,\number\catcodetable)}
+ \annotation_collect
+ \annotation_method}%
+ \annotation_collect}
+
+\unexpanded\def\annotation_end
+ {}
+
+\unexpanded\def\annotation_cmd#environment%
+ {\begingroup
+ \annotation_initialize
+ \edef\currentannotation{#environment}%
+ \dodoubleempty\annotation_cmd_parameters}
+
+\def\annotation_cmd_parameters
+ {\iffirstargument
+ \ifsecondargument
+ \doubleexpandafter\annotation_cmd_parameters_two
+ \else
+ \doubleexpandafter\annotation_cmd_parameters_one
+ \fi
+ \else
+ \expandafter\annotation_cmd_parameters_zero
+ \fi}
+
+\def\annotation_cmd_parameters_two[#name][#parameters]%
+ {\edef\m_annotation_name {#name}%
+ \edef\m_annotation_parameters{#parameters}%
+ \dodoublegroupempty\annotation_cmd_title}
+
+\def\annotation_cmd_parameters_one[#name][#parameters]%
+ {\doifassignmentelse{#name}
+ {\edef\m_annotation_parameters{#name}}
+ {\edef\m_annotation_name {#name}}%
+ \dodoublegroupempty\annotation_cmd_title}
+
+\def\annotation_cmd_parameters_zero[#name][#parameters]%
+ {\dodoublegroupempty\annotation_cmd_title}
+
+\def\annotation_cmd_title
+ {\ifsecondargument
+ \expandafter\annotation_cmd_content
+ \else
+ \expandafter\annotation_cmd_content\expandafter\empty
+ \fi}
+
+\def\annotation_cmd_content#title#content%
+ {\ctxlua{thirddata.annotation.erasedata("\m_annotation_name")}%
+ \edef\m_annotation_parameters{\c!reference=,\c!list=,\c!title={#title},\m_annotation_parameters}%
+ \begingroup
+ \ctxlua{thirddata.annotation.savedata("\currentannotation","\m_annotation_name","\m_annotation_parameters",\!!bs\normalunexpanded{#content}\!!es,\number\catcodetable)}%
+ \annotation_method}
+
+\unexpanded\def\annotation_get#environment%
+ {\begingroup
+ \annotation_initialize
+ \edef\currentannotation{#environment}%
+ \dodoubleempty\annotation_get_parameters}
+
+\def\annotation_get_parameters
+ {\iffirstargument
+ \iffirstargument
+ \doubleexpandafter\annotation_get_parameters_two
+ \else
+ \doubleexpandafter\annotation_get_parameters_one
+ \fi
+ \else
+ \expandafter\annotation_get_parameters_zero
+ \fi}
+
+\def\annotation_get_parameters_two[#name][#parameters]%
+ {\edef\m_annotation_name {#name}%
+ \edef\m_annotation_parameters{#parameters}%
+ \annotation_get_content}
+
+\def\annotation_get_parameters_one[#name][#parameters]%
+ {\doifassignmentelse{#name}
+ {\edef\m_annotation_parameters{#name}}
+ {\edef\m_annotation_name {#name}}%
+ \annotation_get_content}
+
+\def\annotation_get_parameters_zero[#name][#parameters]%
+ {\annotation_get_content}
+
+\def\annotation_get_content
+ {\letannotationparameter\c!method\s!default
+ \settrue\c_annotation_buffer
+ \edef\m_annotation_parameters{\ctxlua{thirddata.annotation.parameters("\currentannotation","\m_annotation_name")},\m_annotation_parameters}%
+ \begingroup
+ \annotation_method}
+
+\def\annotation_alternative
+ {\edef\currentannotationalternative {\annotationparameter \c!alternative }%
+ \edef\p_annotationalternative_renderingsetup{\annotationalternativeparameter\c!renderingsetup}%
+ \edef\p_annotationalternative_alternative {\annotationalternativeparameter\c!alternative }%
+ \ifx\p_annotationalternative_alternative\v!vertical
+ \settrue\c_annotation_display
+ \else\ifx\p_annotationalternative_alternative\v!horizontal
+ \settrue\c_annotation_inline
+ \else\ifx\p_annotationalternative_alternative\v!auto % used for \setupannotation[alternative=command]
+ \ifx\p_annotation_display\v!yes
+ \settrue\c_annotation_display
+ \else\ifx\p_annotation_display\v!no
+ \settrue\c_annotation_inline
+ \else
+ \ifvmode
+ \settrue\c_annotation_display
+ \else
+ \settrue\c_annotation_inline
+ \fi
+ \fi\fi
+ \else\ifx\p_annotationalternative_alternative\v!none % needed for \setupannotation[alternative=none]
+ \ifhmode
+ \settrue\c_annotation_inline
+ \fi
+ \else
+ % margin, comment etc. annotations
+ \fi\fi\fi\fi
+ \annotation_before
+ \annotation_tagged_start
+ \autosetups\p_annotationalternative_renderingsetup
+ \annotation_tagged_stop
+ \annotation_after}
+
+\def\annotation_before
+ {\ifconditional\c_annotation_display
+ \edef\p_annotation_spacebefore {\annotationparameter\c!spacebefore }%
+ \edef\p_annotation_before {\annotationparameter\c!before }%
+ \edef\p_annotation_spaceafter {\annotationparameter\c!spaceafter }%
+ \edef\p_annotation_after {\annotationparameter\c!after }%
+ \edef\p_annotation_inbetween {\annotationparameter\c!inbetween }%
+ \edef\p_annotation_indenting {\annotationparameter\c!indenting }%
+ \edef\p_annotation_interlinespace{\annotationparameter\c!interlinespace}%
+ \ifx\p_annotation_spacebefore\empty
+ \endgraf
+ \else
+ \blank[\p_annotation_spacebefore]%
+ \fi
+ \ifx\p_annotation_indenting\empty \else
+ \setupindenting[\p_annotation_indenting]%
+ \fi
+ \ifconditional\c_annotation_paragraph
+ \ifx\p_annotation_interlinespace\v!empty
+ \setupinterlinespace
+ \else
+ \setupinterlinespace[\p_annotation_interlinespace]%
+ \fi
+ \fi
+ \p_annotation_before
+ \fi}
+
+\def\annotation_after
+ {\ifconditional\c_annotation_display
+ \p_annotation_after
+ \ifx\p_annotation_spaceafter\empty
+ \endgraf
+ \else
+ \blank[\p_annotation_spaceafter]%
+ \fi
+ \fi}
+
+% methods
+
+\unexpanded\def\installannotationmethod#name#command%
+ {\setvalue{\????annotationmethod#name}{#command}}
+
+\def\annotation_method
+ {\endgroup
+ \expandnamespaceparameter\????annotationmethod\annotationparameter\c!method\s!default}
+
+\def\annotation_method_default
+ {\normalexpanded{\annotation_parameters[\m_annotation_parameters]}%
+ \annotation_alternative
+ \ifconditional\c_annotation_display
+ \checknextindentation[\p_annotation_indentnext]%
+ \glet\annotation_aftergroup\dorechecknextindentation
+ \else
+ \ifconditional\c_annotation_inline
+ \glet\annotation_aftergroup\p_annotation_next
+ \else
+ \glet\annotation_aftergroup\GotoPar
+ \fi
+ \fi
+ \aftergroup\annotation_aftergroup
+ \endgroup}
+
+\def\annotation_method_buffer
+ {\endgroup}
+
+\installannotationmethod \s!default \annotation_method_default
+\installannotationmethod \v!buffer \annotation_method_buffer
+
+% processing
+
+\def\c_annotation_level{\csname\????annotationlevel\currentparentannotation\endcsname}
+
+\def\annotation_level
+ {\let\currentparentannotation\currentannotation
+ \advance\c_annotation_level\plusone
+ \chaintocurrentannotation{\currentparentannotation:\number\c_annotation_level}%
+ \edef\currentannotation{\currentparentannotation:\number\c_annotation_level}}
+
+\unexpanded\def\annotation_parameters[#parameters]%
+ {\annotation_level
+ \setupcurrentannotation[#parameters]%
+ \useannotationstyleandcolor\c!style\c!color
+ \edef\p_annotation_number {\annotationparameter\c!number }%
+ \edef\p_annotation_header {\annotationparameter\c!header }%
+ \edef\p_annotation_title {\annotationparameter\c!title }%
+ \edef\p_annotation_text {\annotationparameter\c!text }%
+ \edef\p_annotation_left {\annotationparameter\c!left }%
+ \edef\p_annotation_right {\annotationparameter\c!right }%
+ \edef\p_annotation_stopper {\annotationparameter\c!stopper }%
+ \edef\p_annotation_reference {\annotationparameter\c!reference }%
+ \edef\p_annotation_list {\annotationparameter\c!list }%
+ \edef\p_annotation_counter {\annotationparameter\s!counter }%
+ \edef\p_annotation_display {\annotationparameter\c!display }%
+ \edef\p_annotation_paragraph {\annotationparameter\c!paragraph }%
+ \edef\p_annotation_export {\annotationparameter\c!export }%
+ \edef\p_annotation_indentnext {\annotationparameter\c!indentnext }%
+ \edef\p_annotation_next {\annotationparameter\c!next }%
+ \edef\p_annotation_doublesided{\annotationparameter\c!doublesided}%
+ \edef\p_annotation_leftmargin {\annotationparameter\c!leftmargin }%
+ \edef\p_annotation_rightmargin{\annotationparameter\c!rightmargin}%
+ \ifx\p_annotation_number\v!yes
+ \settrue\c_annotation_number
+ \incrementcounter[\p_annotation_counter]%
+ \fi
+ \ifx\p_annotation_title\empty \else
+ \settrue\c_annotation_title
+ \fi
+ \ifx\p_annotation_header\v!yes
+ \ifconditional\c_annotation_number
+ \settrue\c_annotation_header
+ \else\ifconditional\c_annotation_title
+ \settrue\c_annotation_header
+ \else\ifx\p_annotation_text\empty
+ % \setfalse\c_annotation_header
+ \else
+ \settrue\c_annotation_header
+ \fi\fi\fi
+ \fi
+ \ifx\p_annotation_reference\empty \else
+ \ifconditional\c_annotation_number
+ \normalexpanded{\reference[\p_annotation_reference]{\directconvertedcounter\p_annotation_counter\empty}}%
+ \else
+ \normalexpanded{\reference[\p_annotation_reference]{{\tttf ??}}}%
+ \fi
+ \fi
+ \ifx\p_annotation_list\empty \else
+ \ifconditional\c_annotation_number
+ \normalexpanded{\writetolist[\currentparentannotation]{\directconvertedcounter\p_annotation_counter\empty}{\p_annotation_list}}%
+ \else
+ \normalexpanded{\writetolist[\currentparentannotation]{}{\p_annotation_list}}%
+ \fi
+ \fi
+ \ifx\p_annotation_paragraph\v!yes
+ \settrue\c_annotation_paragraph
+ \fi
+ \ifx\p_annotation_doublesided\v!yes
+ \signalrightpage
+ \doifrightpageelse\settrue\setfalse\c_annotation_rightpage
+ \else
+ \settrue\c_annotation_rightpage
+ \fi
+ \ifx\p_annotation_export\v!yes
+ \ifconditional\c_annotation_header % do this at the lua with the raw text
+ \begingroup\simplifycommands
+ \ctxlua{thirddata.annotation.write(\!!bs\annotation_header_raw\!!es,\!!bs\normalexpanded{\noexpand\detokenize{\annotation_content_raw}}\!!es)}%
+ \endgroup
+ \fi
+ \fi}
+
+\def\annotation_tagged_start
+ {\ifconditional\c_annotation_inline
+ \dostarttagged\t!construct\currentparentannotation
+ \else
+ \dostarttagged\t!division\currentparentannotation
+ \fi}
+
+\def\annotation_tagged_stop
+ {\dostoptagged}
+
+% The title and the content of the annotation commands is accesed
+% by the following four commands, the formatted version is used
+% by alternatives which allow you to change the style and color.
+%
+% The raw version is used by alternatives where attributes are
+% not possible (comment) or undesired (footnotes).
+
+\unexpanded\def\annotation_header_formatted
+ {\edef\p_annotation_headcommand{\annotationparameter\c!headcommand}%
+ \p_annotation_headcommand\annotation_header_formatted_indeed}
+
+\unexpanded\def\annotation_header_formatted_indeed
+ {\begingroup
+ \useannotationstyleandcolor\c!headstyle\c!headcolor
+ \p_annotation_text
+ \ifconditional\c_annotation_number
+ \ifx\p_annotation_text\empty \else
+ \removeunwantedspaces\space % add space between “text” and “number” when there is text
+ \fi
+ \convertedcounter[\p_annotation_counter]%
+ \fi
+ \ifconditional\c_annotation_title
+ \ifx\p_annotation_text\empty
+ \ifconditional\c_annotation_number \space \fi % add space between “number” and “title” when there is a number
+ \else
+ \space % add space between “text” and “title” when there is a text
+ \fi
+ \p_annotation_left
+ \p_annotation_title
+ \p_annotation_right
+ \fi
+ \p_annotation_stopper
+ \endgroup}
+
+\unexpanded\def\annotation_content_formatted
+ {\edef\p_annotation_textcommand{\annotationparameter\c!textcommand}%
+ \p_annotation_textcommand\annotation_content_formatted_indeed}
+
+\unexpanded\def\annotation_content_formatted_indeed
+ {\begingroup
+ \useannotationstyleandcolor\c!textstyle\c!textcolor
+ \ifconditional\c_annotation_paragraph\setupinterlinespace\fi
+ \ctxlua{thirddata.annotation.printdata("\currentparentannotation","\m_annotation_name")}%
+ \removeunwantedspaces
+ \ifconditional\c_annotation_paragraph\par\fi
+ \endgroup}
+
+\unexpanded\def\annotation_text_formatted
+ {\begingroup
+ \useannotationstyleandcolor\c!headstyle\c!headcolor
+ \annotationparameter\c!text
+ \endgroup}
+
+\unexpanded\def\annotation_counter_formatted
+ {\begingroup
+ \useannotationstyleandcolor\c!headstyle\c!headcolor
+ \convertedcounter[\p_annotation_counter]%
+ \endgroup}
+
+\unexpanded\def\annotation_title_formatted
+ {\begingroup
+ \useannotationstyleandcolor\c!headstyle\c!headcolor
+ \p_annotation_title
+ \endgroup}
+
+\def\annotation_header_raw
+ {\p_annotation_text
+ \ifconditional\c_annotation_number
+ \ifx\p_annotation_text\empty \else
+ \removeunwantedspaces\space
+ \fi
+ \rawcountervalue[\p_annotation_counter]%
+ \fi
+ \ifconditional\c_annotation_title
+ \ifx\p_annotation_text\empty
+ \ifconditional\c_annotation_number \space \fi
+ \else
+ \space
+ \fi
+ \p_annotation_left
+ \p_annotation_title
+ \p_annotation_right
+ \fi
+ \p_annotation_stopper}
+
+\def\annotation_content_raw{\ctxlua{thirddata.annotation.printdata("\currentparentannotation","\m_annotation_name")}}
+\def\annotation_text_raw {\p_annotation_text}
+\def\annotation_counter_raw{\rawcountervalue[\p_annotation_counter]}
+\def\annotation_title_raw {\p_annotation_title}
+
+% With the command alternative one can access the formatted content and title
+% with the two arguments but it’s also possible to use the raw content of
+% each element with the \placeannotation... commands.
+
+\let\placeannotationtext \annotation_text_raw
+\let\placeannotationnumber \annotation_counter_raw
+\let\placeannotationtitle \annotation_title_raw
+\let\placeannotationcontent\annotation_content_raw
+
+% Condtionals for the users to check whether your’re in vertical or
+% horizontal mode, they are usefull when you want a command which
+% works different depenedent on the mode.
+
+\unexpanded\def\doifdisplayannotation
+ {\ifconditional\c_annotation_display
+ \expandafter\firstofoneargument
+ \else
+ \expandafter\gobbleoneargument
+ \fi}
+
+\unexpanded\def\doifelsedisplayannotation
+ {\ifconditional\c_annotation_display
+ \expandafter\firstoftwoarguments
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
+
+\unexpanded\def\doifinlineannotation
+ {\ifconditional\c_annotation_inline
+ \expandafter\firstofoneargument
+ \else
+ \expandafter\gobbleoneargument
+ \fi}
+
+\unexpanded\def\doifelseinlineannotation
+ {\ifconditional\c_annotation_inline
+ \expandafter\firstoftwoarguments
+ \else
+ \expandafter\secondoftwoarguments
+ \fi}
+
+% All layouts for the annotation commands are accessible with the alternative key,
+% the relation between the key values and the internal layout is done with the
+% following command. This command is not meant for user because they should always
+% use the command alternative for their own layouts but the author will add new
+% layouts if they are usefull.
+
+\installcommandhandler \????annotationalternative {annotationalternative} \????annotationalternative
+
+\defineannotationalternative
+ [\v!text]
+ [ \c!alternative=\v!horizontal,
+ \c!renderingsetup=\????annotationrenderings:\v!text]
+
+\startsetups[\????annotationrenderings:\v!text]
+ \ifconditional\c_annotation_header
+ \annotation_header_formatted\space
+ \fi
+ \annotation_content_formatted
+\stopsetups
+
+\defineannotationalternative
+ [\v!paragraph]
+ [ \c!alternative=\v!vertical,
+ \c!renderingsetup=\????annotationrenderings:\v!paragraph]
+
+\startsetups[\????annotationrenderings:\v!paragraph]
+ \ifconditional\c_annotation_header
+ \noindent\annotation_header_formatted
+ \p_annotation_inbetween
+ \fi
+ \annotation_content_formatted
+\stopsetups
+
+\defineannotationalternative
+ [\v!narrow]
+ [ \c!alternative=\v!vertical,
+ \c!renderingsetup=\????annotationrenderings:\v!narrow]
+
+\startsetups[\????annotationrenderings:\v!narrow]
+ \ifconditional\c_annotation_rightpage
+ \doadaptleftskip \p_annotation_leftmargin
+ \doadaptrightskip\p_annotation_rightmargin
+ \else
+ \doadaptleftskip \p_annotation_rightmargin
+ \doadaptrightskip\p_annotation_leftmargin
+ \fi
+ \annotation_content_formatted
+\stopsetups
+
+\defineannotationalternative
+ [\v!comment]
+ [\c!renderingsetup=\????annotationrenderings:\v!comment]
+
+\startsetups[\????annotationrenderings:\v!comment]
+ \begingroup\simplifycommands
+ \doifsomething{\annotationparameter\c!color}{\setupcomment[\c!color=\annotationparameter\c!color]}
+ \removeunwantedspaces
+ \ifconditional\c_annotation_header
+ \inmargin[\c!stack=\v!yes]{\normalexpanded{\comment[\annotation_header_raw]{\annotation_content_raw}}}
+ \else
+ \inmargin[\c!stack=\v!yes]{\normalexpanded{\comment{\annotation_content_raw}}}
+ \fi
+ \endgroup
+\stopsetups
+
+\defineannotationalternative
+ [\v!tooltip]
+ [\c!renderingsetup=\????annotationrenderings:\v!tooltip]
+
+\startsetups[\????annotationrenderings:\v!tooltip]
+ \ifconditional\c_annotation_title\else\removeunwantedspaces\fi
+ \tooltip[\annotationparameter\c!location]{\annotation_title_raw}{\annotation_content_raw}
+\stopsetups
+
+\defineannotationalternative
+ [\v!inmargin]
+ [\c!command=\inmargin,
+ \c!renderingsetup=\????annotationrenderings:\v!margin]
+
+\defineannotationalternative
+ [\v!margin]
+ [\c!command=\inmargin,
+ \c!renderingsetup=\????annotationrenderings:\v!margin]
+
+\defineannotationalternative
+ [\v!inleft]
+ [\c!command=\inleft,
+ \c!renderingsetup=\????annotationrenderings:\v!margin]
+
+\defineannotationalternative
+ [\v!leftmargin]
+ [\c!command=\inleft,
+ \c!renderingsetup=\????annotationrenderings:\v!margin]
+
+\defineannotationalternative
+ [\v!inright]
+ [\c!command=\inright,
+ \c!renderingsetup=\????annotationrenderings:\v!margin]
+
+\defineannotationalternative
+ [\v!rightmargin]
+ [\c!command=\inright,
+ \c!renderingsetup=\????annotationrenderings:\v!margin]
+
+\defineannotationalternative
+ [\v!innermargin]
+ [\c!command=\ininner,
+ \c!renderingsetup=\????annotationrenderings:\v!margin]
+
+\defineannotationalternative
+ [\v!outermargin]
+ [\c!command=\inouter,
+ \c!renderingsetup=\????annotationrenderings:\v!margin]
+
+\startsetups[\????annotationrenderings:\v!margin]
+ \edef\p_annotation_command{\annotationalternativeparameter\c!command}%
+ \ifx\p_annotation_command\empty \else
+ \p_annotation_command{\annotationparameter\c!before
+ \ifconditional\c_annotation_header
+ \annotation_header_formatted
+ \fi
+ \annotationparameter\c!inbetween
+ \annotation_content_formatted
+ \annotationparameter\c!after}
+ \fi
+\stopsetups
+
+\defineannotationalternative
+ [\v!footnote]
+ [ \c!alternative=\v!horizontal,
+ \c!renderingsetup=\????annotationrenderings:\v!footnote]
+
+\startsetups[\????annotationrenderings:\v!footnote]
+ \normalexpanded{\footnote{\annotation_content_raw}}
+\stopsetups
+
+\defineannotationalternative
+ [\v!endnote]
+ [ \c!alternative=\v!horizontal,
+ \c!renderingsetup=\????annotationrenderings:\v!endnote]
+
+\startsetups[\????annotationrenderings:\v!endnote]
+ \normalexpanded{\endnote{\annotation_content_raw}}
+\stopsetups
+
+\defineannotationalternative
+ [\v!command]
+ [ \c!alternative=\v!auto,
+ \c!renderingsetup=\????annotationrenderings:\v!command]
+
+\startsetups[\????annotationrenderings:\v!command]
+ \edef\p_annotation_command{\annotationparameter\c!command}%
+ \ifx\p_annotation_command\empty \else
+ \p_annotation_command\annotation_header_formatted\annotation_content_formatted
+ \fi
+\stopsetups
+
+\defineannotationalternative
+ [\v!quotation]
+ [ \c!alternative=\v!horizontal,
+ \c!renderingsetup=\????annotationrenderings:\v!quotation]
+
+\startsetups[\????annotationrenderings:\v!quotation]
+ \annotationparameter\c!leftsymbol
+ \annotation_content_raw\removeunwantedspaces
+ \annotationparameter\c!rightsymbol
+\stopsetups
+
+\defineannotationalternative
+ [\v!none]
+ [\c!renderingsetup=\????annotationrenderings:\v!none]
+
+\startsetups[\????annotationrenderings:\v!none]
+ \removeunwantedspaces
+\stopsetups
+
+% The module provides the option to write the content of each command to a external
+% file. The values for the option are defined with \defineannotationexport and can
+% be changed with \setupannotationexport.
+
+% \definenamespace
+% [annotationexport]
+% [ type=module,
+% comment=Annotationexport,
+% version=2011.02.17,
+% name=annotationexport,
+% style=no,
+% command=yes,
+% setup=yes,
+% \s!parent=annotationexport]
+%
+% \appendtoks
+% \ctxlua{thirddata.annotation.export_define{...}}%
+% \to \everydefineannotationexport
+%
+% \appendtoks
+% \ctxlua{thirddata.annotation.export_setup{...}}%
+% \to \everysetupannotationexport
+%
+% \defineannotationexport[\v!yes][\c!type=\v!default]
+% \defineannotationexport[\v!org][\c!type=\v!org]
+
+% To make the module usefull even if there is no annotation command in a document
+% i predefine here the command \annotation. As the command is created with
+% \defineannotation you can make specific setups for this command with
+% \setupannotation[annotation][...] which won’t affect all other commands.
+
+\defineannotation[\v!annotation]
+
+% Finally i set default values for all commands, you can change them in
+% your document but all or individual annotation commands.
+
+\setupannotation
+ [ \c!headstyle=\v!bold,
+ \c!left=(,
+ \c!right=),
+ \c!spacebefore=\v!line,
+ \c!spaceafter=\annotationparameter\c!spacebefore,
+ \c!inbetween=\blank,
+ \c!alternative=\v!paragraph,
+ \c!paragraph=\v!no,
+ \c!number=\v!no,
+ \c!header=\v!yes,
+ \c!export=\v!no,
+ \c!indenting=\v!never,
+ \c!indentnext=\v!yes,
+ \c!next=\autoinsertnextspace]
+
+\setupannotationalternative
+ [\c!alternative=\v!none]
+
+% \setupannotationexport
+% [ \c!mode=\v!default,
+% \c!name=\v!annotation,
+% \c!extension=\s!txt]
+
+\protect \endinput
diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check
index d69e512d146..0ecfd5a7e8c 100755
--- a/Master/tlpkg/bin/tlpkg-ctan-check
+++ b/Master/tlpkg/bin/tlpkg-ctan-check
@@ -136,7 +136,7 @@ my @TLP_working = qw(
compactbib
complexity components-of-TeX comprehensive computational-complexity
concepts concmath concmath-fonts concprog concrete confproc constants conteq
- context-account context-algorithmic context-animation
+ context-account context-algorithmic context-animation context-annotation
context-bnf context-chromato
context-construction-plan context-cyrillicnumbers
context-degrade context-filter context-fixme
diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds
index 24b17fc15cc..d83c09fa899 100755
--- a/Master/tlpkg/libexec/ctan2tds
+++ b/Master/tlpkg/libexec/ctan2tds
@@ -258,6 +258,7 @@ chomp ($Build = `cd $Master/../Build/source && pwd`);
'context-algorithmic', "&MAKEcopy",
'context-account', "&MAKEcopy",
'context-animation', "&MAKEcopy",
+ 'context-annotation', "&MAKEcopy",
'context-bnf', "&MAKEcopy",
'context-chromato', "&MAKEcopy",
'context-cyrillicnumbers', "&MAKEcopy",
diff --git a/Master/tlpkg/tlpsrc/collection-context.tlpsrc b/Master/tlpkg/tlpsrc/collection-context.tlpsrc
index 993d6ccbb96..31fec21c283 100644
--- a/Master/tlpkg/tlpsrc/collection-context.tlpsrc
+++ b/Master/tlpkg/tlpsrc/collection-context.tlpsrc
@@ -10,6 +10,7 @@ depend jmn
depend context-account
depend context-algorithmic
depend context-animation
+depend context-annotation
depend context-bnf
depend context-chromato
depend context-construction-plan
diff --git a/Master/tlpkg/tlpsrc/context-annotation.tlpsrc b/Master/tlpkg/tlpsrc/context-annotation.tlpsrc
new file mode 100644
index 00000000000..92d22763ef6
--- /dev/null
+++ b/Master/tlpkg/tlpsrc/context-annotation.tlpsrc
@@ -0,0 +1,3 @@
+category ConTeXt
+runpattern +f texmf-dist/tex/context/interface/third/t-annotation.xml
+depend context