texlive[61503] Master: dbshow (6jan22)

commits+karl at tug.org commits+karl at tug.org
Thu Jan 6 01:21:45 CET 2022


Revision: 61503
          http://tug.org/svn/texlive?view=revision&revision=61503
Author:   karl
Date:     2022-01-06 01:21:44 +0100 (Thu, 06 Jan 2022)
Log Message:
-----------
dbshow (6jan22)

Modified Paths:
--------------
    trunk/Master/tlpkg/bin/tlpkg-ctan-check
    trunk/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/dbshow/
    trunk/Master/texmf-dist/doc/latex/dbshow/README.md
    trunk/Master/texmf-dist/doc/latex/dbshow/dbshow-doc.pdf
    trunk/Master/texmf-dist/doc/latex/dbshow/dbshow-doc.tex
    trunk/Master/texmf-dist/tex/latex/dbshow/
    trunk/Master/texmf-dist/tex/latex/dbshow/dbshow.sty
    trunk/Master/tlpkg/tlpsrc/dbshow.tlpsrc

Added: trunk/Master/texmf-dist/doc/latex/dbshow/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/dbshow/README.md	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/dbshow/README.md	2022-01-06 00:21:44 UTC (rev 61503)
@@ -0,0 +1,32 @@
+
+# Package dbshow
+
+## Overview
+
+The package provides four core functions:
+
+1. data storage and display
+2. data filtering
+3. data sorting
+4. data display
+
+All data is saved once and then you can display these data with custom filters, orders and styles. The package can be used, for example, to record and display something you'd like to review, maybe the question you always answered incorrectly or some forgettable knowledge. But obviously, the package is much more powerful and extensible for more interesting tasks depending on the individual.
+
+## LICENSE
+
+ dbshow.sty
+ Copyright 2022 Li Changkai <lichangkai225 at qq.com>
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License, either version 1.3
+of this license or (at your option) any later version.
+The latest version of this license is in
+  http://www.latex-project.org/lppl.txt
+and version 1.3 or later is part of all distributions of LaTeX
+version 2005/12/01 or later.
+
+This work has the LPPL maintenance status 'maintained'.
+
+The Current Maintainer of this work is Li Changkai.
+
+This work consists of the files dbshow.sty, dbshow-doc.tex.


Property changes on: trunk/Master/texmf-dist/doc/latex/dbshow/README.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/dbshow/dbshow-doc.pdf
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/latex/dbshow/dbshow-doc.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/latex/dbshow/dbshow-doc.pdf	2022-01-06 00:21:08 UTC (rev 61502)
+++ trunk/Master/texmf-dist/doc/latex/dbshow/dbshow-doc.pdf	2022-01-06 00:21:44 UTC (rev 61503)

