blob: 19a391d3dccdec3aa174b42dbc9261536815ae2e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
%%
%% This is file `multilang-tags.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% multilang.dtx (with options: `pkgtags')
%%
%% Copyright (C) 2016-2018 by Richard Grewe <r-g+tex@posteo.net>
%%
%% This file may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.2 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.2 or later is part of all distributions of LaTeX version
%% 1999/12/01 or later.
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{multilang-tags}[2018/11/02 v0.9b Filtering of multilingual macros by tags]
\newcommand\SetTagFilter[2][accept]{%
\kcvml@parsepolicy{kcvml@@tagfilter}{#1}{#2}}
\newcommand\kcvml@@tagfilter{}
\newcommand\DefineTagFilter[3]{%
\kcvml@parsepolicy{kcvml@filter@@#1}{#2}{#3}}
\newcommand\UseTagFilter[1]{%
\letcs\kcvml@@tagfilter{kcvml@filter@@#1}}
\newcommand\kcvml@parsepolicy[3]{%
\bgroup
\def\kcvml@@tmptagfilter{}%
\pgfqkeys{kcvml/tagfilter}{#3,default/#2}%
\edef\do{\egroup
\unexpanded{\csdef{#1}}{\expandonce{\kcvml@@tmptagfilter}}}%
\do}
\pgfqkeys{kcvml/tagfilter}{%
accept/.code={\kcvml@appendrule{#1}{\boolfalse}{\booltrue}},
deny/.code ={\kcvml@appendrule{#1}{\booltrue}{\boolfalse}},
default/accept/.code n args={0}{\appto\kcvml@@tmptagfilter{%
\kcvml@applydefault{\boolfalse}}},
default/deny/.code n args={0}{\appto\kcvml@@tmptagfilter{%
\kcvml@applydefault{\booltrue}}},
}
\newcommand\kcvml@appendrule[3]{%
\bgroup
\def\kcvml@@ruletags{}%
\forcsvlist{\listadd{\kcvml@@ruletags}}{#1}%
\expandafter\egroup
\expandafter\listadd\expandafter\kcvml@@tmptagfilter\expandafter{%
\expandafter\kcvml@applyrule\expandafter{\kcvml@@ruletags}{#2}{#3}}}
\appto\multilang@hook@processargs{%
\ifbool{multilang@@disablable}%
{\eappto{\multilang@@keys}{%
\noexpand\pgfqkeys{\multilang@@cekey}{%
tags/.code={\noexpand\kcvml@applyfilter{##1}}}}}
{}}
\newcommand\kcvml@applyfilter[1]{%
\ifbool{multilang@cmd@@disabled}{}{%
\boolfalse{kcvml@@match}%
\def\do##1{%
##1{#1}%
\ifbool{kcvml@@match}{\listbreak}{}}%
\dolistloop{\kcvml@@tagfilter}}}
\newbool{kcvml@@match}
\newcommand\kcvml@applyrule[4]{%
\forcsvlist{\kcvml@applyrule@i{#1}{#2}{#3}}{#4}}
\newcommand\kcvml@applyrule@i[4]{%
\if !\@car#4\@nil
\expandafter\kcvml@applyrule@ii\expandafter{\@cdr#4\@nil}{#1}{#3}%
\else
\kcvml@applyrule@ii{#4}{#1}{#2}\fi}
\newcommand\kcvml@applyrule@ii[3]{%
\ifinlist{#1}{\empty #2}%
{#3{multilang@cmd@@disabled}\booltrue{kcvml@@match}}{}}
\newcommand\kcvml@applydefault[2]{%
#1{multilang@cmd@@disabled}}
\endinput
%%
%% End of file `multilang-tags.sty'.
|