xtemplate
我在使用\KeyValue
类型的键时遇到了一个问题instance
。实例键类型尚未记录,所以我可能做错了。
这是我能想到的最小的例子:
\documentclass{article}
\usepackage{expl3}
\usepackage{xtemplate}
\ExplSyntaxOn
\DeclareObjectType { format } {1}
\DeclareObjectType { tagged } {2}
\DeclareTemplateInterface { format } { format-text } {1}
{
font : tokenlist = \normalfont ,
}
\DeclareTemplateInterface { tagged } { tagged-text } {2}
{
main : instance { format } = normal ,
tag : instance { format } = \KeyValue { main } ,
}
\tl_new:N \l__mwe_tl
\DeclareTemplateCode { format } { format-text } {1}
{ font = \l__mwe_tl , }
{
\AssignTemplateKeys
{ \l__mwe_tl #1 }
}
\DeclareTemplateCode { tagged } { tagged-text } {2}
{
main = \__mwe_main:n ,
tag = \__mwe_tag:n ,
}
{
\AssignTemplateKeys
\__mwe_tag:n {#1} \__mwe_main:n {#2}
}
\DeclareInstance { format } { normal } { format-text }
{}
\DeclareInstance { tagged } { specific } { tagged-text }
{
main = normal ,
tag = normal ,
}
\DeclareInstance { tagged } { default } { tagged-text }
{
main = normal ,
}
\ExplSyntaxOff
\begin{document}
\UseInstance {tagged} {specific} {Y:~} {This one works.}
\UseInstance {tagged} {default} {N:~} {This one fails.}
\end{document}
(错误报告位于https://github.com/latex3/latex3/issues/131建议再试一次,但也没有用)。
日志文件的相关内容:
This is pdfTeX, Version 3.14159265-2.6-1.40.20 (MiKTeX 2.9.7200 64-bit)
Package: expl3 2019-10-02 L3 programming layer (loader)
Package: xtemplate 2019-05-28 L3 Experimental prototype document functions
! Package xtemplate Error: The instance '\KeyValue {main}' of type 'format' is
(xtemplate) unknown.
For immediate help type H <return>.
...
l.61 ...{tagged} {default} {N:~} {This one fails.}
有谁知道如何提前做出\KeyValue
评估吗?