Property changes on: trunk/Master/texmf-dist/doc/latex/dbshow/dbshow-doc.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/dbshow/dbshow-doc.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/dbshow/dbshow-doc.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/dbshow/dbshow-doc.tex	2022-01-06 00:21:44 UTC (rev 61503)
@@ -0,0 +1,1059 @@
+\documentclass[full]{l3doc}
+\usepackage[scheme=plain]{ctex}
+\usepackage{zhlineskip}
+\usepackage{enumitem}
+\usepackage{indentfirst}
+\usepackage{titling}
+\usepackage{geometry}
+\usepackage{tabularray}
+\usepackage{xcolor}
+
+\IndexPrologue
+  {
+    \section*{Index}
+    \markboth{Index}{Index}
+    \addcontentsline{toc}{section}{Index}
+    The~italic~numbers~denote~the~pages~where~the~
+    corresponding~entry~is~described,~
+    numbers~underlined~point~to~the~definition,~
+    all~others~indicate~the~places~where~it~is~used.
+  }
+
+\newcommand\tikzmark[1]{\tikz \coordinate[overlay, remember picture] (#1);}
+
+\geometry{
+  left=4.5cm,
+  right=2cm,
+  top=2cm,
+  bottom=2cm,
+}
+\hypersetup {
+  CJKbookmarks,
+  bookmarksopen,
+  bookmarksopenlevel=3,
+  pdfstartview=FitH,
+  pdfinfo = {
+   Title = The package 'dbshow' ,
+   Subject = A LaTeX package ,
+   Author = Li Changkai
+ }
+}
+
+\DoNotIndex{\begin, \end}
+\setlength{\parskip}{\medskipamount}
+\DeclareDocumentEnvironment { note } { +b } {
+  \par\textbf{\textsf{NOTE:~}}#1\par
+} {}
+
+\AtEndDocument{
+  \newgeometry{
+    left=2cm,
+    right=2cm,
+    top=2cm,
+    bottom=2cm
+  }
+  \PrintIndex
+}
+
+\ExplSyntaxOn
+\dim_new:N \l__my_syntax_dim
+\box_new:N \g__my_syntax_box
+\NewDocumentEnvironment { Syntax } { s }
+  {
+    \dim_set:Nn \l__my_syntax_dim
+      { \textwidth }
+    \hbox_gset:Nw \g__my_syntax_box
+      \small \ttfamily
+      \begin{minipage}[t]{\l__my_syntax_dim}
+        \raggedright\obeyspaces\obeylines
+  }
+  {
+      \end{minipage}
+    \hbox_gset_end:
+    \IfValueF { #1 } { \smallskip }
+    \box_use_drop:N \g__my_syntax_box
+    \smallskip
+  }
+
+\DeclareDocumentEnvironment { Description } { o +b } {
+  \hbox_set:Nn \l_tmpa_box { #1 }
+  \dim_set:Nn \l_tmpa_dim { \box_wd:N \l_tmpa_box }
+  \begin{itemize}[labelwidth=\l_tmpa_dim, align=left]
+    #2
+  \end{itemize}
+} {  }
+
+\keys_define:nn { dbshow/doc } {
+  opt .tl_set:N = \l_opt_tl,
+  desc .tl_set:N = \l_desc_tl,
+  init .tl_set:N = \l_init_tl,
+  init .initial:n = init-none,
+}
+
+\box_new:N \l__option_box
+\NewDocumentEnvironment { option } { m +b } {
+  \keys_set:nn { dbshow/doc } { #1 }
+  \hbox_set:Nw \l__option_box
+    \small \ttfamily
+    \begin{minipage}[t]{\textwidth}
+      \obeyspaces\obeylines
+      \textcolor{red}{
+        \l_opt_tl
+        \exp_args:Nx\SpecialOptionIndex{\l_opt_tl}
+      }
+      {~}\l_desc_tl
+      \hfill(
+      \tl_if_eq:NnTF \l_init_tl { init-none } { no~value }
+        { initially~\texttt{\l_init_tl} }
+      )
+    \end{minipage}
+  \hbox_gset_end:
+  \box_use_drop:N \l__option_box
+  #2
+  \medskip
+} {  }
+
+\DeclareDocumentCommand \opt { O{} m }
+  { \__codedoc_cmd:no {#1} { #2 } }
+\ExplSyntaxOff
+
+
+\begin{document}
+\title{
+  \pkg{dbshow} 宏包
+  \protect\footnote{\url{https://github.com/ZhiyuanLck/dbshow}}
+  \rlap{\makebox[4cm][r]{
+    \normalsize $\Longrightarrow$ \color{red}
+    \protect\hyperlink{en}{English Version}
+    \protect\hypertarget{zh}{}
+  }}
+}
+\author{\textit{李昌锴} \texttt{<lichangkai225\@qq.com>}}
+\date{2022年1月3日}
+\maketitle
+
+{\small
+\tableofcontents
+}
+\newpage
+
+\begin{documentation}
+
+\section{引言}
+编写本宏包的动机来源于当前没有一个很好的错题本宏包,可以方便的根据各种条件对错
+题进行筛选、排序,然后以自定义的样式展示出来。\pkg{dbshow} 宏包实现了四个核心
+功能:数据存储和使用、数据筛选、数据排序、数据展示。
+
+数据只需要存储一次,就可以通过预定义的筛选、排序条件和样式展示部分或全部的数据。
+如上所述,本宏包其实实现了一个非常简单的数据库,复习错题的功能只是其中一个应用,
+和其他数据库宏包比如 \pkg{datatool} 相比,\pkg{dbshow} 更专注于非图表类型的数
+据展示。
+
+宏包基于 \pkg{expl3} 的基础类型构建了6种类型:
+\begin{Description}[\texttt{clist}]
+  \item[\texttt{date}]
+    基于宏包 \pkg{datetime2} 的日期类型,以iso标准存储,支持大小比较,排序(转
+    换成字符串)。默认值为 \cs{Today}。
+  \item[\texttt{str}]
+    字符串类型,支持正则匹配,英文排序。默认值为空。
+  \item[\texttt{tl}]
+    \meta{token list}类型,支持正则匹配。默认值为空。
+  \item[\texttt{int}]
+    整数类型,支持大小比较,排序。默认值为0。
+  \item[\texttt{fp}]
+    浮点数类型,支持大小比较,排序。默认值为0。
+  \item[\texttt{clist}]
+    逗号分隔的列表类型。默认值为空列表。
+\end{Description}
+
+\section{接口文档}
+\subsection{\cs{dbNewDatabase}}
+\begin{function}{\dbNewDatabase, \dbNewDatabase*}
+  \begin{syntax}
+    \cs{dbNewDatabase} \oarg{base database} \marg{database} \{ \\
+    ~~\meta{attr1} = \meta{type spec1}, \\
+    ~~\meta{attr2} = \meta{type spec2}, \\
+    ~~\ldots{} \\
+    \} \\
+    \cs{dbNewDatabase}* \marg{database} \{ \\
+    ~~\meta{attr1} = \meta{type spec1}, \\
+    ~~\meta{attr2} = \meta{type spec2}, \\
+    ~~\ldots{} \\
+    \} \\
+  \end{syntax}
+
+\end{function}
+
+  新建一个数据库,不带星号的版本可以指定一个数据库来继承其属性设置,该版本总是
+  会舍弃掉之前的定义。
+
+  带星号的版本不会舍弃之前已有的定义,而是将新的选项添加到后面。
+
+  \meta{attr} 为属性名称,\meta{type spec} 负责声明属性类型和属性默认值:
+
+  \noindent\begin{tblr}{
+    colspec = {ll},
+    column{1} = {font = \ttfamily}
+  }
+    \meta{attr} = \meta{type} &
+    将 \meta{attr} 声明为 \meta{type} 类型 \\
+    \meta{attr} = \meta{type}\textbar\meta{default} &
+    将 \meta{attr} 声明为 \meta{type} 类型,并且将默认值设置为 \meta{default}。
+    \\
+  \end{tblr}
+
+  \begin{note}
+    每个数据库都有一个默认的属性 |id| 用来存储数据的索引。
+  \end{note}
+
+  下面是定义一个错题数据库的示例,|question| 和 |answer| 属性用来存储问题和答
+  案,|date| 属性存储日期,|info| 属性存储额外信息,|labels| 存储题目标签。
+\begin{verbatim}
+  \dbNewDatabase{ques}{
+    question = tl,
+    answer = tl,
+    date = date,
+    info = tl,
+    labels = clist
+  }
+\end{verbatim}
+
+\subsection{\cs{dbNewStyle} 和样式选项}
+
+\begin{function}{\dbNewStyle}
+  \begin{syntax}
+    \cs{dbNewStyle} \oarg{base styles} \marg{style} \marg{database} \marg{opts}
+  \end{syntax}
+
+  为 \meta{database} 定义一个新的样式 \meta{style},该样式可以基于已有的样式
+  \meta{base styles},比如 |\dbNewStyle[base1, base2]{new-style}{ques}{}|。
+\end{function}
+
+\bigskip
+
+\begin{option}{opt=filter, desc={= \meta{filter}}, init=-none-}
+  为当前样式设置由 \cs{dbCombineFilters} 所定义的过滤器
+\end{option}
+
+\begin{option}{
+  opt = sort,
+  desc = {= \{ \meta{attr spec1}, \meta{attr spec2}, \ldots{} \}},
+}
+  为当前样式设置排序规则。支持根据 |str|,|date|,|int|,|fp| 类型的数据进行排
+  序,支持多级排序。\meta{attr} 表示增序,\meta{attr}* 表示降序。下面例子中,
+  使用 |sort-style| 展示数据时的顺序为先按 |level| 降序,|level| 相同的再按出
+  生日期 |birth| 增序,以此类推。
+\end{option}
+
+\begin{verbatim}
+  \dbNewDatabase{sort-example}{
+    name = str,
+    birth = date,
+    level = int,
+    weight = fp,
+  }
+  \dbNewStyle{sort-style}{sort-example}{
+    sort = { level*, birth, name, weight }
+  }
+\end{verbatim}
+
+\begin{option}{
+  opt = before-code,
+  desc = {= \meta{before code}}
+}
+  该选项用来设置在展示整个数据库之前需要执行的代码。
+\end{option}
+
+\begin{option}{
+  opt = after-code,
+  desc = {= \meta{after code}}
+}
+  该选项用来设置在展示整个数据库之后需要执行的代码。
+\end{option}
+
+\begin{option}{
+  opt = item-code,
+  desc = {= \meta{item code}}
+}
+  该选项用来设置展示数据库中每条记录的代码。你可以使用 \cs{dbuse} 来展示属性的
+  值。
+\end{option}
+
+\begin{option}{
+  opt = {\meta{attr}/before-code},
+  desc = {= \meta{before code}}
+}
+  该选项用来设置展示数据库中属性 \meta{attr} 对应数据之前需要执行的代码。
+  \cs{dbuse} 会在展示属性数据前执行此代码。
+\end{option}
+
+\begin{option}{
+  opt = {\meta{attr}/after-code},
+  desc = {= \meta{after code}}
+}
+  该选项用来设置展示数据库中属性 \meta{attr} 对应数据之后需要执行的代码。
+  \cs{dbuse} 会在展示属性数据后执行此代码。
+\end{option}
+
+\begin{option}{
+  opt = {\meta{attr}/sep},
+  desc = {= \meta{sep spec}},
+  init = {,~\~}
+}
+\begin{Syntax}
+  \meta{attr}/sep = \meta{separator} \\
+  \meta{attr}/sep = \{ \\
+  ~~\meta{separator between two}, \\
+  ~~\meta{separator between more than two}, \\
+  ~~\meta{separator between final two} \\
+  \}
+\end{Syntax}
+
+  该选项只适用于类型为 |clist| 的属性,用来设置列表间元素的间隔。第一个版本接
+  受一个参数,将所有的元素间隔设置为 \meta{separator}。第二个版本接受逗号分隔
+  的三个参数,分别用来设置只有两个元素时的分隔符 \meta{separator between two},
+  超过两个元素时的分隔符 \meta{separator between more than two},和最后两个元
+  素之间的分隔符 \meta{separator between final two}。
+
+\end{option}
+
+\begin{option}{
+  opt = item-before-code,
+  desc = {= \meta{before code}}
+}
+  该选项只适用于类型为 |clist| 的属性,用来设置展示列表每个元素前需要执行的代
+  码。
+\end{option}
+
+\begin{option}{
+  opt = item-after-code,
+  desc = {= \meta{after code}}
+}
+  该选项只适用于类型为 |clist| 的属性,用来设置展示列表每个元素后需要执行的代
+  码。
+\end{option}
+
+\subsection{使用 \cs{dbNewReviewPoints} 定义复习点}
+
+\begin{function}{\dbNewReviewPoints}
+  \begin{syntax}
+    \cs{dbNewReviewPoints} \marg{name} \marg{points}
+  \end{syntax}
+
+  定义名为 \meta{name} 的复习点。这是专门为错题本或复习所定制的功能,
+  \meta{points}是一系列整数,现在假设每道错题你都将写错时的日期记录在了 |date|
+  属性中,并且你希望每隔2,5,15天复习一次。下面的代码给出了一个实现示例。
+\begin{verbatim}
+  \dbNewReviewPoints{review-point}{2, 5, 15}            % 定义复习点
+  \begin{dbFilters}
+    \dbNewConditional{cond1}{date}{review-point|\Today} % 定义复习条件
+    \dbCombineConditionals{filter1}{cond1}              % 定义过滤器
+  \end{dbFilters}
+  \dbNewStyle{review-style}{ques}{filter=filter1}       % 定义展示样式
+\end{verbatim}
+\end{function}
+
+\subsection{在 \env{dbFilters} 环境中定义过滤器}
+
+\noindent\DescribeEnv{dbFilters}
+\begin{Syntax}*
+  |\begin{dbFilters}|\marg{database} \\
+  ~~\meta{code}
+  |\end{dbFilters}| \\
+\end{Syntax}
+
+\env{dbFilters}用来定义过滤器,此环境中定义了 \cs{dbNewConditional} 命令用来定
+义条件和 \cs{dbCombineConditionals} 命令用来组合条件定义过滤器。过滤器独立于每
+个 \meta{database},这意味着你可以在不同数据库中定义名称相同的过滤条件和过滤器。
+
+\begin{function}{\dbNewConditional, \dbNewConditional*}
+  \begin{syntax}
+    \cs{dbNewConditional}  \marg{name}        \marg{attr} \marg{cond spec} \\
+    \cs{dbNewConditional}* \marg{name}        \marg{attr} \marg{cond spec} \\[2pt]
+    \cs{dbNewConditional}  \marg{name} \marg{int/fp attr} \marg{relation} \\
+    \cs{dbNewConditional}* \marg{name} \marg{int/fp attr} \marg{relation} \\
+    \cs{dbNewConditional}  \marg{name} \marg{str/tl attr} \marg{regex expr} \\
+    \cs{dbNewConditional}* \marg{name} \marg{str/tl attr} \marg{regex expr} \\
+    \cs{dbNewConditional}  \marg{name}  \marg{clist attr} \marg{val list} \\
+    \cs{dbNewConditional}* \marg{name}  \marg{clist attr} \marg{val list} \\
+    \cs{dbNewConditional}  \marg{name}   \marg{date attr} \{\meta{review points}\textbar\meta{date}\} \\
+    \cs{dbNewConditional}* \marg{name}   \marg{date attr} \marg{relation}
+  \end{syntax}
+
+  \cs{dbNewConditional} 用来定义名为 \meta{name} 的条件,\meta{attr} 指定条件
+  所绑定的属性,在 \meta{cond spec} 中可以用 \cs{dbval} 指代属性的值。
+\end{function}
+
+  对于类型为 |int| 和 |fp| 的属性,两个版本的定义是一致的,\meta{relation} 可
+  以是单个关系式,比如 |\dbval > 3|,也可以是组合关系式,比如
+  |\dbval > 3 && \dbval < 10.2|。支持的操作符有 |<, >, =, ==, !=, >=, <=, !|。
+
+  对于类型为 |str| 和 |tl| 的属性,\meta{regex} 为正则表达式,
+  \cs{dbNewConditional} 表示部分匹配,\cs{dbNewConditional*} 表示整体匹配。
+\begin{verbatim}
+  \dbNewConditional{cond1}{str-attr}{abc}  % 匹配 abc, abcd, 1abc, =abc= 等
+  \dbNewConditional*{cond2}{str-attr}{abc} % 只匹配 abc
+\end{verbatim}
+
+  对于类型为 |clist| 的属性,使用 \cs{dbNewConditional} 定义的条件只要
+  \meta{val list} 中的任意一个元素在属性值(列表)中则条件成立;使用
+  \cs{dbNewConditional*} 定义的条件只有 \meta{val list} 中每一个值都在属性值
+  (列表)中条件才成立。
+
+\begin{verbatim}
+  \dbNewConditional{cond1}{clist-attr}{a, b, c}  % a, b, d 满足条件
+  \dbNewConditional*{cond2}{clist-attr}{a, b, c} % a, b, d 不满足条件
+\end{verbatim}
+
+  对于类型为 |date| 的属性,\cs{dbNewConditional} 使用复习点来定义过滤条件,
+  \meta{review points} 是 \cs{dbNewReviewPoints} 定义的复习点,\meta{date} 是
+  用来比较的日期;\cs{dbNewConditional*} 使用\textbf{单个}关系式来定义过滤条件。
+  支持的操作符有 |<, >, =, ==, !=, >=, <=|。
+
+\begin{function}{\dbCombineConditionals}
+  \begin{syntax}
+    \cs{dbCombineConditionals} \marg{name} \marg{cond combination} \oarg{info}
+  \end{syntax}
+
+  \cs{dbCombineConditionals} 定义名为 \marg{name} 的过滤器,并将
+  \cs{dbNewConditional} 定义的条件组合起来,比如
+  \verb=\dbCombineConditionals{filter}{(cond1 && cond2) || !cond3}=。
+  \meta{cond combination} 中可以使用的关系操作符为 \verb=&&, ||, !=。
+  可以将 \opt{filter} 选项设置为 \meta{name} 来应用过滤器。\meta{info} 为过滤
+  器的相关信息,在展示数据库的时候可以用 \cs{dbFilterInfo} 指代。
+\end{function}
+
+\subsection{使用 \env{dbitem} 环境存储数据}
+
+\noindent\DescribeEnv{dbitem}
+\begin{Syntax}*
+  |\begin{dbitem}|\marg{database}[ \\
+  ~~\meta{attr1} = \meta{val1}, \\
+  ~~\meta{attr2} = \meta{val2}, \\
+  ~~\ldots{} \\
+  ] \\
+  ~~\meta{code} \\
+  |\end{dbitem}|
+\end{Syntax}
+
+  \env{dbitem} 环境用来存储数据。有两种存储数据的方法,较短的数据可以在选项列
+  表中通过键值对设置值,较长的数据可以在 \meta{code} 中使用 \cs{dbsave} 存储。
+  \cs{dbsave}会覆盖选项中设置的值。没有设置的值将会被设置为全局默认值,下面给
+  出一个存储示例。
+
+\begin{verbatim}
+  \begin{dbitem}[date=2022-01-01, info=测试]
+    \dbsave{question}{这是一个测试问题}
+    \dbsave{answer}{这是一个测试答案}
+  \end{dbitem}
+\end{verbatim}
+
+\subsection{\cs{dbsave} 和 \cs{dbuse}}
+
+\begin{function}{\dbsave, \dbuse}
+  \begin{syntax}
+    \cs{dbsave} \marg{attr} \marg{data} \\
+    \cs{dbuse}  \marg{attr} \\
+  \end{syntax}
+
+  \cs{dbsave} 用来存储数据,只能在 \env{item} 环境中使用。\cs{dbuse} 用来使用
+  数据,只能在 \opt{item-code} 选项中使用。
+\end{function}
+
+\subsection{使用 \cs{dbshow} 展示数据库}
+
+\begin{function}{\dbshow}
+  \begin{syntax}
+    \cs{dbshow} \marg{style} \marg{database}
+  \end{syntax}
+
+  使用 \meta{style} 样式来展示 \meta{database}。
+\end{function}
+
+\subsection{条件判别式}
+
+\begin{function}{\dbIfEmptyT, \dbIfEmptyF, \dbIfEmptyTF}
+  \begin{syntax}
+    \cs{dbIfEmptyTF} \marg{true code} \marg{false code} \\
+    \cs{dbIfEmptyT} \marg{true code} \\
+    \cs{dbIfEmptyF} \marg{false code}
+  \end{syntax}
+
+  该判别式用来判断当前数据库是否为空。下面的示例展示了如何预防空的列表环境。
+\end{function}
+
+\begin{verbatim}
+  \dbNewStyle{style-cond1}{database-test}{
+    before-code = {\dbIfEmptyF{\begin{enumerate}}},
+    after-code = {\dbIfEmptyF{\end{enumerate}}},
+    item-code = {\item \dbuse{attr-test}}
+  }
+\end{verbatim}
+
+\begin{function}{\dbItemIfEmptyT, \dbItemIfEmptyF, \dbItemIfEmptyTF}
+  \begin{syntax}
+    \cs{dbItemIfEmptyTF} \marg{true code} \marg{false code} \\
+    \cs{dbItemIfEmptyT} \marg{true code} \\
+    \cs{dbItemIfEmptyF} \marg{false code}
+  \end{syntax}
+
+  该判别式用来判断当前元素是否为空。下面的示例展示了如何在展示 |database-test|
+  数据库中 |text| 属性的元素时在元素非空的时候前后都加上 |*|。
+\end{function}
+
+\begin{verbatim}
+  \dbNewStyle{style-cond2}{database-test}{
+    text/before-code = {\dbItemIfEmptyF{*}},
+    text/after-code = {\dbItemIfEmptyF{*}},
+  }
+\end{verbatim}
+
+\begin{function}{\dbClistItemIfEmptyT, \dbClistItemIfEmptyF, \dbClistItemIfEmptyTF}
+  \begin{syntax}
+    \cs{dbClistItemIfEmptyTF} \marg{true code} \marg{false code} \\
+    \cs{dbClistItemIfEmptyT} \marg{true code} \\
+    \cs{dbClistItemIfEmptyF} \marg{false code}
+  \end{syntax}
+
+  该判别式用来判断列表属性中的元素是否为空。下面的示例展示了如何在展示
+  |database-test| 数据库中 |labels| 属性(标签列表)的元素时在标签非空的时候前
+  后都加上 |*|。
+\end{function}
+
+\begin{verbatim}
+  \dbNewDatabase{database-test}{labels=clist}
+  \dbNewStyle{style-cond3}{database-test}{
+    labels/item-before-code = {\dbClistItemIfEmptyF{*}},
+    labels/item-after-code = {\dbClistItemIfEmptyF{*}},
+  }
+\end{verbatim}
+
+\subsection{常量}
+
+\begin{function}{\dbDatabase, \dbFilterName, \dbFilterInfo, \dbIndex}
+  \cs{dbDatabase} 指代数据库名,\cs{dbFilterName} 指代过滤器名称,
+  \cs{dbFilterInfo} 指代过滤器额外信息,\cs{dbIndex} 指代当前索引。
+\end{function}
+
+\section{错题本示例}
+见第 \ref{sec:example} 节。
+
+\title{
+  Package \pkg{dbshow}
+  \protect\footnote{\url{https://github.com/ZhiyuanLck/dbshow}}
+  \rlap{\makebox[4cm][r]{
+    \normalsize $\Longrightarrow$ \color{red}
+    \protect\hyperlink{zh}{中文版本}
+    \protect\hypertarget{en}{}
+  }}
+}
+\author{Li Changkai \texttt{<lichangkai225\@qq.com>}}
+\date{2022/01/03}
+\maketitle
+
+\section{Introduction}
+
+The initial motivation to write this package is that I want to write a
+template, which can collect questions you gave the wrong answer and can
+display those questions you would like to review by some conditionals, such as
+questions with certain label, questions you have answered uncorrectly for
+certain times or questions having not been reviewed for certain days. So this
+package provides a database to do such thing.
+
+The package provides four core functions: data storage and display, data
+filtering, data sorting and data display. All data is saved once and then you
+can display these data with custom filters, orders and styles.
+
+The package constructs 6 types based on the internal typed of \pkg{expl3}:
+\begin{Description}[\texttt{clist}]
+  \item[\texttt{date}]
+    date based on \pkg{datetime2} in iso format, supports comparison,
+    sorting (converting to |str|), default \cs{Today}.
+  \item[\texttt{str}]
+    string,supports regex match and sorting, default empty.
+  \item[\texttt{tl}]
+    token list, supports regex match, default empty.
+  \item[\texttt{int}]
+    integer, supports comparison and sorting, default 0.
+  \item[\texttt{fp}]
+    floating point, supports comparison and sorting, default 0.
+  \item[\texttt{clist}]
+    comma list, default empty.
+\end{Description}
+
+\section{Interfaces}
+
+\subsection{\cs{dbNewDatabase}}
+
+\begin{function}{\dbNewDatabase, \dbNewDatabase*}
+  \begin{syntax}
+    \cs{dbNewDatabase} \oarg{base database} \marg{database} \{ \\
+    ~~\meta{attr1} = \meta{type spec1}, \\
+    ~~\meta{attr2} = \meta{type spec2}, \\
+    ~~\ldots{} \\
+    \} \\
+    \cs{dbNewDatabase}* \marg{database} \{ \\
+    ~~\meta{attr1} = \meta{type spec1}, \\
+    ~~\meta{attr2} = \meta{type spec2}, \\
+    ~~\ldots{} \\
+    \} \\
+  \end{syntax}
+
+\end{function}
+
+Create a new database named \meta{database}, unstarred form provides the optional
+\meta{base database} from which current database inherit the attributes settings.
+The unstarred form always replace the old definition, while starred form
+appends the new options.
+
+\begin{Syntax}
+  \meta{attr} = \meta{type} \\
+  \meta{attr} = \meta{type}\textbar\meta{default}
+\end{Syntax}
+
+The first form defines the \meta{attr} as \meta{type}, and the second also
+sets the default value.
+
+\begin{note}
+  Every database has a default attribute |id| to store the index of the item.
+\end{note}
+
+The example below define a database named |ques|.
+\begin{verbatim}
+  \dbNewDatabase{ques}{
+    question = tl, % store question
+    answer = tl,   % store corresponding answer
+    date = date,   % store the date when you were wrong
+    info = tl,     % store extra info
+    labels = clist % store question labels
+  }
+\end{verbatim}
+
+\subsection{\cs{dbNewStyle} and Style Options}
+
+\begin{function}{\dbNewStyle}
+  \begin{syntax}
+    \cs{dbNewStyle} \oarg{base styles} \marg{style} \marg{database} \marg{opts}
+  \end{syntax}
+
+Define a new \meta{style} that binds to \meta{database}. The style can inherit
+from a list of \meta{base styles} such as
+|\dbNewStyle[base1, base2]{new-style}{ques}{}|.
+\end{function}
+
+\bigskip
+
+\begin{option}{opt=filter, desc={= \meta{filter}}, init=-none-}
+  Set the \meta{filter} defined by \cs{dbCombineFilters}.
+\end{option}
+
+\begin{option}{
+  opt = sort,
+  desc = {= \{ \meta{attr spec1}, \meta{attr spec2}, \ldots{} \}},
+}
+  Set sorting rules. Attributes of type |str, date, int, fp| is supported to
+  sort.  Multi-level sort is allowed. \meta{attr} represents for ascending
+  order, and \meta{attr}* represents for descending order. The example below
+  use four fields to determine the order of the records. It sorts on |level|
+  in descending order first and if two |levels| are same then sorts on |birth|
+  in ascending order and so on.
+\end{option}
+
+\begin{verbatim}
+  \dbNewDatabase{sort-example}{
+    name = str,
+    birth = date,
+    level = int,
+    weight = fp,
+  }
+  \dbNewStyle{sort-style}{sort-example}{
+    sort = { level*, birth, name, weight }
+  }
+\end{verbatim}
+
+\begin{option}{
+  opt = before-code,
+  desc = {= \meta{before code}}
+}
+  Set the \meta{before code} that is executed before displaying the database.
+\end{option}
+
+\begin{option}{
+  opt = after-code,
+  desc = {= \meta{after code}}
+}
+  Set the \meta{after code} that is executed after displaying the database.
+\end{option}
+
+\begin{option}{
+  opt = item-code,
+  desc = {= \meta{item code}}
+}
+  Set the code that show a single record. You can use \cs{dbuse} to display
+  certian attribute.
+\end{option}
+
+\begin{option}{
+  opt = {\meta{attr}/before-code},
+  desc = {= \meta{before code}}
+}
+  Set the \meta{before code} that is executed by \cs{dbuse} before displaying
+  certain attribute.
+\end{option}
+
+\begin{option}{
+  opt = {\meta{attr}/after-code},
+  desc = {= \meta{after code}}
+}
+  Set the \meta{after code} that is executed by \cs{dbuse} after displaying
+  certain attribute.
+\end{option}
+
+\begin{option}{
+  opt = {\meta{attr}/sep},
+  desc = {= \meta{sep spec}},
+  init = {,~\~}
+}
+\begin{Syntax}
+  \meta{attr}/separator = \meta{separator} \\
+  \meta{attr}/separator = \{ \\
+  ~~\meta{separator between two}, \\
+  ~~\meta{separator between more than two}, \\
+  ~~\meta{separator between final two} \\
+  \}
+\end{Syntax}
+
+  Only for attributes of type |clist|. Set the separator between clist items.
+  The first form accept one arguments and set the seperator as \meta{sep}. The
+  second form is more complicated, the following documentation is quoted from
+  \pkg{interface3}:
+  \begin{quote}
+    If the comma list has more than two items, the \meta{separator between
+    more than two} is placed between each pair of items except the last, for
+    which the \meta{separator between final two} is used. If the comma list
+    has exactly two items, then they are placed in the input stream separated
+    by the \meta{separator between two}. If the comma list has a single item,
+    it is placed in the input stream, and a comma list with no items produces
+    no output.
+  \end{quote}
+
+\end{option}
+
+\begin{option}{
+  opt = item-before-code,
+  desc = {= \meta{before code}}
+}
+  Only for attributes of type |clist|. Set the \meta{after code} that is
+  excuted before displaying the item of the comma list.
+\end{option}
+
+\begin{option}{
+  opt = item-after-code,
+  desc = {= \meta{after code}}
+}
+  Only for attributes of type |clist|. Set the \meta{after code} that is
+  excuted after displaying the item of the comma list.
+\end{option}
+
+\subsection{Use \cs{dbNewReviewPoints} to Define Review Points}
+
+\begin{function}{\dbNewReviewPoints}
+  \begin{syntax}
+    \cs{dbNewReviewPoints} \marg{name} \marg{points}
+  \end{syntax}
+
+  Define the new \meta{points} that is specially designed for reviewing
+  something. \meta{points} is a list of integers. Suppose you record the date
+  when you did not answer correctly and you plan to review every 2, 5 and 15
+  days. The following code give what you want.
+\begin{verbatim}
+  \dbNewReviewPoints{review-point}{2, 5, 15}            % define points
+  \begin{dbFilters}
+    \dbNewConditional{cond1}{date}{review-point|\Today} % define conditional
+    \dbCombineConditionals{filter1}{cond1}              % define filter
+  \end{dbFilters}
+  \dbNewStyle{review-style}{ques}{filter=filter1}       % define style
+\end{verbatim}
+\end{function}
+
+\subsection{Define Filters inside \env{dbFilters} Environment}
+
+\noindent\DescribeEnv{dbFilters}
+\begin{Syntax}*
+  |\begin{dbFilters}|\marg{database} \\
+  ~~\meta{code}
+  |\end{dbFilters}| \\
+\end{Syntax}
+
+Filters are defined inside \env{dbFilters} environment, inside which,
+\cs{dbNewConditional} is defined to declare conditionals and
+\cs{dbCombineConditionals} is defined to combine conditionals. Filters are
+independent in different databases, which means the same name of filters is
+allowed in different databases.
+
+\begin{function}{\dbNewConditional, \dbNewConditional*}
+  \begin{syntax}
+    \cs{dbNewConditional}  \marg{name}        \marg{attr} \marg{cond spec} \\
+    \cs{dbNewConditional}* \marg{name}        \marg{attr} \marg{cond spec} \\[2pt]
+    \cs{dbNewConditional}  \marg{name} \marg{int/fp attr} \marg{relation} \\
+    \cs{dbNewConditional}* \marg{name} \marg{int/fp attr} \marg{relation} \\
+    \cs{dbNewConditional}  \marg{name} \marg{str/tl attr} \marg{regex expr} \\
+    \cs{dbNewConditional}* \marg{name} \marg{str/tl attr} \marg{regex expr} \\
+    \cs{dbNewConditional}  \marg{name}  \marg{clist attr} \marg{val list} \\
+    \cs{dbNewConditional}* \marg{name}  \marg{clist attr} \marg{val list} \\
+    \cs{dbNewConditional}  \marg{name}   \marg{date attr} \{\meta{review points}\textbar\meta{date}\} \\
+    \cs{dbNewConditional}* \marg{name}   \marg{date attr} \marg{relation}
+  \end{syntax}
+
+  Define the conditional named \meta{name} that binds to \meta{attr}. \cs{dbval}
+  is replaced with the real value of the attribute inside the \meta{cond spec}.
+\end{function}
+
+For attributes of type |int| and |fp|, two forms have the same definition.
+\meta{relation} can be a single relation formula, such as |\dbval > 3|, or the
+combination of several relation formulas, such as |\dbval > 3 && \dbval < 10.2|.
+Supported operators are |<, >, =, ==, !=, >=, <=, !|.
+
+For attribute of type |str| and |tl|, unstarred form matches any part while
+starred form matches the whole part with the \meta{regex expr}.
+\begin{verbatim}
+  \dbNewConditional{cond1}{str-attr}{abc}  % match abc, abcd, 1abc, =abc=, etc
+  \dbNewConditional*{cond2}{str-attr}{abc} % only match abc
+\end{verbatim}
+
+For attributes of type |clist|, the conditional defined by unstarred form is
+true if any item of \meta{val list} is in the comma list. While the
+conditional defined by starred form is true only if every item of \meta{val
+list} is in the comma list. As is showed below, for |cond1|, |a| is in
+|{a, b, d}| so |cond1| is true. While |c| is not in |{a, b, d}| so |cond2| is
+false.
+
+\begin{verbatim}
+  \dbNewConditional{cond1}{clist-attr}{a, b, c}  % {a, b, d} -> true
+  \dbNewConditional*{cond2}{clist-attr}{a, b, c} % {a, b, d} -> false
+\end{verbatim}
+
+For attributes of type |date|, unstarred form uses \meta{review points} to
+define the conditional and \meta{date} is the date to be compared. The starred
+form define the conditional with \textbf{single} relation formula. Supported
+operators are |<, >, =, ==, !=, >=, <=|.
+
+\begin{function}{\dbCombineConditionals}
+  \begin{syntax}
+    \cs{dbCombineConditionals} \marg{name} \marg{cond combination} \oarg{info}
+  \end{syntax}
+
+  Define the filter \meta{name}, which combine the conditionals and store the
+  extra \meta{info} into \cs{dbFilterInfo}. So you can write something as\\
+  \verb=\dbCombineConditionals{filter}{(cond1 && cond2) || !cond3}=.\\
+  Supported operators are \verb=&&, ||, !=. You can set the option \opt{filter}
+  to \meta{name} to apply the filter when you display the database.
+\end{function}
+
+\subsection{Store Data with \env{dbitem} Environment}
+
+\noindent\DescribeEnv{dbitem}
+\begin{Syntax}*
+  |\begin{dbitem}|\marg{database}[ \\
+  ~~\meta{attr1} = \meta{val1}, \\
+  ~~\meta{attr2} = \meta{val2}, \\
+  ~~\ldots{} \\
+  ] \\
+  ~~\meta{code} \\
+  |\end{dbitem}|
+\end{Syntax}
+
+The data are stored with \env{dbitem} environment in two ways. Smaller data
+can be stored in the option list and the bigger data can be stored by
+\cs{dbsave}, which will suppress the value set by the option list. An example
+code is showned below.
+
+\begin{verbatim}
+  \begin{dbitem}[date=2022-01-01, info=test]
+    \dbsave{question}{This is a test question.}
+    \dbsave{answer}{This is the correct answer of the question.}
+  \end{dbitem}
+\end{verbatim}
+
+\subsection{\cs{dbsave} and \cs{dbuse}}
+
+\begin{function}{\dbsave, \dbuse}
+  \begin{syntax}
+    \cs{dbsave} \marg{attr} \marg{data} \\
+    \cs{dbuse}  \marg{attr} \\
+  \end{syntax}
+
+  Date is stored with \cs{dbsave} and is displayed with \cs{dbuse}.  \cs{dbsave}
+  can be used only inside the \env{dbitem} environment and \cs{dbuse} can be
+  only used inside the option \opt{item-code}.
+\end{function}
+
+\subsection{Use \cs{dbshow} to Display the Database}
+
+\begin{function}{\dbshow}
+  \begin{syntax}
+    \cs{dbshow} \marg{style} \marg{database}
+  \end{syntax}
+
+  Show the \meta{database} with \meta{style}.
+\end{function}
+
+\subsection{Conditionals}
+
+\begin{function}{\dbIfEmptyT, \dbIfEmptyF, \dbIfEmptyTF}
+  \begin{syntax}
+    \cs{dbIfEmptyTF} \marg{true code} \marg{false code} \\
+    \cs{dbIfEmptyT} \marg{true code} \\
+    \cs{dbIfEmptyF} \marg{false code}
+  \end{syntax}
+
+  Test if the database is empty. The example below shows how to avoid an empty
+  list environment.
+\end{function}
+
+\begin{verbatim}
+  \dbNewStyle{style-cond1}{database-test}{
+    before-code = {\dbIfEmptyF{\begin{enumerate}}},
+    after-code = {\dbIfEmptyF{\end{enumerate}}},
+    item-code = {\item \dbuse{attr-test}}
+  }
+\end{verbatim}
+
+\begin{function}{\dbItemIfEmptyT, \dbItemIfEmptyF, \dbItemIfEmptyTF}
+  \begin{syntax}
+    \cs{dbItemIfEmptyTF} \marg{true code} \marg{false code} \\
+    \cs{dbItemIfEmptyT} \marg{true code} \\
+    \cs{dbItemIfEmptyF} \marg{false code}
+  \end{syntax}
+
+  Test if the value of the attribute is empty. The example belows shows how to
+  surround the non-empty |text| attribute with the symbol *.
+\end{function}
+
+\begin{verbatim}
+  \dbNewStyle{style-cond2}{database-test}{
+    text/before-code = {\dbItemIfEmptyF{*}},
+    text/after-code = {\dbItemIfEmptyF{*}},
+  }
+\end{verbatim}
+
+\begin{function}{\dbClistItemIfEmptyT, \dbClistItemIfEmptyF, \dbClistItemIfEmptyTF}
+  \begin{syntax}
+    \cs{dbClistItemIfEmptyTF} \marg{true code} \marg{false code} \\
+    \cs{dbClistItemIfEmptyT} \marg{true code} \\
+    \cs{dbClistItemIfEmptyF} \marg{false code}
+  \end{syntax}
+
+  Test if the item of comma list is empty. The example belows shows how to
+  surround the non-empty label with the symbol *.
+\end{function}
+
+\begin{verbatim}
+  \dbNewDatabase{database-test}{labels=clist}
+  \dbNewStyle{style-cond3}{database-test}{
+    labels/item-before-code = {\dbClistItemIfEmptyF{*}},
+    labels/item-after-code = {\dbClistItemIfEmptyF{*}},
+  }
+\end{verbatim}
+
+\subsection{Constants}
+
+\begin{function}{\dbDatabase, \dbFilterName, \dbFilterInfo, \dbIndex}
+  \cs{dbDatabase} represents for the database name, \cs{dbFilterName} represents for
+  the filter name, \cs{dbFilterInfo} represents for the extra info of the
+  filter and \cs{dbIndex} represents for the item index.
+\end{function}
+
+\section{Example of Flaw Sweeper Template}
+\label{sec:example}
+
+\begin{verbatim}
+  \documentclass{article}
+  \usepackage{dbshow}
+  \usepackage{hyperref}
+
+  \NewDocumentCommand { \hyperlinktarget } { m m m } {%
+    \hyperlink{#1}{#3}\hypertarget{#2}{}
+  }
+
+  \dbNewDatabase{ques}{
+    question=tl,
+    answer=tl,
+    date=date,
+    count=int,
+    labels=clist
+  }
+  \dbNewReviewPoints{review}{1, 3, 7, 15, 30, 60}
+
+  \begin{dbFilters}{ques}
+    % which need reviewed today?
+    \dbNewConditional{date}{date}{review|2021-12-25}
+    \dbNewConditional{easy}{labels}{easy}
+    \dbNewConditional{not-easy}{labels}{mid, hard}
+    % questions you haven't answered correctly for more than 3 times!
+    \dbNewConditional{bad}{count}{\dbval > 3}
+    \dbCombineConditionals{date}{date}[to be review today]
+    \dbCombineConditionals{easy}{easy}[easy questions]
+    \dbCombineConditionals{not-easy}{not-easy}[hard questions]
+    \dbCombineConditionals{bad}{bad}[bad questions]
+    \dbCombineConditionals{bad-easy}{bad && easy}[bad but easy questions]
+  \end{dbFilters}
+
+  \newcounter{ques}
+
+  \dbNewStyle{test}{ques} {
+    before-code = {\setcounter{ques}{0}\section{Test}},
+    item-code = {
+      \refstepcounter{ques}
+      \par\noindent\arabic{ques}. \dbuse{labels} \dbuse{date}\hfill \dbuse{count}
+      \par\noindent ques: \dbuse{question}
+      \par\noindent\hyperlinktarget
+        {answer_\dbIndex}{ques_\dbIndex}{go to answer}
+    },
+  }
+  \dbNewStyle{check}{ques} {
+    before-code = {\setcounter{ques}{0}\section{Answer}},
+    item-code = {
+      \refstepcounter{ques}
+      \par\noindent\arabic{ques}. \dbuse{labels} \dbuse{date}\hfill \dbuse{count}
+      \par\noindent ques: \dbuse{question}
+      \par\noindent\hyperlinktarget
+        {ques_\dbIndex}{answer_\dbIndex}{back to question}
+      \par\noindent answer: \dbuse{answer}
+    },
+  }
+  \dbNewStyle[test]{test-bad}{ques}{
+    filter=bad,
+    before-code = {\setcounter{ques}{0}\section{Bad Question}}
+  }
+
+  \AtEndDocument{
+    \dbshow{test}{ques}
+    \dbshow{test-bad}{ques}
+    \dbshow{check}{ques}
+  }
+
+  \begin{document}
+
+  \begin{dbitem}{ques}[date=2021-12-21, count=1, labels=easy]
+    \dbsave{question}{This is test question 1.}
+    \dbsave{answer}{This is test question 1.}
+  \end{dbitem}
+
+  \begin{dbitem}{ques}[date=2021-12-22, count=4, labels=easy]
+    \dbsave{question}{This is test question 2.}
+    \dbsave{answer}{This is test question 2.}
+  \end{dbitem}
+
+  \begin{dbitem}{ques}[date=2021-12-23, count=3, labels=hard]
+    \dbsave{question}{This is test question 3.}
+    \dbsave{answer}{This is test question 3.}
+  \end{dbitem}
+
+  \end{document}
+\end{verbatim}
+
+\end{documentation}
+
+
+\end{document}


Property changes on: trunk/Master/texmf-dist/doc/latex/dbshow/dbshow-doc.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/latex/dbshow/dbshow.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/dbshow/dbshow.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/dbshow/dbshow.sty	2022-01-06 00:21:44 UTC (rev 61503)
@@ -0,0 +1,661 @@
+%% dbshow.sty
+%% Copyright 2022 Li Changkai <lichangkai225 at qq.com>
+%
+% This work may be distributed and/or modified under the
+% conditions of the LaTeX Project Public License, either version 1.3
+% of this license or (at your option) any later version.
+% The latest version of this license is in
+%   http://www.latex-project.org/lppl.txt
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status `maintained'.
+% 
+% The Current Maintainer of this work is Li Changkai.
+%
+% This work consists of the files dbshow.sty, dbshow-doc.tex.
+\def\myfileversion{1.0}
+\def\myfiledate{2022/01/02}
+\RequirePackage{expl3, xparse}
+\RequirePackage[calc]{datetime2}
+\ProvidesExplPackage
+  {dbshow}
+  {\myfiledate}
+  {\myfileversion}
+  {database to store and show data}
+
+\DTMsetdatestyle{iso}
+
+\msg_new:nnn { dbshow } { non-existent-database } {
+  Database~'#1'~does~not~exist~\msg_line_context:.
+}
+
+% #1 database
+\cs_new:Nn \dbshow_check_database:n {
+  \prop_if_exist:cF { g__dbshow_type_map_#1 }
+    { \msg_fatal:nnn { dbshow } { non-existent-database } { #1 } }
+}
+
+\msg_new:nnn { dbshow } { non-existent-attr } {
+  Attribute~'#2'~of~database~'#1'~does~not~exist~\msg_line_context:.
+}
+
+% #1 database #2 attr
+\cs_new:Nn \dbshow_check_attr:nn {
+  \prop_if_in:cnF { g__dbshow_type_map_#1 } { #2 }
+    { \msg_fatal:nnnn { dbshow } { non-existent-attr } { #1 } { #2 } }
+}
+
+\msg_new:nnn { dbshow } { non-existent-style } {
+  Style~'#1'~of~database~'#2'~does~not~exist~\msg_line_context:.
+}
+
+% #1 style #2 database
+\cs_new:Nn \dbshow_check_style:nn {
+  \tl_if_exist:cF { g__dbshow_style_opts_#1_#2 }
+    { \msg_warning:nnnn { dbshow } { non-existent-style } { #1 } { #2 } }
+}
+
+\msg_new:nnn { dbshow } { non-existent-cond } {
+  Conditional~'#2'~of~database~'#1'~does~not~exist~\msg_line_context:.
+}
+
+% #1 database #2 cond
+\cs_new:Nn \dbshow_check_cond:nnn {
+  \tl_if_exist:cF { g__dbshow_filter_attr_#1_#2 }
+    { \msg_fatal:nnnn { dbshow } { non-existent-cond } { #1 } { #2 } }
+}
+
+\msg_new:nnn { dbshow } { non-existent-filter } {
+  Filter~'#2'~of~database~'#1'~does~not~exist~and~is~ignored~\msg_line_context:.
+}
+
+\cs_generate_variant:Nn \msg_warning:nnnn { nnnx }
+% #1 database #2 filter
+\cs_new:Nn \dbshow_check_filter:nn {
+  \seq_if_exist:cF { g__dbshow_filter_run_seq_#1_#2 } {
+    \str_if_eq:eeF { #2 } { -none- } {
+      \msg_warning:nnnx { dbshow } { non-existent-filter } { #1 } { #2 }
+    }
+  }
+}
+
+\msg_new:nnn { dbshow } { non-existent-type } {
+  Type~'#1'~does~not~exist,~the~type~of~attribute~should~be~one~of~
+  \{date,~str,~tl,~clist,~int,~fp\}~\msg_line_context:.
+}
+
+% #1 type
+\cs_new:Nn \dbshow_check_type:n {
+  \clist_if_in:NnF \dbshow_type_clist { #1 }
+    { \msg_fatal:nnn { dbshow } { non-existent-type } { #1 } }
+}
+
+% #1 count #2 content
+\msg_new:nnn { dbshow } { wrong-seperator } {
+  option~sep~should~contain~1~or~3~items~but~only~#1~items~was~given,~
+  sep~=~\{#2\}~\msg_line_context:.
+}
+
+\msg_new:nnn { dbshow } { unsupported-sort-type } {
+  unsupported~sort~type:~'#1'~\msg_line_context:.~The~type~should~be~one~of~
+  \{str,~date,~int,~fp\}.
+}
+
+\cs_new:Nn \dbshow_sep_error:nn {
+  \msg_error:nnnn { dbshow } { wrong-seperator } { #1 } { #2 }
+}
+\cs_generate_variant:Nn \dbshow_sep_error:nn { xx }
+
+\clist_const:Nn \dbshow_type_clist { date, str, tl, clist, int, fp }
+
+\prop_const_from_keyval:Nn \dbshow_new_cs_map {
+  date = str_clear_new:c,
+  str = str_clear_new:c,
+  tl = tl_gclear_new:c,
+  clist = clist_gclear_new:c,
+  int = int_gzero_new:c,
+  fp = fp_gzero_new:c
+}
+
+\prop_const_from_keyval:Nn \dbshow_set_cs_map {
+  date = str_gset:cn,
+  str = str_gset:cn,
+  tl = tl_gset:cn,
+  clist = clist_gset:cn,
+  int = int_gset:cn,
+  fp = fp_gset:cn
+}
+
+\prop_const_from_keyval:Nn \dbshow_use_cs_map {
+  date = str_use:c,
+  str = str_use:c,
+  tl = tl_use:c,
+  clist = dbshow_clist_use:c,
+  int = int_use:c,
+  fp = fp_use:c
+}
+
+\prop_const_from_keyval:Nn \dbshow_default_value {
+  date = \Today,
+  str = ,
+  tl = ,
+  clist = ,
+  int = 0,
+  fp = 0
+}
+
+\newcount\l_dbshow_date_diff
+
+% #1 database #2 attr #3 type #4 default value
+\cs_new:Npn \dbshow_process_default_value:w #1|#2=#3|#4\scan_stop {
+  \dbshow_check_type:n { #3 }
+  \prop_gput:cxx { g__dbshow_type_map_#1 } { #2 } { #3 }
+  \prop_gput:cxx { g__dbshow_default_map_#1 } { #2 } { #4 }
+}
+
+\cs_new_protected:Nn \dbshow_process_type_map:n {
+  \prop_gclear_new:c { g__dbshow_default_map_#1 }
+  \prop_map_inline:cn { g__dbshow_type_map_#1 } {
+    \str_if_in:nnTF { ##2 } { | }
+      { \dbshow_process_default_value:w #1|##1=##2\scan_stop }
+      {
+        \prop_get:NnN \dbshow_default_value { ##2 } \l_tmp_default
+        \dbshow_process_default_value:w #1|##1=##2|\l_tmp_default\scan_stop
+      }
+  }
+}
+
+% #1 database_name, #2 clist, attr=type
+\cs_new_protected:Nn \dbshow_database_new:nn {
+  \int_gzero_new:c { g__dbshow_counter_#1 }
+  \prop_gset_from_keyval:cn { g__dbshow_type_map_#1 } { #2 }
+}
+
+% #1 database_name, #2 clist
+\cs_new_protected:Nn \dbshow_database_new_append:nn {
+  \int_gzero_new:c { g__dbshow_counter_#1 }
+  \prop_if_exist:cF { g__dbshow_type_map_#1 }
+    { \prop_new:c { g__dbshow_type_map_#1 } }
+  \prop_gset_from_keyval:Nn \l_tmpa_prop { #2 }
+  \prop_concat:ccc { g__dbshow_type_map_#1 } { g__dbshow_type_map_#1 } { l_tmpa_prop }
+}
+
+% #1 database_name, #2 database inherit from #3 clist
+\cs_new_protected:Nn \dbshow_database_new_inherit:nnn {
+  \dbshow_check_database:n { #2 }
+  \str_if_eq:nnTF { #1 } { #2 } {
+    \dbshow_database_new_append:nn { #1 } { #3 }
+  } {
+    \int_gzero_new:c { g__dbshow_counter_#1 }
+    \prop_gset_from_keyval:cn { g__dbshow_type_map_#1 } { #3 }
+    \prop_concat:ccc { g__dbshow_type_map_#1 } { g__dbshow_type_map_#2 } { g__dbshow_type_map_#1 }
+  }
+}
+
+% #1 database_name, #2 attr
+\cs_new:Nn \dbshow_get_type:nn {
+  \prop_item:cn { g__dbshow_type_map_#1 } { #2 }
+}
+
+% #1 database_name
+\cs_new:Nn \dbshow_get_counter:n {
+  \int_use:c { g__dbshow_counter_#1 }
+}
+
+% #1 database_name
+\cs_new:Nn \dbshow_step_counter:n {
+  \int_gincr:c { g__dbshow_counter_#1 }
+}
+
+% #1 database #2 attr #3 content
+\cs_new:Nn \dbshow_save_data:nnn {
+  \dbshow_check_attr:nn { #1 } { #2 }
+  \str_set:Nx \l_tmp_type { \dbshow_get_type:nn { #1 } { #2 } }
+  \prop_get:NVN \dbshow_new_cs_map \l_tmp_type \l_tmp_cs_new
+  \prop_get:NVN \dbshow_set_cs_map \l_tmp_type \l_tmp_cs_set
+  \use:c { \l_tmp_cs_new }
+    { g__dbshow_data_#1_#2_\dbshow_get_counter:n { #1 } }
+  \use:c { \l_tmp_cs_set }
+    { g__dbshow_data_#1_#2_\dbshow_get_counter:n { #1 } } { #3 }
+}
+\cs_generate_variant:Nn \dbshow_save_data:nnn { nnx }
+
+\cs_new:Nn \dbshow_clist_use:N {
+  \clist_clear:N \l_tmpa_clist
+
+  \clist_map_inline:Nn #1 {
+    \prg_set_conditional:Nnn \dbshow_clist_item_if_empty: { T, F, TF } {
+      \tl_if_empty:nTF { ##1 }
+        { \prg_return_true: }
+        { \prg_return_false: }
+    }
+    \cs_set_eq:NN \dbClistItemIfEmptyT\dbshow_clist_item_if_empty:T
+    \cs_set_eq:NN \dbClistItemIfEmptyF\dbshow_clist_item_if_empty:F
+    \cs_set_eq:NN \dbClistItemIfEmptyTF\dbshow_clist_item_if_empty:TF
+
+    \clist_put_right:Nn \l_tmpa_clist {
+      \l_style_item_before_code
+      ##1
+      \l_style_item_after_code
+    }
+  }
+
+  \tl_clear:N \l_tmpa_tl
+  \clist_map_inline:Nn \l_style_sep_clist {
+    \tl_put_right:Nn \l_tmpa_tl { { ##1 } }
+  }
+
+  \int_set:Nn \l_tmpa_int { \clist_count:N \l_style_sep_clist }
+  \int_case:nnF { \l_tmpa_int } {
+    { 1 } {
+      \exp_after:wN \clist_use:Nn \exp_after:wN \l_tmpa_clist \l_tmpa_tl
+    }
+    { 3 } {
+      \exp_after:wN \clist_use:Nnnn \exp_after:wN \l_tmpa_clist \l_tmpa_tl
+    }
+  }
+  {
+    \dbshow_sep_error:xx
+      { \int_use:N \l_tmpa_int }
+      { \clist_use:Nn \l_style_sep_clist { , } }
+  }
+}
+\cs_generate_variant:Nn \dbshow_clist_use:N { c }
+
+% #1 database #2 attr #3 index
+\cs_new:Nn \dbshow_use_data:nnn {
+  \str_set:Nx \l_tmp_type { \dbshow_get_type:nn { #1 } { #2 } }
+  \prop_get:NVN \dbshow_use_cs_map \l_tmp_type \l_tmp_cs
+  \use:c { \l_tmp_cs } { g__dbshow_data_#1_#2_#3 }
+}
+
+% #1 database
+\cs_new_protected:Nn \dbshow_set_database_keys:n {
+  \prop_map_inline:cn { g__dbshow_type_map_#1 } {
+    \keys_define:nn { dbshow/database/#1 } {
+      ##1 .code:n = \dbshow_save_data:nnn { #1 } { ##1 } { ####1 },
+    }
+  }
+}
+
+% #1 append or not #2 inherit #3 database #4 attrs
+\NewDocumentCommand { \dbNewDatabase } { s o m m } {
+  \IfNoValueTF { #2 } {
+    \IfBooleanTF { #1 }
+      { \dbshow_database_new_append:nn { #3 } { #4 } }
+      { \dbshow_database_new:nn { #3 } { #4 } }
+  } { \dbshow_database_new_inherit:nnn { #3 } { #2 } { #4 } }
+  \dbshow_database_new_append:nn { #3 } { id=int }
+  \dbshow_process_type_map:n { #3 }
+  \dbshow_set_database_keys:n { #3 }
+  \dbNewStyle{default}{#3}{}
+}
+
+% #1 database #2 attr-content map
+\NewDocumentEnvironment { dbitem } { m O{} +b } {
+  \dbshow_check_database:n { #1 }
+  \dbshow_step_counter:n { #1 }
+  \cs_set:Nn \dbshow_set_default:nn {
+    \dbshow_save_data:nnx { #1 } { ##1 } {
+      \prop_item:cn { g__dbshow_default_map_#1 } { ##1 }
+    }
+  }
+  \prop_map_function:cN { g__dbshow_type_map_#1 } \dbshow_set_default:nn
+  \dbshow_save_data:nnx { #1 } { id } { \dbshow_get_counter:n { #1 } }
+  \keys_set:nn { dbshow/database/#1 } { #2 }
+  % #2 attr #3 content
+  \NewDocumentCommand { \dbsave } { m m } {
+    \dbshow_save_data:nnn { #1 } { ##1 } { ##2 }
+  }
+} { #3 }
+
+\cs_new:Nn \dbshow_if_int: {
+  \int_compare:nTF { \l_dbshow_rela }
+    { \dbshow_set_true: }
+    { \dbshow_set_false: }
+}
+
+\cs_new:Nn \dbshow_if_fp: {
+  \fp_compare:nTF { \l_dbshow_rela }
+    { \dbshow_set_true: }
+    { \dbshow_set_false: }
+}
+
+% star: all in
+% no star: one in
+\cs_new:Nn \dbshow_if_clist: {
+  \bool_if:NTF \l_star_bool { % and
+    \dbshow_set_true:
+    \exp_args:Nx
+    \clist_map_inline:nn { \l_dbshow_rela } {
+      \clist_if_in:NnF \dbval { ##1 } {
+        \dbshow_set_false:
+        \clist_map_break:
+      }
+    }
+  }
+  { % or
+    \dbshow_set_false:
+    \exp_args:Nx
+    \clist_map_inline:nn { \l_dbshow_rela } {
+      \clist_if_in:NnT \dbval { ##1 } {
+        \dbshow_set_true:
+        \clist_map_break:
+      }
+    }
+  }
+}
+
+% star: match full
+% no star: match part
+\cs_new:Nn \dbshow_if_str: {
+  \bool_if:NT \l_star_bool {
+    \tl_put_left:Nn \l_dbshow_rela { \A }
+    \tl_put_right:Nn \l_dbshow_rela { \Z }
+  }
+  \regex_match:VVTF \l_dbshow_rela \dbval
+    { \dbshow_set_true: }
+    { \dbshow_set_false: }
+}
+\cs_set_eq:NN \dbshow_if_tl: \dbshow_if_str:
+
+\cs_new:Npn \dbshow_parse_date:w #1|#2\dbshow_stop {
+  \clist_set_eq:Nc \l_point_clist { g__review_points_#1 }
+  \tl_set:Nn \l_date_tl { #2 }
+}
+
+\cs_new:Nn \dbshow_if_date: {
+  \bool_if:NTF \l_star_bool {
+    \regex_extract_once:nVNF { \A(.*)([!<>=]+)(.*)\Z }
+      \l_dbshow_rela \l_tmpa_seq { }
+    \exp_args:Nnx \DTMsavedate{day1}{ \seq_item:Nn \l_tmpa_seq { 2 } }
+    \tl_set:Nx \l_rela { \seq_item:Nn \l_tmpa_seq { 3 } }
+    \exp_args:Nnx \DTMsavedate{day2}{ \seq_item:Nn \l_tmpa_seq { 4 } }
+    \DTMsaveddatediff{day1}{day2}{\l_dbshow_date_diff}% specious blank
+    \exp_args:NnV \int_compare:nNnTF
+      { \the\l_dbshow_date_diff } \l_rela { 0 }
+      { \dbshow_set_true: }
+      { \dbshow_set_false: }
+  }
+  {
+    \exp_after:wN \dbshow_parse_date:w \l_dbshow_rela\dbshow_stop
+    \exp_args:Nnx \DTMsavedate{day1}{ \l_date_tl }
+    \exp_args:Nnx \DTMsavedate{day2}{ \dbval }
+    \DTMsaveddatediff{day1}{day2}{\l_dbshow_date_diff}% specious blank
+    \clist_if_in:NoTF \l_point_clist { \the\l_dbshow_date_diff }
+      { \dbshow_set_true: }
+      { \dbshow_set_false: }
+  }
+}
+
+\cs_generate_variant:Nn \prop_get:NnN { cVN }
+\prg_generate_conditional_variant:Nnn \regex_extract_once:nnN { nVN } { T, F, TF, p }
+\prg_generate_conditional_variant:Nnn \regex_match:nn { VV } { T, F, TF, p }
+% #1 database name #2 cond name #3 index
+\cs_set:Nn \dbshow_if:nnn {
+  \tl_set_eq:Nc \l_dbshow_attr { g__dbshow_filter_attr_#1_#2 }
+  \tl_set_eq:Nc \l_dbshow_rela { g__dbshow_filter_rela_#1_#2 }
+  \cs_set_eq:Nc \dbval { g__dbshow_data_#1_\l_dbshow_attr _#3 }
+  \cs_set:Nn \dbshow_set_true:
+    { \bool_gset_true:c { g__dbshow_filter_bool_#1_#2 } }
+  \cs_set:Nn \dbshow_set_false:
+    { \bool_gset_false:c { g__dbshow_filter_bool_#1_#2 } }
+  \prop_get:cVN { g__dbshow_type_map_#1 } \l_dbshow_attr \l_tmp_type
+  \bool_set_eq:Nc \l_star_bool { g__dbshow_cond_star_#1_#2 }
+  \use:c { dbshow_if_\l_tmp_type : }
+}
+
+% 将cond->attr, cond->rela, cond->bool关联起来
+% #1 database name #2 cond name #3 attr #4 rela #5 star
+\cs_new_protected:Nn \dbshow_new_conditional:nnnnn {
+  \tl_gset:cn { g__dbshow_filter_attr_#1_#2 } { #3 }
+  \tl_gset:cn { g__dbshow_filter_rela_#1_#2 } { #4 }
+  \bool_if_exist:cF { g__dbshow_filter_bool_#1_#2 }
+    { \bool_new:c { g__dbshow_filter_bool_#1_#2 } }
+  \bool_if_exist:cF { g__dbshow_cond_star_#1_#2 }
+    { \bool_new:c { g__dbshow_cond_star_#1_#2 } }
+  \IfBooleanTF { #5 }
+    { \bool_gset_true:c { g__dbshow_cond_star_#1_#2 } }
+    { \bool_gset_false:c { g__dbshow_cond_star_#1_#2 } }
+  \cs_gset:cn { g__dbshow_filter_cs_#1_#2:n } {
+    \dbshow_if:nnn { #1 } { #2 } { ##1 }
+  }
+  \seq_gput_right:cn { g__dbshow_cond_list_#1 } { #2 }
+}
+
+% 将组合条件cond1, cond2, ..., 替换成cond1->bool, cond2->bool, ...
+% #1 database name #2 filter name #3 filters
+\cs_new_protected:Nn \dbshow_combine_conditional:nnn {
+  \tl_gset_eq:cN { g__dbshow_filter_bool_tl_#1_#2 } \c_true_bool
+  \seq_gclear_new:c { g__dbshow_filter_run_seq_#1_#2 }
+  \regex_extract_all:nnN { \w+ } { #3 } \l_tmpa_seq
+  \seq_map_inline:Nn \l_tmpa_seq {
+    % ##1 cond name
+    \seq_if_in:cnT { g__dbshow_cond_list_#1 } { ##1 } {
+      \seq_gput_right:cn { g__dbshow_filter_run_seq_#1_#2 }
+        { g__dbshow_filter_cs_#1_##1:n }
+    }
+  }
+  \tl_set:Nn \l_tmpa_tl { #3 }
+  \regex_replace_all:nnN
+    { \w+ } { \c{ g__dbshow_filter_bool_#1_\0 } }
+    \l_tmpa_tl
+  \tl_gset_eq:cN { g__dbshow_filter_bool_tl_#1_#2 } \l_tmpa_tl
+}
+
+\cs_generate_variant:Nn \regex_replace_all:nnN { nnc }
+% #1 database #2 content
+\NewDocumentEnvironment { dbFilters } { m +b } {
+  \seq_gclear_new:c { g__dbshow_cond_list_#1 }
+  % #1 star #2 cond name #3 attr #4 rela
+  \DeclareDocumentCommand { \dbNewConditional } { s m m m } {
+    \dbshow_new_conditional:nnnnn
+      { #1 } { ##2 } { ##3 } { ##4 } { ##1 }
+  }
+  % ##1 filter name ##2 filters ##3 info
+  \DeclareDocumentCommand { \dbCombineConditionals } { m m O{} } {
+    \tl_gset:cn { g__dbshow_filter_info_#1_##1 } { ##3 }
+    \dbshow_combine_conditional:nnn { #1 } { ##1 } { ##2 }
+  }
+  #2
+} {  }
+
+% #1 name #2 points
+\NewDocumentCommand { \dbNewReviewPoints } { m m } {
+  \clist_set:cn { g__review_points_#1 } { #2 }
+}
+
+% #1 style name #2 database name #3 attr
+\cs_new_protected:Nn \dbshow_new_attr_style:nnn {
+  \dbshow_check_attr:nn { #2 } { #3 }
+  \keys_define:nn { dbshow/style/#1/#3 } {
+    before-code .tl_gset:c = { g__dbshow_style_before_#1_#2_#3 },
+    before-code .initial:n = ,
+    after-code .tl_gset:c = { g__dbshow_style_after_#1_#2_#3 },
+    after-code .initial:n = ,
+  }
+  \prop_get:cnN { g__dbshow_type_map_#2 } { #3 } \l_tmp_type
+  \str_if_eq:eeT { \l_tmp_type } { clist } {
+    \keys_define:nn { dbshow/style/#1/#3 } {
+      sep .clist_gset:c = { g__dbshow_style_sep_#1_#2_#3 },
+      sep .initial:n = { { ,~ } },
+      item-before-code .tl_gset:c = { g__dbshow_style_item_before_#1_#2_#3 },
+      item-before-code .initial:n = ,
+      item-after-code .tl_gset:c = { g__dbshow_style_item_after_#1_#2_#3 },
+      item-after-code .initial:n = ,
+    }
+  }
+}
+
+% #1 style name #2 database name
+\cs_new_protected:Nn \dbshow_new_database_style:nn {
+  \dbshow_check_database:n { #2 }
+  \keys_define:nn { dbshow/style/#1 } {
+    filter .tl_gset:c = { g__dbshow_filter_#1_#2 },
+    filter .initial:n = -none-,
+    sort .clist_gset:c = { g__dbshow_sort_#1_#2 },
+    before-code .tl_gset:c = { g__dbshow_style_before_#1_#2 },
+    before-code .initial:n = ,
+    item-code .tl_gset:c = { g__dbshow_style_database_item_#1_#2 },
+    item-code .initial:n = ,
+    after-code .tl_gset:c = { g__dbshow_style_after_#1_#2 },
+    after-code .initial:n = ,
+  }
+  \prop_map_inline:cn { g__dbshow_type_map_#2 } {
+    \dbshow_new_attr_style:nnn { #1 } { #2 } { ##1 }
+  }
+}
+
+% #1 base style #2 style #3 database #4 opt
+\NewDocumentCommand { \dbNewStyle } { o m m +m } {
+  \tl_gset:cn { g__dbshow_style_opts_#2_#3 } { #4, }
+  \IfValueT { #1 } {
+    \tl_gclear:N \g_tmpa_tl
+    \clist_map_inline:nn { #1 } {
+      \dbshow_check_style:nn { ##1 } { #3 }
+      \tl_if_exist:cT { g__dbshow_style_opts_##1_#3 } {
+        \tl_gconcat:ccc { g_tmpa_tl }
+          { g_tmpa_tl } { g__dbshow_style_opts_##1_#3 }
+      }
+    }
+    \tl_gconcat:ccc { g__dbshow_style_opts_#2_#3 }
+      { g_tmpa_tl } { g__dbshow_style_opts_#2_#3 }
+  }
+  \dbshow_new_database_style:nn { #2 } { #3 }
+  \exp_args:Nnv
+  \keys_set:nn { dbshow/style/#2 } { g__dbshow_style_opts_#2_#3 }
+}
+
+\cs_new:Npn \dbshow_sort_parse_star:w #1* {
+  \tl_set:Nx \l_op_same { > }
+  \tl_set:Nx \l_op_swap { < }
+  \str_set:Nn \l_tmpa_str { #1 }
+}
+
+% #1 database #2 index #3 style
+\cs_new:Nn \dbshow_sort:nNn {
+  \int_set:Nn \l_tmpb_int { \clist_count:c { g__dbshow_sort_#3_#1 } }
+  \clist_sort:Nn #2 {
+    \int_zero:N \l_tmpa_int
+    \cs_set:Nn \dbshow_sort_single: {
+      \int_incr:N \l_tmpa_int
+      \str_set:Nx \l_tmpa_str
+        { \clist_item:cn { g__dbshow_sort_#3_#1 } { \l_tmpa_int } }
+      \str_if_in:NnTF \l_tmpa_str { * } {
+        \exp_after:wN \dbshow_sort_parse_star:w \l_tmpa_str
+      }
+      {
+        \tl_set:Nx \l_op_same { < }
+        \tl_set:Nx \l_op_swap { > }
+      }
+      \exp_args:NnV \dbshow_check_attr:nn { #1 } \l_tmpa_str
+
+      \cs_set_eq:Nc \l_tmpa_tl { g__dbshow_data_#1_\l_tmpa_str _##1 }
+      \cs_set_eq:Nc \l_tmpb_tl { g__dbshow_data_#1_\l_tmpa_str _##2 }
+
+      \prop_get:cVN { g__dbshow_type_map_#1 } \l_tmpa_str \l_tmp_type
+      \clist_if_in:nVF { str, int, date, fp  } \l_tmp_type {
+        \msg_error:nnx { dbshow } { unsupported-sort-type } { \l_tmp_type }
+      }
+      \str_if_eq:eeT { \l_tmp_type } { date }
+        { \str_set:Nn \l_tmp_type { str } }
+      \cs_set_eq:Nc \dbshow_compare { \l_tmp_type _compare:nNnTF }
+
+      \exp_args:NnV
+      \dbshow_compare { \l_tmpa_tl } \l_op_same { \l_tmpb_tl }
+        { \sort_return_same: }
+      {
+        \exp_args:NnV
+        \dbshow_compare { \l_tmpa_tl } \l_op_swap { \l_tmpb_tl }
+          { \sort_return_swapped: }
+        {
+          \int_compare:nTF { \l_tmpa_int = \l_tmpb_int }
+            { \sort_return_same: }
+            { \dbshow_sort_single: }
+        }
+      }
+    }
+    \dbshow_sort_single:
+  }
+}
+
+% #1 style #2 database #3 filter
+\cs_new_protected:Nn \dbshow_init_iterator:nnn {
+  \tl_set:Nn \dbDatabase { #2 }
+  \tl_set:Nx \dbFilterName { #3 }
+  \tl_set_eq:Nc \dbFilterInfo { g__dbshow_filter_info_#2_#3 }
+
+  \clist_clear_new:N \l_index
+  %% run filters
+  % ##1 index
+  \cs_set:Nn \dbshow_filter:n {
+    \seq_if_exist:cTF { g__dbshow_filter_run_seq_#2_#3 } {
+      \seq_map_inline:cn { g__dbshow_filter_run_seq_#2_#3 } {
+        \use:c { ####1 } { ##1 }
+      }
+      \exp_args:Nv
+      \bool_if:nT { g__dbshow_filter_bool_tl_#2_#3 }
+        { \clist_put_right:Nn \l_index { ##1 } }
+    } { \clist_put_right:Nn \l_index { ##1 } }
+  }
+  \int_step_function:nN { \dbshow_get_counter:n { #2 } } \dbshow_filter:n
+  \clist_if_empty:cF { g__dbshow_sort_#1_#2 }
+    { \dbshow_sort:nNn { #2 } \l_index { #1 } }
+
+  % ##1 index
+  \cs_set:Nn \dbshow_iter:n {
+    % ####1 attr
+    \cs_set:Npn \dbuse ####1 {
+      \dbshow_check_attr:nn { #2 } { ####1 }
+      \clist_set_eq:Nc \l_style_sep_clist
+        { g__dbshow_style_sep_#1_#2_####1 }
+      \tl_set_eq:Nc \l_style_item_before_code
+        { g__dbshow_style_item_before_#1_#2_####1 }
+      \tl_set_eq:Nc \l_style_item_after_code
+        { g__dbshow_style_item_after_#1_#2_####1 }
+      \tl_set:Nn \dbIndex { ##1 }
+
+      \prop_get:cnN { g__dbshow_type_map_#2 } { ####1 } \l_tmp_type
+      % \tl_show:N \l_tmp_type
+      \str_if_eq:eeT { \l_tmp_type } { date }
+        { \tl_set:Nn \l_tmp_type { str } }
+      \prg_set_conditional:Nnn \dbshow_item_if_empty: { T, F, TF } {
+        \use:c { \l_tmp_type _if_empty:cTF }
+          { g__dbshow_data_#2_####1_##1 }
+          { \prg_return_true: }
+          { \prg_return_false: }
+      }
+      \cs_set_eq:NN \dbItemIfEmptyT\dbshow_item_if_empty:T
+      \cs_set_eq:NN \dbItemIfEmptyF\dbshow_item_if_empty:F
+      \cs_set_eq:NN \dbItemIfEmptyTF\dbshow_item_if_empty:TF
+
+      \tl_use:c { g__dbshow_style_before_#1_#2_####1 }
+      \dbshow_use_data:nnn { #2 } { ####1 } { ##1 }
+      \tl_use:c { g__dbshow_style_after_#1_#2_####1 }
+    }
+    \tl_use:c { g__dbshow_style_database_item_#1_#2 }
+  }
+  \prg_set_conditional:Nnn \dbshow_if_empty: { T, F, TF } {
+    \clist_if_empty:NTF \l_index
+      { \prg_return_true: }
+      { \prg_return_false: }
+  }
+  \cs_set_eq:NN \dbIfEmptyT\dbshow_if_empty:T
+  \cs_set_eq:NN \dbIfEmptyF\dbshow_if_empty:F
+  \cs_set_eq:NN \dbIfEmptyTF\dbshow_if_empty:TF
+
+  \tl_use:c { g__dbshow_style_before_#1_#2 }
+  \clist_map_function:NN \l_index \dbshow_iter:n
+  \tl_use:c { g__dbshow_style_after_#1_#2 }
+}
+
+% #1 style #2 database
+\NewDocumentCommand { \dbshow } { m m } {
+  \dbshow_check_database:n { #2 }
+  \tl_set_eq:Nc \l_dbshow_filter { g__dbshow_filter_#1_#2 }
+  \dbshow_check_filter:nn  { #2 } { \l_dbshow_filter }
+  \dbshow_init_iterator:nnn { #1 } { #2 } { \l_dbshow_filter }
+}
+
+\endinput


Property changes on: trunk/Master/texmf-dist/tex/latex/dbshow/dbshow.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check	2022-01-06 00:21:08 UTC (rev 61502)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check	2022-01-06 00:21:44 UTC (rev 61503)
@@ -243,7 +243,7 @@
     datetime2-serbian datetime2-slovak datetime2-slovene
     datetime2-spanish datetime2-swedish datetime2-turkish datetime2-ukrainian
     datetime2-usorbian datetime2-welsh
-    dblfloatfix dccpaper dcpic
+    dblfloatfix dbshow dccpaper dcpic
     ddphonism
     de-macro debate decimal decision-table decorule dehyph dehyph-exptl
     dejavu dejavu-otf

Modified: trunk/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc	2022-01-06 00:21:08 UTC (rev 61502)
+++ trunk/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc	2022-01-06 00:21:44 UTC (rev 61503)
@@ -320,6 +320,7 @@
 depend datetime2-usorbian
 depend datetime2-welsh
 depend dblfloatfix
+depend dbshow
 depend debate
 depend decimal
 depend decorule

Added: trunk/Master/tlpkg/tlpsrc/dbshow.tlpsrc
===================================================================


More information about the tex-live-commits mailing list.