summaryrefslogtreecommitdiff
path: root/macros
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-01-19 03:01:05 +0000
committerNorbert Preining <norbert@preining.info>2022-01-19 03:01:05 +0000
commit67acf92f90956827364ebe689dbdc659c3d402e3 (patch)
tree6168f960e27b9d6e20b3fad98f62ade76aab76e0 /macros
parent42225b2641eab592f67f238c364b237ee036bf0a (diff)
CTAN sync 202201190301
Diffstat (limited to 'macros')
-rw-r--r--macros/latex/contrib/biblatex2bibitem/biblatex2bibitem.sty7
-rw-r--r--macros/latex/contrib/chemmacros/README2
-rw-r--r--macros/latex/contrib/chemmacros/chemmacros-manual.pdfbin1014895 -> 998610 bytes
-rw-r--r--macros/latex/contrib/chemmacros/chemmacros-manual.tex10
-rw-r--r--macros/latex/contrib/chemmacros/chemmacros.sty10
-rw-r--r--macros/latex/contrib/easybook/easybook.dtx37
-rw-r--r--macros/latex/contrib/easybook/easybook.pdfbin595806 -> 595785 bytes
-rw-r--r--macros/latex/contrib/easybook/easybook.tex4
-rw-r--r--macros/latex/contrib/kanbun/kanbun-en.pdf (renamed from macros/latex/contrib/kanbun/kanbun.pdf)bin376249 -> 403013 bytes
-rw-r--r--macros/latex/contrib/kanbun/kanbun-en.tex3
-rw-r--r--macros/latex/contrib/kanbun/kanbun-example.pdfbin45616 -> 60831 bytes
-rw-r--r--macros/latex/contrib/kanbun/kanbun-example.tex2
-rw-r--r--macros/latex/contrib/kanbun/kanbun-ja.pdfbin0 -> 463363 bytes
-rw-r--r--macros/latex/contrib/kanbun/kanbun-ja.tex3
-rw-r--r--macros/latex/contrib/kanbun/kanbun.sty12
-rw-r--r--macros/latex/contrib/kanbun/kanbun.tex242
-rw-r--r--macros/latex/contrib/siunitx/CHANGELOG.md14
-rw-r--r--macros/latex/contrib/siunitx/siunitx-code.pdfbin607833 -> 608018 bytes
-rw-r--r--macros/latex/contrib/siunitx/siunitx-locale.dtx8
-rw-r--r--macros/latex/contrib/siunitx/siunitx-symbol.dtx6
-rw-r--r--macros/latex/contrib/siunitx/siunitx-unit.dtx4
-rw-r--r--macros/latex/contrib/siunitx/siunitx.dtx13
-rw-r--r--macros/latex/contrib/siunitx/siunitx.pdfbin638335 -> 638357 bytes
-rw-r--r--macros/latex/contrib/siunitx/siunitx.tex3
-rw-r--r--macros/luatex/latex/autopuncitems/README.md4
-rw-r--r--macros/luatex/latex/autopuncitems/autopuncitems.lua4
-rw-r--r--macros/luatex/latex/autopuncitems/autopuncitems.pdfbin35326 -> 41875 bytes
-rw-r--r--macros/luatex/latex/autopuncitems/autopuncitems.sty40
-rw-r--r--macros/luatex/latex/autopuncitems/autopuncitems.tex20
-rw-r--r--macros/luatex/latex/yamlvars/README.md6
-rw-r--r--macros/luatex/latex/yamlvars/YAMLvars.lua57
-rw-r--r--macros/luatex/latex/yamlvars/YAMLvars.pdfbin46890 -> 69229 bytes
-rw-r--r--macros/luatex/latex/yamlvars/YAMLvars.sty16
-rw-r--r--macros/luatex/latex/yamlvars/YAMLvars.tex91
-rw-r--r--macros/luatex/latex/yamlvars/tinyyaml.lua816
35 files changed, 419 insertions, 1015 deletions
diff --git a/macros/latex/contrib/biblatex2bibitem/biblatex2bibitem.sty b/macros/latex/contrib/biblatex2bibitem/biblatex2bibitem.sty
index 1099f7728c..72b5cde68a 100644
--- a/macros/latex/contrib/biblatex2bibitem/biblatex2bibitem.sty
+++ b/macros/latex/contrib/biblatex2bibitem/biblatex2bibitem.sty
@@ -10,7 +10,7 @@
%
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{biblatex2bibitem}
- [2021/10/26 v0.2.1 LaTeX package to convert biblatex-generated bibliography to bibitem commands]
+ [2022/01/17 v0.2.2 LaTeX package to convert biblatex-generated bibliography to bibitem commands]
\RequirePackage{biblatex}
@@ -30,6 +30,11 @@
\hyphenpenalty=10000
\exhyphenpenalty=10000
\raggedright
+ % Ignore curly braces when putting dots to avoid
+ % \emph{Banach) \emph{S.}.
+ \sfcode`\{=\z@
+ \sfcode`\}=\z@
+ %
\renewcommand*{\&}{\textbackslash \symbol{38}}%
\ifcsname mkbibsc\endcsname% Sometimes it is not defined
\renewcommand*{\mkbibsc}[1]{\textbackslash textsc\{##1\}}%
diff --git a/macros/latex/contrib/chemmacros/README b/macros/latex/contrib/chemmacros/README
index ceda07d4e3..fa7047a4a3 100644
--- a/macros/latex/contrib/chemmacros/README
+++ b/macros/latex/contrib/chemmacros/README
@@ -1,5 +1,5 @@
--------------------------------------------------------------------------
-the CHEMMACROS package v6.0 2022/01/16
+the CHEMMACROS package v6.0a 2022/01/18
comprehensive support for typesetting chemistry documents
diff --git a/macros/latex/contrib/chemmacros/chemmacros-manual.pdf b/macros/latex/contrib/chemmacros/chemmacros-manual.pdf
index d1edf60aac..516e7cf6f2 100644
--- a/macros/latex/contrib/chemmacros/chemmacros-manual.pdf
+++ b/macros/latex/contrib/chemmacros/chemmacros-manual.pdf
Binary files differ
diff --git a/macros/latex/contrib/chemmacros/chemmacros-manual.tex b/macros/latex/contrib/chemmacros/chemmacros-manual.tex
index d3cbb31d96..3504f8cfa8 100644
--- a/macros/latex/contrib/chemmacros/chemmacros-manual.tex
+++ b/macros/latex/contrib/chemmacros/chemmacros-manual.tex
@@ -1,5 +1,5 @@
-% !arara: pdflatex: { interaction: nonstopmode }
-% !arara: biber
+% arara: pdflatex: { interaction: nonstopmode }
+% arara: biber
% arara: pdflatex: { interaction: nonstopmode }
% arara: pdflatex: { interaction: nonstopmode }
% --------------------------------------------------------------------------
@@ -2160,7 +2160,7 @@ Using the \cs{reactants} command inside of section headings or captions can
mess up the order in which the molecules are numbered, especially when also
using a table of contents and/or a list of figures/tables. To prevent this,
the \module{reactants} module offers the \code{+} suffixed variant of
-\cs{reactants}, comparably to \pkg{chemnum}'s \cs{cmpd+} command.
+\cs{reactants}, comparable to \pkg{chemnum}'s \cs{cmpd+} command.
\begin{commands}
\command{reactant+}[\oarg{data and units}\marg{ID}]
@@ -2174,9 +2174,9 @@ bookmarks, you might want to use the optional \option{bookmark} property of
displayed inside of the \ac{pdf} bookmarks. To later use such a predefined
solvent or reactant, use one of the following three commands, that are defined
analogously to \pkg{chemnum}`s \cs{cmpdplain}. All three commands also exist
-in the upper case variant (\cs{Reactantplain}, \cs{Sumbainreactantplain} and
+in the upper case variant (\cs{Reactantplain}, \cs{Submainreactantplain} and
\cs{Solventplain}) which can be used to display the upper case version of a
-reactant or solvent's name. he upper case version of the name must be declared
+reactant or solvent's name. The upper case version of the name must be declared
previously through \cs{DeclareChemReactant}'s \option{upper-name} and
\option{upper-bookmark} options.
diff --git a/macros/latex/contrib/chemmacros/chemmacros.sty b/macros/latex/contrib/chemmacros/chemmacros.sty
index 5fcbd0a318..c9a913e922 100644
--- a/macros/latex/contrib/chemmacros/chemmacros.sty
+++ b/macros/latex/contrib/chemmacros/chemmacros.sty
@@ -31,10 +31,10 @@
% --------------------------------------------------------------------------
% package information:
-\tl_const:Nn \c_chemmacros_date_tl {2022/01/16}
+\tl_const:Nn \c_chemmacros_date_tl {2022/01/18}
\tl_const:Nn \c_chemmacros_version_major_number_tl {6}
\tl_const:Nn \c_chemmacros_version_minor_number_tl {0}
-\tl_const:Nn \c_chemmacros_version_subrelease_tl {}
+\tl_const:Nn \c_chemmacros_version_subrelease_tl {a}
\tl_const:Nx \c_chemmacros_version_number_tl
{
\c_chemmacros_version_major_number_tl .
@@ -139,7 +139,7 @@
minimal .bool_set:N = \l__chemmacros_minimal_bool ,
minimal .initial:n = false ,
modules .code:n =
- \clist_if_in:NF \l_chemmacros_modules_clist
+ \clist_if_in:NnF \l_chemmacros_modules_clist {#1}
{ \clist_put_right:Nn \l_chemmacros_modules_clist {#1} } ,
unknown .code:n = \__chemmacros_loadtime_warning:n {unknown-option}
}
@@ -917,10 +917,12 @@
% --------------------------------------------------------------------------
\ChemModuleEnd
-\ChemModule{lang}{2020/11/29 language settings for chemmacros}
+\ChemModule{lang}{2022/01/18 language settings for chemmacros}
\RequirePackage{translations}
+\hook_gset_rule:nnnn {begindocument/before} {translations} {before} {chemmacros}
+
\msg_new:nnn {chemmacros} {language-not-defined}
{
You~ chose~ the~ language~ `#1'~ which~ is~ not~ defined~ by~ chemmacros.~
diff --git a/macros/latex/contrib/easybook/easybook.dtx b/macros/latex/contrib/easybook/easybook.dtx
index 578d585706..aefe66fb20 100644
--- a/macros/latex/contrib/easybook/easybook.dtx
+++ b/macros/latex/contrib/easybook/easybook.dtx
@@ -15,7 +15,7 @@
%<*class>
\NeedsTeXFormat{LaTeX2e}[2020/10/01]
\RequirePackage{l3keys2e}
-\ProvidesExplClass{easybook}{2022/01/16}{1.46E}
+\ProvidesExplClass{easybook}{2022/01/18}{1.46P}
{Typeset Chinese theses or books}
\bool_set_false:N \l__eb_compile_draft_bool
@@ -305,7 +305,7 @@
%<*package>
\NeedsTeXFormat{LaTeX2e}[2020/10/01]
\RequirePackage{l3keys2e,etoolbox}
-\ProvidesExplPackage{easybase}{2022/01/16}{1.46E}
+\ProvidesExplPackage{easybase}{2022/01/18}{1.46P}
{Typeset Chinese theses or books}
\cs_generate_variant:Nn \dim_set:Nn { NV }
@@ -747,7 +747,7 @@
{
fntnumwith .choices:nn =
{ part,page,chapter }
- { \tl_set:Nn \l__eb_fnt_counter_parent_value_tl {#1} },
+ { \tl_set:Nn \l__eb_fnt_parent_counter_tl {#1} },
fntnumwith .value_required:n = true,
fntnumwith .initial:n = chapter
}
@@ -929,7 +929,7 @@
\dim_set:Nn \footnotesep { \dim_use:N \box_ht:N \strutbox }
\bool_if:NT \l__eb_chap_counter_withpart_bool
{ \counterwithin*{chapter}{part} }
- \str_case:VnT \l__eb_fnt_counter_parent_value_tl
+ \str_case:VnT \l__eb_fnt_parent_counter_tl
{
{ part } { \counterwithin*{footnote}{part} }
{ page } { \counterwithin*{footnote}{page} }
@@ -2212,8 +2212,8 @@
numberstyle = \footnotesize,
basewidth = 0.5em,
columns = flexible,
- aboveskip = 1.5ex plus .2ex minus .1ex,
- belowskip = 1.5ex plus .2ex minus .1ex,
+ aboveskip = 0.5\baselineskip,
+ belowskip = 0.5\baselineskip,
abovecaptionskip = -1ex,
belowcaptionskip = 1.5ex,
keepspaces = true,
@@ -2433,7 +2433,7 @@
}
%</package>
%<*tcolorbox>
-\ProvidesExplFile{eb-tcolorbox.cfg}{2022/01/16}{1.46E}
+\ProvidesExplFile{eb-tcolorbox.cfg}{2022/01/18}{1.46P}
{Customization of tcolorbox for easybook}
\cs_set_protected:Npn \addtotcbstyle #1#2
@@ -2446,8 +2446,8 @@
\deftcbstyle{tc-theorem}
{
- enhanced~jigsaw,pad~at~break* = 3pt,
- colframe = ctex@emph,
+ enhanced~jigsaw,
+ frame~hidden,boxrule = 0pt,
beforeafter~skip = 0.5\baselineskip,
left = 8pt,right = 8pt,
top = 0.5\baselineskip,bottom = 0.5\baselineskip,
@@ -2455,7 +2455,7 @@
}
\deftcbstyle{tc-easybox}
{
- enhanced~jigsaw,pad~at~break* = 3pt,
+ enhanced~jigsaw,
center~title,
left = 8pt,right = 8pt,
coltitle = black,colframe = black,
@@ -2467,10 +2467,9 @@
}
\deftcbstyle{tc-ebparbox}
{
- frame~hidden,
- enhanced~jigsaw,pad~at~break* = 3pt,
- boxrule = 0pt,
- left = 8pt,
+ enhanced~jigsaw,
+ frame~hidden,boxrule = 0pt,
+ left = 10pt,
middle = 0.5\baselineskip,bottomtitle = 0.5\baselineskip,
beforeafter~skip = 0.5\baselineskip
}
@@ -2484,10 +2483,12 @@
\tcbset
{
breakable,
+ pad~at~break* = 3pt,
sharpish~corners,
- fonttitle = \sffamily,
- boxsep = 0pt,
- boxrule = 0.5pt
+ fonttitle = \sffamily,
+ colframe = black,
+ boxsep = 0pt,
+ boxrule = 0.5pt
}
\DeclareTColorBox{easybox}{sO{PaleGoldenrod}d()O{}}
@@ -2497,7 +2498,7 @@
colback = #2,colbacktitle = #2,
tc-easybox,#4
}
-\DeclareTColorBox{ebparbox}{sO{DarkSlateBlue}d()O{}}
+\DeclareTColorBox{ebparbox}{sO{RoyalBlue}d()O{}}
{
borderline~west = {3pt}{0pt}{#2},
IfBooleanTF = {#1}
diff --git a/macros/latex/contrib/easybook/easybook.pdf b/macros/latex/contrib/easybook/easybook.pdf
index 633011029a..4fc0e21d61 100644
--- a/macros/latex/contrib/easybook/easybook.pdf
+++ b/macros/latex/contrib/easybook/easybook.pdf
Binary files differ
diff --git a/macros/latex/contrib/easybook/easybook.tex b/macros/latex/contrib/easybook/easybook.tex
index 865f7bf26f..42dd933e04 100644
--- a/macros/latex/contrib/easybook/easybook.tex
+++ b/macros/latex/contrib/easybook/easybook.tex
@@ -21,8 +21,8 @@
name = easybook,
color-scheme = blue,
title = EASYBOOK 使用手册,
- version = v1.46E,
- date = 2022/01/16,
+ version = v1.46P,
+ date = 2022/01/18,
authors = 瞿毅,
info = 排版简体中文学位论文和书籍,
email = q1jx@foxmail.com,
diff --git a/macros/latex/contrib/kanbun/kanbun.pdf b/macros/latex/contrib/kanbun/kanbun-en.pdf
index a3b0cbdd30..0158947906 100644
--- a/macros/latex/contrib/kanbun/kanbun.pdf
+++ b/macros/latex/contrib/kanbun/kanbun-en.pdf
Binary files differ
diff --git a/macros/latex/contrib/kanbun/kanbun-en.tex b/macros/latex/contrib/kanbun/kanbun-en.tex
new file mode 100644
index 0000000000..cc94ac98e2
--- /dev/null
+++ b/macros/latex/contrib/kanbun/kanbun-en.tex
@@ -0,0 +1,3 @@
+\newcommand\en[1]{#1}
+\newcommand\ja[1]{}
+\input{kanbun.tex} \ No newline at end of file
diff --git a/macros/latex/contrib/kanbun/kanbun-example.pdf b/macros/latex/contrib/kanbun/kanbun-example.pdf
index f437066ba9..0e8d472dd5 100644
--- a/macros/latex/contrib/kanbun/kanbun-example.pdf
+++ b/macros/latex/contrib/kanbun/kanbun-example.pdf
Binary files differ
diff --git a/macros/latex/contrib/kanbun/kanbun-example.tex b/macros/latex/contrib/kanbun/kanbun-example.tex
index 0ae963112f..014ae36679 100644
--- a/macros/latex/contrib/kanbun/kanbun-example.tex
+++ b/macros/latex/contrib/kanbun/kanbun-example.tex
@@ -19,7 +19,7 @@
\documentclass{ltjtarticle}
\usepackage[match]{luatexja-fontspec}
-\setmainjfont{Kozuka Mincho Pr6N}
+\setmainjfont{FOT-TsukuBOldMin Pr6N}
\newlength\myzw
\setlength\myzw{2.25\zw}
diff --git a/macros/latex/contrib/kanbun/kanbun-ja.pdf b/macros/latex/contrib/kanbun/kanbun-ja.pdf
new file mode 100644
index 0000000000..624e1ba592
--- /dev/null
+++ b/macros/latex/contrib/kanbun/kanbun-ja.pdf
Binary files differ
diff --git a/macros/latex/contrib/kanbun/kanbun-ja.tex b/macros/latex/contrib/kanbun/kanbun-ja.tex
new file mode 100644
index 0000000000..1b13dcb6c7
--- /dev/null
+++ b/macros/latex/contrib/kanbun/kanbun-ja.tex
@@ -0,0 +1,3 @@
+\newcommand\en[1]{}
+\newcommand\ja[1]{#1}
+\input{kanbun.tex} \ No newline at end of file
diff --git a/macros/latex/contrib/kanbun/kanbun.sty b/macros/latex/contrib/kanbun/kanbun.sty
index 70994ab463..f730245e09 100644
--- a/macros/latex/contrib/kanbun/kanbun.sty
+++ b/macros/latex/contrib/kanbun/kanbun.sty
@@ -18,7 +18,7 @@
\NeedsTeXFormat{LaTeX2e}[2021/06/01]
\RequirePackage{expl3,xparse,l3keys2e,ifluatex}
\ProvidesExplClass{kanbun}
- {2022/01/15} {1.0} {漢文の訓点文の組版}
+ {2022/01/17} {1.1} {漢文の訓点文の組版}
\ExplSyntaxOn
\cs_generate_variant:Nn \str_if_eq:nnTF { V }
@@ -51,8 +51,8 @@
, yokoaki .initial:n = { \kanbun_scale }
, tateaki .tl_set:N = \kanbun_tateaki
, tateaki .initial:n = { 2 }
- , okuriprotrusion .tl_set:N = \kanbun_okuriprotrusion
- , okuriprotrusion .initial:n = { 1 }
+ , okuriintrusion .tl_set:N = \kanbun_okuriintrusion
+ , okuriintrusion .initial:n = { 1 }
, kumi .tl_set:N = \kanbun_kumi
, kumi .initial:n = { aki }
, aki .code:n = \keys_set:nn { kanbun } { kumi = aki }
@@ -185,8 +185,8 @@
\NewDocumentCommand { \furiokuri } { m m }
{
\settowidth{\kanbun_furilen}{#1}
- \ifdim\kanbun_furilen < \fp_eval:n {1-\kanbun_okuriprotrusion/\kanbun_scale}\kanbun_zw
- \makebox[\fp_eval:n {1-\kanbun_okuriprotrusion/\kanbun_scale}\kanbun_zw][l]{#1}
+ \ifdim\kanbun_furilen < \fp_eval:n {1-\kanbun_okuriintrusion/\kanbun_scale}\kanbun_zw
+ \makebox[\fp_eval:n {1-\kanbun_okuriintrusion/\kanbun_scale}\kanbun_zw][l]{#1}
\else
#1
\fi
@@ -235,7 +235,7 @@
{
\kanbun_rubyfontcmd
\kern \fp_eval:n { -(#1) }\kanbun_zw
- \makebox[\fp_eval:n { (#1) + 1 - \kanbun_okuriprotrusion/\kanbun_scale }\kanbun_zw][s]{#2}
+ \makebox[\fp_eval:n { (#1) + 1 - \kanbun_okuriintrusion/\kanbun_scale }\kanbun_zw][s]{#2}
#3
}
diff --git a/macros/latex/contrib/kanbun/kanbun.tex b/macros/latex/contrib/kanbun/kanbun.tex
index 02e4c0e918..2945b0505b 100644
--- a/macros/latex/contrib/kanbun/kanbun.tex
+++ b/macros/latex/contrib/kanbun/kanbun.tex
@@ -22,19 +22,27 @@
\def\@seccntformat#1{\protect\makebox[0pt][r]{\csname the#1\endcsname\hspace{\marglistsep}}}
\makeatother
-\usepackage{shortvrb}
-\MakeShortVerb{|}
+\usepackage{fancyvrb}
+\DefineShortVerb{\|}
\lstnewenvironment{example}[1][]
{\lstset{
- basicstyle=\ttfamily,
+ basicstyle=\ja{\linespread{1}}\ttfamily,
frame=single,
- columns=flexible,
+ columns=fullflexible,
language=[LaTeX]TeX,
- breaklines=true,
- postbreak=\mbox{\textcolor{spot}{$\hookrightarrow$}\space},
- % morekeywords={drawuntpoint,untpoint,linkuntpoints},
- % escapeinside={<@}{@>},
+ moretexcs={
+ Kanbun,
+ EndKanbun,
+ printkanbun,
+ printkanbuncode,
+ kanbunfont,
+ furiokuri,
+ multifuriokuri,
+ ExplSyntaxOn,
+ ExplSyntaxOff,
+ kanjiunit,
+ }
}}
{}
@@ -43,23 +51,40 @@
\ltjdefcharrange{11}{"2039-"203A}
\ltjsetparameter{jacharrange={-1, +2, +3, -4, -5, +6, +7, -8, +9, +10, -11}}
\usepackage[match]{luatexja-fontspec}
-\defaultfontfeatures{Numbers=OldStyle, Scale=MatchLowercase}
-\defaultjfontfeatures{Scale=MatchLowercase}
-\setmainjfont{Kozuka Mincho Pr6N}
+\en{\defaultfontfeatures{Numbers=OldStyle, Scale=MatchLowercase}}
+\ja{\defaultfontfeatures{Scale=MatchLowercase}}
+\defaultjfontfeatures{Scale=MatchLowercase, YokoFeatures={JFM=ja_JP/{kaiming,prop}, RawFeature={+pkna,+kern}}}
+\setmainjfont[BoldFont={*-D}]{FOT-TsukuMin Pr6N}
\setsansjfont{Sarasa Mono J}
-\setmonojfont[YokoFeatures={JFM=prop}]{Sarasa Mono J}
+\setmonojfont[Scale=MatchLowercase, YokoFeatures={JFM=prop, RawFeature={+kern}}]{Sarasa Mono J}
\setmainfont{Minion Pro}
\setsansfont{Myriad Pro}
\setmonofont{Sarasa Mono J}
-\newfontfamily{\kanbunfamily}{Kozuka Mincho Pr6N}
+
+\ja{
+ \parindent=1\zw
+ \renewcommand{\baselinestretch}{1.2}
+}
\usepackage{luatexja-ruby}
- \ltjsetruby{fontcmd=\addjfontfeature{RawFeature={+ruby}}}
+ \ltjsetruby{
+ fontcmd=\addjfontfeature{
+ YokoFeatures={RawFeature={-pkna,+ruby}},
+ TateFeatures={RawFeature={-pkna,+ruby}},
+ },
+ mode=7,
+ }
-\usepackage{kanbun}
+\usepackage[
+ rubyfontcmd=\addjfontfeature{
+ YokoFeatures={RawFeature={-pkna,+ruby}},
+ TateFeatures={RawFeature={-pkna,+ruby}},
+ },
+]{kanbun}
\newcommand{\printkanbunblock}[2]{
{
\parindent=0pt
+ \ja{\linespread{1}}
\vspace*{1\zw}
\hfill
\vbox{
@@ -84,10 +109,19 @@
\Kanbun
以テ[二]羅(ら)蝶(てふ)ヲ[一]作ルガ[二]漢文訓読ヲ[一]用(ため)ノ包(ぱつけーぢ)
\EndKanbun
-\title{The \sty{kanbun} package}
+\title{\en{The \sty{kanbun} package}\ja{\sty{kanbun}パッケージ}}
\subtitle{\normalsize\normalfont\addjfontfeature{Scale=1}\printkanbun}
-\author{Yuanhao Chen (\ruby[rubysmash=true]{陳|元|鎬}{ちん|げん|こう})}
-\date{\scshape 15 january 2022, v1.0}
+\author{
+ \en{Yuanhao Chen (\ruby[rubysmash=true]{陳|元|鎬}{ちん|げん|こう})}
+ \ja{
+ \ruby[rubysmash=true]{陳|元|鎬}{ちん|げん|こう} (Yuanhao Chen)
+ \footnote{日本人ではないので、日本語ネイティヴの方がいらっしゃればマニュアルを書き直して下さると嬉しい。}
+ }
+}
+\date{
+ \en{\scshape 17 january 2022, v1.1}
+ \ja{2022年1月17日, v1.1}
+}
\begin{document}
@@ -97,32 +131,21 @@
\tl_set:Nn \kanbun_kumi { beta }
\ExplSyntaxOff
\maketitle
+\ja{\renewcommand{\contentsname}{目次}}
\tableofcontents
-\section{Introduction}
-The \sty{kanbun} package, like other \emph{kanbun-kundoku} (漢文訓読) \LaTeX{} packages (such as \sty{gckanbun}), allows users to manually input macros for elements in a \emph{kanbun-kundoku} paragraph.
+\section{\en{Introduction}\ja{はじめに}}
+\en{The \sty{kanbun} package, like other \emph{kanbun-kundoku} (漢文訓読) \LaTeX{} packages (such as \sty{gckanbun}), allows users to manually input macros for elements in a \emph{kanbun-kundoku} paragraph.}
+\ja{\sty{kanbun}パッケージでは他の漢文訓読の\LaTeX{}パッケージ(例えば \sty{gckanbun})と同じく、手動で漢文訓読の各要素に対応するマクロを入力できる。}
-More importantly, it accepts plain text input in the ``\emph{kanbun} annotation'' form when used with \LuaLaTeX, which allows typesetting \emph{kanbun-kundoku} paragraphs efficiently\footnote{The idea comes from \href{https://phesoca.com/kanbun-html/}{漢文\textsc{html}} by UntPhesoca, which is a JavaScript and \textsc{css} implementation.}.
+\en{More importantly, it accepts input with light markup in the ``\emph{kanbun} annotation'' form when used with \LuaLaTeX, which allows typesetting \emph{kanbun-kundoku} paragraphs efficiently\footnote{The idea comes from \href{https://phesoca.com/kanbun-html/}{漢文\textsc{html}} by UntPhesoca, which is a JavaScript and \textsc{css} implementation.}.}
+\ja{更に重要なことには、 \LuaLaTeX{}で実行すれば、軽量マークアップの「漢文アノテーション」で容易く効率的に漢文訓読を組版することが可能となっている\footnote{JavaScriptやCSSによって実行するUntPhesocaの \href{https://phesoca.com/kanbun-html/}{漢文HTML} が参考となっていた。}。}
-\section{Basic example with \LuaLaTeX}
-As seen in the following example, typesetting a \emph{kanbun-kundoku} paragraph with the \sty{kanbun} package requires only light annotations --- it automatically transforms the annotated plain text into \LaTeX{} macros through Lua, rather than having users type in macros themselves.
-
-\ExplSyntaxOn
-\tl_set:Nn \kanbun_tateaki { 1 }
-\tl_set:Nn \kanbun_kumi { aki }
-\ExplSyntaxOff
-\Kanbun
-月落チ烏啼キテ霜満ツ[レ]天ニ,
-江楓漁火対ス[二]愁眠ニ[一]。
-姑(こ)蘇(そ)城外ノ寒山寺,
-夜半ノ鐘声到ル[二]客船ニ[一]。
-\EndKanbun
-
-\penalty0
-\printkanbunblock{13}{\printkanbun}
-\vspace{-2\zw}
+\section{\en{Basic example with \LuaLaTeX}\ja{\LuaLaTeX{}での簡単な実例}}
+\en{As seen in the following example, typesetting a \emph{kanbun-kundoku} paragraph with the \sty{kanbun} package requires only light annotations --- it automatically transforms the annotated plain text into \LaTeX{} macros through Lua, rather than having users type in macros themselves.}
+\ja{次の実例のとおり、 \sty{kanbun}パッケージを使えばただの軽量なアノテーションで漢文訓読を組版できる。手動でマクロを入力するではなく、プログラムが自動的にアノテーションのあるプレーンテキストをLuaで処理して\LaTeX{}マクロに変更する。}
\begin{example}
\documentclass{ltjtarticle}
@@ -138,73 +161,109 @@ As seen in the following example, typesetting a \emph{kanbun-kundoku} paragraph
\end{document}
\end{example}
-Note that if you want to use this functionality, you have to run this document with \LuaLaTeX.
+\ExplSyntaxOn
+\tl_set:Nn \kanbun_tateaki { 1 }
+\tl_set:Nn \kanbun_kumi { aki }
+\ExplSyntaxOff
+\Kanbun
+月落チ烏啼キテ霜満ツ[レ]天ニ,
+江楓漁火対ス[二]愁眠ニ[一]。
+姑(こ)蘇(そ)城外ノ寒山寺,
+夜半ノ鐘声到ル[二]客船ニ[一]。
+\EndKanbun
+
+\allowbreak
+\printkanbunblock{13}{\printkanbun}
+\vspace{-1.5\zw}
+
+\en{Note that if you want to use this functionality, you have to run this document with \LuaLaTeX.}
+\ja{この機能を使う場合、必ず\LuaLaTeX{}で実行してください。}
-\section{Usage}
+\section{\en{Usage}\ja{使用方法}}
-\subsection{Package options}
-Load the package with
+\subsection{\en{Package options}\ja{パッケージのオプション}}
+\en{Load the package with}
+\ja{パッケージの読み込みは次のようにしてよい:}
+\nobreak
\begin{ltxsyntax}
- \cmditem{usepackage}\oprm{\sty{kanbun} options}|{kanbun}|
+ \cmditem{usepackage}\oprm{\en{\sty{kanbun} options}\ja{ \sty{kanbun}のオプション}}|{kanbun}|
\end{ltxsyntax}
-This package provides a variety of customisable features in \emph{kanbun-kundoku}.
+\en{This package provides a variety of customisable features in \emph{kanbun-kundoku}.}
+\ja{以下のオプションでさまざまな漢文訓読においてのパラメーターを設定できる。}
\begin{optionlist}
- \optitem[]{scale}{\prm{ratio}}
- Sets the ratio of the size of \emph{kanji} to that of ruby texts. Default: \verb|2|.
+ \optitem[]{scale}{\prm{\en{ratio}\ja{比}}}
+ \en{Sets the ratio of the size of \emph{kanji} to that of ruby texts. Default: \verb|2|.}
+ \ja{ルビ文字のサイズに対する漢字のサイズの割合を設定する。初期値: \verb|2|。}
- \optitem[]{fontcmd}{\prm{font command}}
- Sets the font command to use for \emph{kanji}. If \sty{luatexja-fontspec} is loaded, it is set default to \verb|\addjfontfeatures{RawFeature={+trad}}| to obtain traditional \emph{kanji} if applicable.
+ \SaveVerb{fontcmd}|\addjfontfeatures{RawFeature={+trad}}|
+ \optitem[]{fontcmd}{\prm{\en{font command}\ja{書体のコマンド}}}
+ \en{Sets the font command to use for \emph{kanji}. If \sty{luatexja-fontspec} is loaded, it is set default to \UseVerb{fontcmd} to obtain traditional \emph{kanji} if applicable.}
+ \ja{漢字の書体のコマンドを設定する。\sty{luatexja-fontspec}パッケージが読み込まれてある場合、 \UseVerb{fontcmd} に初期化されて、旧字体のグリフに変更する。}
- \optitem[]{rubyfontcmd}{\prm{font command}}
- Sets the font command to use for ruby texts. If \sty{luatexja-fontspec} is loaded, it is set default to \verb|\addjfontfeatures{RawFeature={+ruby}}| to obtain ruby glyphs when applicable.
+ \SaveVerb{rubyfontcmd}|\addjfontfeatures{RawFeature={+ruby}}|
+ \optitem[]{rubyfontcmd}{\prm{\en{font command}\ja{書体のコマンド}}}
+ \en{Sets the font command to use for ruby texts. If \sty{luatexja-fontspec} is loaded, it is set default to \UseVerb{rubyfontcmd} to obtain ruby glyphs when applicable.}
+ \ja{ルビ文字の書体のコマンドを設定する。\sty{luatexja-fontspec}パッケージが読み込まれてある場合、 \UseVerb{rubyfontcmd} に初期化されて、ルビグリフに変更する。}
- \optitem[]{unit}{\prm{length}}
- Sets the base size (size of \emph{kanji}). Default: \verb|\kanbun_zw|, which is initialised as \verb|1em|.
+ \SaveVerb{unit}|\kanbun_init_zw|
+ \optitem[]{unit}{\prm{\en{length}\ja{長さ}}}
+ \en{Sets the dimensions of \emph{kanji} (assuming it is a square). Default: \UseVerb{unit}, which is a length equal to \verb|1em|.}
+ \ja{(正方形だと仮定して)漢字の寸法を設定する。初期値: \UseVerb{unit} (\verb|1em| に等しい長さ)。}
- \optitem[]{yokoaki}{\prm{ratio}}
- Sets the horizontal space between \emph{kanji} with respect to the size of ruby texts. Default: \verb|2|.
+ \optitem[]{yokoaki}{\prm{\en{ratio}\ja{比}}}
+ \en{Sets the horizontal space between \emph{kanji} with respect to the size of ruby texts. Default: \verb|2|.}
+ \ja{ルビ文字のサイズに対するインテルの幅の割合を設定する。初期値: \verb|2|。}
- \optitem[]{tateaki}{\prm{ratio}}
- Sets the vertical space between \emph{kanji} with respect to the size of ruby texts. Default: \verb|2|.
+ \optitem[]{tateaki}{\prm{\en{ratio}\ja{比}}}
+ \en{Sets the vertical space between \emph{kanji} with respect to the size of ruby texts. Default: \verb|2|.}
+ \ja{ルビ文字のサイズに対する漢字間のアキ量の割合を設定する。初期値: \verb|2|。}
- \optitem[]{okuriprotrusion}{\prm{ratio}}
- Sets how much \emph{okurigana} should be vertically tucked into the space of \emph{kanji} with respect to the size of ruby texts, if that does not cause an overlap with \emph{furigana}. Default: \verb|1|.
+ \optitem[]{okuriintrusion}{\prm{\en{ratio}\ja{比}}}
+ \en{Sets the intrusion of \emph{okurigana} (how much \emph{okurigana} should be vertically tucked into the space of \emph{kanji}) with respect to the size of ruby texts, if that does not cause an overlap with \emph{furigana}. Default: \verb|1|.}
+ \ja{ルビ文字のサイズに対する送仮名\ruby[pre=0.5,post=1]{進入量}{イントルージョン}(送仮名を上に突かせて漢字に掛ける長さ)の割合を設定する。初期値: \verb|1|。}
\optitem[]{kumi}{\opt{aki}, \opt{beta}}
- Sets whether to use \emph{aki-gumi} (typeset with uniform inter-character spacing) or \emph{beta-gumi} (typeset with no inter-character space between adjacent character frames). Or simply call \opt{aki} or \opt{beta} without \opt{kumi=}. Default: \opt{aki}.
+ \en{Sets whether to use \emph{aki-gumi} (typeset with uniform inter-character spacing) or \emph{beta-gumi} (typeset with no inter-character space between adjacent character frames). Or simply call \opt{aki} or \opt{beta} without \opt{kumi=}. Default: \opt{aki}. }
+ \ja{アキ組を使うかベタ組を使うかを設定する。\opt{kumi=} を書かず、単に \opt{aki} か \opt{beta} かと書いてもよい。}
\end{optionlist}
-After initialising the options, you can still change the option values through \sty{exlp3} syntax, with a prefix \verb|\kanbun_| to option names. For example, to switch to \emph{beta-gumi}, you could use
+\SaveVerb{kanbunprefix}|\kanbun_|
+\en{After initialising the options, you can still change the option values through \sty{exlp3} syntax, with a prefix \UseVerb{kanbunprefix} to option names. For example, to switch to \emph{beta-gumi}, you could use}
+\ja{オプションを初期化する後でも、 \sty{exlp3} \ruby[pre=1]{構文}{シンタックス}でオプション名に \UseVerb{kanbunprefix} をプリフィックスして再アサインできる。例えば、ベタ組に再設定するには下記のコードを使う。}
\begin{example}
\ExplSyntaxOn
\tl_set:Nn \kanbun_kumi { beta }
\ExplSyntaxOff
\end{example}
-\subsection[Basic usage without \LuaLaTeX]{Basic usage without \LuaLaTeX{} (not recommended)}
-When not using the advanced \emph{kanbun}-annotation functionality, it is possible to typeset \emph{kanbun} with any engine with \textsc{cjk} support, such as using \XeLaTeX{} with the \sty{xeCJK} package, or using \upLaTeX{} with \sty{utarticle} or other appropriate class.
+\subsection[\en{Basic usage without \LuaLaTeX}\ja{\LuaLaTeX{}を使わない場合の基本使用}]{\en{Basic usage without \LuaLaTeX{} (not recommended)}\ja{\LuaLaTeX{}を使わない場合の基本使用(お薦めではない)}}
+\en{When not using the advanced \emph{kanbun}-annotation functionality, it is possible to typeset \emph{kanbun} with any engine with \textsc{cjk} support, such as using \XeLaTeX{} with the \sty{xeCJK} package, or using \upLaTeX{} with \sty{utarticle} or other appropriate class. }
+\ja{漢文アノテーションの機能を使わない場合、任意の CJK 支援のあるエンジンで漢文を組版できる。例えば\XeLaTeX{} を \sty{xeCJK} パッケージと一緒に使うか、 \upLaTeX{} を \sty{utarticle} クラス或いは他の適宜なクラスと一緒に使うか、どちらもよい。}
\begin{ltxsyntax}
- \cmditem{kanjiunit}\verb|{ |\cmd{furiokuri}\mprm{right furigana}\mprm{right okurigana}\verb| }|\vspace{-5pt}\\
- \mprm{left punctuation (e.g.~`「')}\\
- \mprm{kanji}\\
- \mprm{other punctuation}\\
- \mprm{kaeriten}\\
- \verb|{ |\cmd{furiokuri}\mprm{left furigana}\mprm{left okurigana}\verb| }|
+ \cmditem{kanjiunit}\verb|{ |\cmd{furiokuri}\mprm{\en{right furigana}\ja{右の振仮名}}\mprm{\en{right okurigana}\ja{右の送仮名}}\verb| }|\vspace{-5pt}\\
+ \mprm{\en{left (top) punctuation (e.g.~`「')}\ja{左(上)の句読点(“「”など)}}\\
+ \mprm{\en{kanji}\ja{漢字}}\\
+ \mprm{\en{other punctuation}\ja{他の句読点}}\\
+ \mprm{\en{kaeriten}\ja{返点}}\\
+ \verb|{ |\cmd{furiokuri}\mprm{\en{left furigana}\ja{左の振仮名}}\mprm{\en{left okurigana}\ja{左の送仮名}}\verb| }|
\cmditem{kanbunfont}
- Sets the font size of \emph{kanji}. Use when the \opt{unit} option is set different to the document's default font size.
+ \en{Sets the font size of \emph{kanji}. Use when the \opt{unit} option is set different to the document's default font size.}
+ \ja{漢字のサイズを設定する。\opt{unit} オプションと文書のデフォルト文字サイズが違う時に使う。}
- Use \cmd{multifuriokuri} instead of \cmd{furiokuri} if you are putting \emph{furigana} to multiple kanji.
+ \en{Use \cmd{multifuriokuri} instead of \cmd{furiokuri} if you are putting \emph{furigana} to multiple kanji.}
+ \ja{複数個の漢字に仮名を振れば、 \cmd{furiokuri} の代わりに \cmd{multifuriokuri} を使う。}
- \cmditem{multifuriokuri}\oprm{length by which {furigana} is raised}\mprm{furigana}\mprm{okurigana}
+ \cmditem{multifuriokuri}\oprm{\en{length by which ruby is raised}\ja{ルビ文字を上げる長さ}}\mprm{\en{furigana}\ja{振仮名}}\mprm{\en{okurigana}\ja{送仮名}}
\end{ltxsyntax}
-For example, the code
+\en{For example, the code}
+\ja{例えば、 \opt{tateaki} が \verb|1| に設定されている場合、下記のコードを使えば}
\begin{example}
% example text from https://phesoca.com/kanbun-html/
\kanbunfont
@@ -217,7 +276,8 @@ For example, the code
\kanjiunit{\furiokuri{}{ヲ}}{}{志}{。}{一}{}
\par
\end{example}
-outputs
+\en{outputs}
+\ja{こう出力する:}
\printkanbunblock{6}{
\kanbunfont
@@ -232,36 +292,42 @@ outputs
}
\noindent
-with \opt{tateaki} set to \verb|1|.
+\en{with \opt{tateaki} set to \verb|1|.}
-\subsection{Usage with \LuaLaTeX}
-\emph{Kanbun} annotation uses the following brackets to mark different elements in \emph{kanbun-kundoku} (as described in \href{https://phesoca.com/kanbun-html/}{漢文\textsc{html}} by UntPhesoca).
+\subsection{\en{Usage with \LuaLaTeX}\ja{\LuaLaTeX{}での使用}}
+\en{\emph{Kanbun} annotation uses the following brackets to mark different elements in \emph{kanbun-kundoku} (as described in \href{https://phesoca.com/kanbun-html/}{漢文\textsc{html}} by UntPhesoca). }
+\ja{漢文アノテーションでは下記の括弧を以って漢文訓読においての各要素を示す(UntPhesocaの \href{https://phesoca.com/kanbun-html/}{漢文HTML} を参照されたい)。}
\begin{itemize}
- \item \verb|( )|: \emph{furigana} (振り仮名)
- \item \verb|{ }|: \emph{okurigana} (送り仮名) (these brackets can be omitted)
- \item \verb|‹ ›|: \emph{furigana} (振り仮名) of \emph{saidoku-moji} (再読文字)
- \item \verb|« »|: \emph{okurigana} (送り仮名) of \emph{saidoku-moji} (再読文字)
- \item \verb|[ ]|: \emph{kaeriten} (返り点)
- \item \verb|‘ ’|: multiple \emph{kanji}, potentially with \emph{tateten} inserted, as a ruby base; group ruby (グループルビ)
- \item no annotation: \emph{kanji} (漢字) and punctuation.
+ \item \verb|( )|: \en{\emph{furigana} (}振仮名\en{)}
+ \item \verb|{ }|: \en{\emph{okurigana} (}送仮名\en{) (these brackets can be omitted)}\ja{(この括弧を省略してもよい)}
+ \item \verb|‹ ›|: \en{\emph{furigana} (振仮名) of \emph{saidoku-moji} (再読文字)}\ja{再読文字の振仮名}
+ \item \verb|« »|: \en{\emph{okurigana} (送仮名) of \emph{saidoku-moji} (再読文字)}\ja{再読文字の送仮名}
+ \item \verb|[ ]|: \en{\emph{kaeriten} (}返点\en{)}
+ \item \verb|‘ ’|: \en{multiple \emph{kanji}, potentially with \emph{tateten} inserted, as a ruby base; group ruby (グループルビ)}\ja{グループルビのベース。中に\ruby{竪|点}{たて|てん}を入れてもよい}
+ \item \en{no annotation: \emph{kanji} (漢字) and punctuation}\ja{アノテーション無し:漢字と句読点}
\end{itemize}
-\emph{Tateten} (竪点) can be input with either \verb|―| (\verb|U+2015|), \verb|—| (\verb|U+2014|) or \verb|㆐| (\verb|U+3190|).
+\en{\emph{Tateten} (竪点) can be input with either \verb|―| (\verb|U+2015|), \verb|—| (\verb|U+2014|) or \verb|㆐| (\verb|U+3190|).}
+\ja{\verb|―| (\verb|U+2015|) か \verb|—| (\verb|U+2014|) か \verb|㆐| (\verb|U+3190|) かで竪点を入力できる。}
\begin{ltxsyntax}
\cmditem{Kanbun}\cmditem{EndKanbun}
- Write the annotated \emph{kanbun} between the commands \cmd{Kanbun} and \cmd{EndKanbun}, and it will be processed and saved, ready to be used later.
+ \en{Write the annotated \emph{kanbun} between the commands \cmd{Kanbun} and \cmd{EndKanbun}, and it will be processed and saved, ready to be used later.}
+ \ja{アノテーションのある漢文を \cmd{Kanbun} と \cmd{EndKanbun} の間に書き込む。処理されて、保存されておいて、後で使用可能となる。}
\cmditem{printkanbun}
- Where you would like to use the most recently saved \emph{kanbun-kundoku} paragraph, use \cmd{printkanbun}.
+ \en{Where you would like to use the most recently saved \emph{kanbun-kundoku} paragraph, use \cmd{printkanbun}.}
+ \ja{最近保存された漢文訓読を使用するには、 \cmd{printkanbun} を使う。}
\cmditem{printkanbuncode}
- If you wish to make modifications on the result or to use the result with a non-\LuaTeX{} engine, it is possible to obtain the macros using \cmd{printkanbuncode} (prints in the terminal), and continue to work from there.
+ \en{If you wish to make modifications on the result or to use the result with a non-\LuaTeX{} engine, it is possible to obtain the macros using \cmd{printkanbuncode} (prints in the terminal), and continue to work from there.}
+ \ja{処理の結果を一部変更する、もしくは結果を\LuaTeX{}でないエンジンで使用するには、結果のマクロを \cmd{printkanbuncode} で入手して(端末に出力)、そこから作業を続けることが可能。}
\end{ltxsyntax}
-You can always save \cmd{printkanbun} to a macro and start a new annotated \emph{kanbun} block, as in the following example.
+\en{You can always save \cmd{printkanbun} to a macro for use later and start a new annotated \emph{kanbun} block, as in the following example.}
+\ja{次の実例のとおり、後で使えるように \cmd{printkanbun} をあるマクロに保存し、新しい漢文段落を書き込み始められる。}
\begin{example}
% example text from https://phesoca.com/kanbun-html/
\documentclass{ltjtarticle}
diff --git a/macros/latex/contrib/siunitx/CHANGELOG.md b/macros/latex/contrib/siunitx/CHANGELOG.md
index 649008576a..ddee0243e6 100644
--- a/macros/latex/contrib/siunitx/CHANGELOG.md
+++ b/macros/latex/contrib/siunitx/CHANGELOG.md
@@ -7,6 +7,17 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
## [Unreleased]
+## [v3.0.42] - 2022-01-18
+
+### Added
+- Slovene translations (see pull request
+ [\#570](https://github.com/josephwright/siunitx/pull/570))
+
+### Changed
+- Enable new LaTeX option handling if available
+- Use U+2126 rather than U+03A9 for `\ohm` in text mode with Unicode
+ engines
+
## [v3.0.41] - 2022-01-13
### Fixed
@@ -1660,7 +1671,8 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
### Added
- First public testing release (as `si`)
-[Unreleased]: https://github.com/josephwright/siunitx/compare/v3.0.41...HEAD
+[Unreleased]: https://github.com/josephwright/siunitx/compare/v3.0.42...HEAD
+[v3.0.42]: https://github.com/josephwright/siunitx/compare/v3.0.41...v3.0.42
[v3.0.41]: https://github.com/josephwright/siunitx/compare/v3.0.40...v3.0.41
[v3.0.40]: https://github.com/josephwright/siunitx/compare/v3.0.39...v3.0.40
[v3.0.39]: https://github.com/josephwright/siunitx/compare/v3.0.38...v3.0.39
diff --git a/macros/latex/contrib/siunitx/siunitx-code.pdf b/macros/latex/contrib/siunitx/siunitx-code.pdf
index b5922ebc96..bc6e13dedc 100644
--- a/macros/latex/contrib/siunitx/siunitx-code.pdf
+++ b/macros/latex/contrib/siunitx/siunitx-code.pdf
Binary files differ
diff --git a/macros/latex/contrib/siunitx/siunitx-locale.dtx b/macros/latex/contrib/siunitx/siunitx-locale.dtx
index 8535a74c20..681ad06ee7 100644
--- a/macros/latex/contrib/siunitx/siunitx-locale.dtx
+++ b/macros/latex/contrib/siunitx/siunitx-locale.dtx
@@ -107,6 +107,12 @@
inter-unit-product = \, ,
output-decimal-marker = { , }
} ,
+ locale / SI .meta:n =
+ {
+ exponent-product = \times ,
+ inter-unit-product = \, ,
+ output-decimal-marker = { , }
+ } ,
locale / UK .meta:n =
{
exponent-product = \times ,
@@ -137,10 +143,12 @@
{
\RequirePackage { translations }
\DeclareTranslation { Catalan } { and } { i }
+ \DeclareTranslation { Slovene } { and } { in }
\DeclareTranslation { Catalan } { to~(numerical~range) } { a }
\DeclareTranslation { English } { to~(numerical~range) } { to }
\DeclareTranslation { French } { to~(numerical~range) } { à }
\DeclareTranslation { German } { to~(numerical~range) } { bis }
+ \DeclareTranslation { Slovene } { to~(numerical~range) } { do }
\DeclareTranslation { Spanish } { to~(numerical~range) } { a }
\keys_set:nn { siunitx }
{
diff --git a/macros/latex/contrib/siunitx/siunitx-symbol.dtx b/macros/latex/contrib/siunitx/siunitx-symbol.dtx
index 8952aabeab..eaf2caac9b 100644
--- a/macros/latex/contrib/siunitx/siunitx-symbol.dtx
+++ b/macros/latex/contrib/siunitx/siunitx-symbol.dtx
@@ -118,6 +118,8 @@
\exp_after:wN \exp_after:wN \exp_after:wN
\exp_not:N \char_generate:nn {#1} { 13 }
\char_generate:nn {#2} { 12 }
+ \tl_if_blank:nF {#3}
+ { \char_generate:nn {#3} { 12 } }
}
}
\cs_new:Npn \@@_deal_with_utf: { }
@@ -230,7 +232,7 @@
% a mode-dependent definition. This doesn't work if the text mode symbol is
% bust: the \pkg{fourier} package puts us in that position.
% \begin{macrocode}
- \@@_if_replace:NnT \ohm { "03A9 }
+ \@@_if_replace:NnT \ohm { "2126 }
{
\tl_set:Nx \l_@@_tmpa_tl
{
@@ -262,7 +264,7 @@
\bool_lazy_or:nnTF
{ \sys_if_engine_luatex_p: }
{ \sys_if_engine_xetex_p: }
- { \@@_non_latin:n { "03A9 } }
+ { \@@_non_latin:n { "2126 } }
{ \exp_not:N \textohm }
}
\exp_not:N \fi
diff --git a/macros/latex/contrib/siunitx/siunitx-unit.dtx b/macros/latex/contrib/siunitx/siunitx-unit.dtx
index 677e05f750..1ac6db5596 100644
--- a/macros/latex/contrib/siunitx/siunitx-unit.dtx
+++ b/macros/latex/contrib/siunitx/siunitx-unit.dtx
@@ -2532,6 +2532,8 @@
\exp_after:wN \exp_after:wN \exp_after:wN
\exp_not:N \char_generate:nn {#1} { 13 }
\char_generate:nn {#2} { 12 }
+ \tl_if_blank:nF {#3}
+ { \char_generate:nn {#3} { 12 } }
}
}
% \end{macrocode}
@@ -2680,7 +2682,7 @@
% Named derived units: second half of alphabet.
% \begin{macrocode}
\siunitx_declare_unit:Nn \newton { N }
-\siunitx_declare_unit:Nx \ohm { \@@_non_latin:n { "03A9 } }
+\siunitx_declare_unit:Nx \ohm { \@@_non_latin:n { "2126 } }
\siunitx_declare_unit:Nn \pascal { Pa }
\siunitx_declare_unit:Nn \radian { rad }
\siunitx_declare_unit:Nn \siemens { S }
diff --git a/macros/latex/contrib/siunitx/siunitx.dtx b/macros/latex/contrib/siunitx/siunitx.dtx
index 35902e25c7..400f4fa539 100644
--- a/macros/latex/contrib/siunitx/siunitx.dtx
+++ b/macros/latex/contrib/siunitx/siunitx.dtx
@@ -121,7 +121,7 @@
%
% Identify the package and give the over all version information.
% \begin{macrocode}
-\ProvidesExplPackage {siunitx} {2022-01-13} {3.0.41}
+\ProvidesExplPackage {siunitx} {2022-01-18} {3.0.42}
{A comprehensive (SI) units package}
% \end{macrocode}
%
@@ -200,11 +200,12 @@
% \subsection{Option handling}
%
% \begin{macrocode}
-\RequirePackage { l3keys2e }
-% \end{macrocode}
-%
-% \begin{macrocode}
-\ProcessKeysOptions { siunitx }
+\IfFormatAtLeastTF { 2022-06-01 }
+ { \ProcessKeyOptions [ siunitx ] }
+ {
+ \RequirePackage { l3keys2e }
+ \ProcessKeysOptions { siunitx }
+ }
% \end{macrocode}
%
% \begin{macrocode}
diff --git a/macros/latex/contrib/siunitx/siunitx.pdf b/macros/latex/contrib/siunitx/siunitx.pdf
index 266462e8b6..e5d013218f 100644
--- a/macros/latex/contrib/siunitx/siunitx.pdf
+++ b/macros/latex/contrib/siunitx/siunitx.pdf
Binary files differ
diff --git a/macros/latex/contrib/siunitx/siunitx.tex b/macros/latex/contrib/siunitx/siunitx.tex
index 69f61e8c58..7306796936 100644
--- a/macros/latex/contrib/siunitx/siunitx.tex
+++ b/macros/latex/contrib/siunitx/siunitx.tex
@@ -2860,7 +2860,8 @@ same value (one of \opt{center}, \opt{right} or \opt{left}).
\pkg{siunitx} allows the user to switch between the typographic conventions of
different (geographical) areas by using locales. Currently, the package is
supplied with configurations for locales \opt{UK}, \opt{US}, \opt{DE}
-(Germany), \opt{FR} (French) and \opt{ZA} (South Africa). The \opt{locale}
+(Germany), \opt{FR} (French), \opt{SI} (Slovene) and \opt{ZA} (South Africa).
+The \opt{locale}
option is used to switch to a particular locale.
\begin{LaTeXdemo}
\qty{1.234}{\metre}\\
diff --git a/macros/luatex/latex/autopuncitems/README.md b/macros/luatex/latex/autopuncitems/README.md
index 3cd4844b10..1b4ad8c5c6 100644
--- a/macros/luatex/latex/autopuncitems/README.md
+++ b/macros/luatex/latex/autopuncitems/README.md
@@ -1,10 +1,10 @@
# autopuncitems
-Automatically punctuate lists by passing the autopunc option to enumitem lists.
+Automatically punctuate lists by passing the autopunc option to enumitem lists. Requires LuaLaTeX.
# License
-Copyright (C) 2021 Kale Ewasiuk
+Copyright (C) 2021-2022 Kale Ewasiuk
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/macros/luatex/latex/autopuncitems/autopuncitems.lua b/macros/luatex/latex/autopuncitems/autopuncitems.lua
index 5e8e5b10c6..fc0a4b38b5 100644
--- a/macros/luatex/latex/autopuncitems/autopuncitems.lua
+++ b/macros/luatex/latex/autopuncitems/autopuncitems.lua
@@ -1,6 +1,6 @@
--% Kale Ewasiuk (kalekje@gmail.com)
---% 2021-12-20
---% Copyright (C) 2021 Kale Ewasiuk
+--% 2022-01-18
+--% Copyright (C) 2021-2022 Kale Ewasiuk
--%
--% Permission is hereby granted, free of charge, to any person obtaining a copy
--% of this software and associated documentation files (the "Software"), to deal
diff --git a/macros/luatex/latex/autopuncitems/autopuncitems.pdf b/macros/luatex/latex/autopuncitems/autopuncitems.pdf
index fd743e4d99..d2a5da00ed 100644
--- a/macros/luatex/latex/autopuncitems/autopuncitems.pdf
+++ b/macros/luatex/latex/autopuncitems/autopuncitems.pdf
Binary files differ
diff --git a/macros/luatex/latex/autopuncitems/autopuncitems.sty b/macros/luatex/latex/autopuncitems/autopuncitems.sty
index 8045fa4737..81c3f2dd6c 100644
--- a/macros/luatex/latex/autopuncitems/autopuncitems.sty
+++ b/macros/luatex/latex/autopuncitems/autopuncitems.sty
@@ -1,6 +1,6 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2021-12-20
-% Copyright (C) 2021 Kale Ewasiuk
+% 2022-01-18
+% Copyright (C) 2021-2022 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
% of this software and associated documentation files (the "Software"), to deal
@@ -23,10 +23,15 @@
% OR OTHER DEALINGS IN THE SOFTWARE.
-\ProvidesPackage{autopuncitems}[2021-12-20]
+\ProvidesPackage{autopuncitems}[2022-01-18]
-\RequirePackage{enumitem}
\RequirePackage{luacode}
+\RequirePackage{etoolbox}
+
+\newtoggle{noenumitem}
+
+\DeclareOption{noenumitem}{\toggletrue{noenumitem}}
+\ProcessOptions*\relax
\luadirect{autopuncitems = require'autopuncitems'}
@@ -42,15 +47,22 @@
\NewDocumentCommand{\setAPlast}{m}{\luadirect{autopuncitems.punc[1] = \luastring{#1}}} % second last punc value
\NewDocumentCommand{\setAPseclast}{m}{\luadirect{autopuncitems.punc[2] = \luastring{#1}}} % final punc value
-\NewDocumentEnvironment{AutoPuncItemize}{ +b }{
-% \luadirect{texio.write_nl('auto >>>'..autopuncitems.go(\luastringN{#1}))}
- \luadirect{tex.print(autopuncitems.go(\luastringN{#1}))}
-}{}
+\NewDocumentEnvironment{AutoPuncItems}{ +b }{\luadirect{tex.print(autopuncitems.go(\luastringN{#1}))}}{} % does not expand
+\NewDocumentEnvironment{AutoPuncItemsO}{ +b }{\luadirect{tex.print(autopuncitems.go(\luastringO{#1}))}}{} % expands once
+\NewDocumentEnvironment{AutoPuncItemsE}{ +b }{\luadirect{tex.print(autopuncitems.go(\luastring{#1}))}}{} % full expansion IN-PROGRESS
-\SetEnumitemKey{autopunc}{
- first*=\expandafter\AutoPuncItemize,
- after=\endAutoPuncItemize,
+\iftoggle{noenumitem}{}{% do nothing to enumitem if noenumitem is passed. Useful for beamer
+ \RequirePackage{enumitem}
+ \global\SetEnumitemKey{autopunc}{
+ first*=\expandafter\AutoPuncItems,
+ after=\endAutoPuncItems,
+ }
+ \global\SetEnumitemKey{autopuncO}{
+ first*=\expandafter\AutoPuncItemsO,
+ after=\endAutoPuncItemsO,
+ }
+ \global\SetEnumitemKey{autopuncE}{
+ first*=\expandafter\AutoPuncItemsE,
+ after=\endAutoPuncItemsE,
+ }
}
-
-
-
diff --git a/macros/luatex/latex/autopuncitems/autopuncitems.tex b/macros/luatex/latex/autopuncitems/autopuncitems.tex
index fd829b81e6..06f3f5e9be 100644
--- a/macros/luatex/latex/autopuncitems/autopuncitems.tex
+++ b/macros/luatex/latex/autopuncitems/autopuncitems.tex
@@ -1,6 +1,6 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2021-12-20
-% Copyright (C) 2021 Kale Ewasiuk
+% 2022-01-18
+% Copyright (C) 2021-2022 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
% of this software and associated documentation files (the "Software"), to deal
@@ -62,12 +62,19 @@
\begin{document}
\maketitle
+{\Huge TODO make an environment that can be used outside of itemize, useful for beamer possibly}
+
\section{Introduction}
-This package provides the \cmd{autopunc} option in the
-\cmd{enumitem} environemnts \cmd{itemize}, \cmd{enumerate}, and \cmd{description}
+This package provides environments \cmd{AutoPuncItemize}, \cmd{AutoPuncItemizeO}, and \cmd{AutoPuncItemizeE} (beta)
to automatically punctuate the items.
+By default, it adds the \cmd{autopunc (O|E)} options in the
+\cmd{enumitem} environments \cmd{itemize}, \cmd{enumerate}, and \cmd{description}, to wrap the contents in these enviroments.
+If you want to skip this (say if you were using the beamer class which
+may be interefered with by enum item), pass the \cmd{noenumitem} option to this package. You can still use the environments with beamer, though.
It uses lua pattern matching to modify the environment's contents.
+
+
\section{Some commands}
\llcmd{\APomit}Used in an \cmd{\item} to signify that that item should not be automatically punctuated, and not be counted. Expands to nothing.\\
\llcmd{\APpass}Used in an \cmd{\item} to signify that that item should not be automatically punctuated, and but still counted. Expands to nothing.\\
@@ -84,6 +91,11 @@ It uses lua pattern matching to modify the environment's contents.
\end{addmargin}
+\section{Variants}
+\llcmd{autopunc}Does not expand the contents of environment. Tutorial on next section shows this.\\
+\llcmd{autopuncO}Expands the contents of environment once. Useful if \cmd{\item}'s are in a command \\
+\llcmd{autopuncE}Fully expands the contents of environment first. This is in-progress and should not be used.\\
+
\section{Tutorial}
\subsection{Basic Use}
diff --git a/macros/luatex/latex/yamlvars/README.md b/macros/luatex/latex/yamlvars/README.md
index 946ee2e374..031de6c53a 100644
--- a/macros/luatex/latex/yamlvars/README.md
+++ b/macros/luatex/latex/yamlvars/README.md
@@ -1,13 +1,13 @@
-# YAMLvars -- parse a YAML document and create LaTeX definitons
+# YAMLvars -- parse a YAML document and create definitions in LaTeX
This LuaLaTeX package provides a YAML parser and some functions to declare and define LaTeX definitions using YAML files.
-It uses the [`tinyyaml`](https://github.com/api7/lua-tinyyaml) parser.
+It uses the [`markdown-tinyyaml`](https://github.com/api7/lua-tinyyaml) parser that is shipped with the [`markdown`](https://ctan.org/pkg/markdown) package.
# License
-Copyright (C) 2021 Kale Ewasiuk
+Copyright (C) 2021-2022 Kale Ewasiuk
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/macros/luatex/latex/yamlvars/YAMLvars.lua b/macros/luatex/latex/yamlvars/YAMLvars.lua
index 72e4d6ad1a..93234e5d59 100644
--- a/macros/luatex/latex/yamlvars/YAMLvars.lua
+++ b/macros/luatex/latex/yamlvars/YAMLvars.lua
@@ -1,6 +1,6 @@
--% Kale Ewasiuk (kalekje@gmail.com)
---% 2021-12-15
---% Copyright (C) 2021 Kale Ewasiuk
+--% 2022-01-18
+--% Copyright (C) 2021-2022 Kale Ewasiuk
--%
--% Permission is hereby granted, free of charge, to any person obtaining a copy
--% of this software and associated documentation files (the "Software"), to deal
@@ -61,6 +61,7 @@ YAMLvars.dftDefault = nil
YAMLvars.xfmDefault = {}
YAMLvars.allowUndeclared = false
+YAMLvars.overwritedefs = false
YAMLvars.valTemp = ''
YAMLvars.varTemp = ''
@@ -69,7 +70,9 @@ YAMLvars.tabmidrule = 'hline'
YAMLvars.debug = false
-YAMLvars.yaml = require('tinyyaml')
+YAMLvars.yaml = require'markdown-tinyyaml' -- note: YAMLvars.sty will have checked existence of this already
+local pl = _G['penlight'] or _G['pl'] -- penlight for this namespace is pl
+
function YAMLvars.debugtalk(s, ss)
if YAMLvars.debug then
@@ -77,9 +80,10 @@ function YAMLvars.debugtalk(s, ss)
end
end
+
-- xfm functions (transforms) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
function YAMLvars.xfm.addxspace(var, val)
- return val .. '\\xspace'
+ return val .. '\\xspace{}'
end
function YAMLvars.xfm.tab2arr(var, val)
@@ -99,10 +103,10 @@ function YAMLvars.xfm.arr2tabular(var, val)
end
-function YAMLvars.xfm.arr2itemize(var, val)
+function YAMLvars.xfm.list2items(var, val) -- todo should be list2item
return pl.List(val):map('\\item '.._1):join(' ')
end
-
+YAMLvars.xfm.arr2itemize = YAMLvars.xfm.list2items
function YAMLvars.xfm.arrsortAZ(var, val)
return pl.List(val):sort(pl.operator.strlt)
@@ -126,12 +130,15 @@ function YAMLvars.xfm.arrsortlastnameAZ(var, val)
end
-- todo need distinction beyyween table and penlight list ???
function YAMLvars.xfm.list2nl(var, val)
- val = pl.array2d.map_slice1(_1..'\\\\', val, 1,-2)
- return val:join('')
- --return pl.tablex.reduce(_1.._2, val, '')
+ return pl.tablex.join(val,'\\\\ ')
end
-function YAMLvars.xfm.lb2nl(var, val)
+ --val = pl.array2d.map_slice1(_1..'\\\\', val, 1,-2)
+ --return val:join('')
+ --return pl.tablex.reduce(_1.._2, val, '')
+
+
+function YAMLvars.xfm.lb2nl(var, val) --linebreak in text 2 new line
val, _ = val:gsub('\n','\\\\ ')
return val
end
@@ -265,7 +272,7 @@ end
function YAMLvars.prvcmd(cs, val) -- provide command via lua
- if token.is_defined(cs) then
+ if token.is_defined(cs) and (not YAMLvars.overwritedefs) then
tex.print('\\PackageError{YAMLvars}{Variable '..cs..' already defined, could not declare}{}')
else
token.set_macro(cs, val, 'global')
@@ -339,21 +346,29 @@ local function sub_lua_var(s, v1, v2)
return s:gsub('([%A?%-?])('..v1..')([%W?%-?])', '%1'..v2..'%3') -- replace x variables
end
+local _YV_invalid_expression = '\1 invalid expression'
+local _YV_no_return = '\2 no return val'
local function eval_expr(func, var, val)
- local s, c = func:gsub('^[=/]', {['/'] = '', ['='] = 'YAMLvars.valTemp = '}, 1) -- / is run code, = sets val = code
+ local s, c = func:gsub('^[=/]', {['/'] = '\2', ['='] = 'YAMLvars.valTemp = '}, 1) -- / is run code, = sets val = code
if c == 0 then
- return nil
+ return _YV_invalid_expression
else
--help_wrt(s, var)
--help_wrt(val, var)
YAMLvars.valTemp = val
YAMLvars.varTemp = var
--help_wrt(s, var)
+ s, c = s:gsub('\2', '') -- strip \2 that might have appeared if / was applied
s = sub_lua_var(' '..s, 'x', 'YAMLvars.valTemp')
s = sub_lua_var(s, 'v', 'YAMLvars.varTemp')
--help_wrt(s, var)
- loadstring(s)()
- --help_wrt(val, var)
+ local f, err = pcall(loadstring(s))
+ if not f then
+ tex.print('\\PackageError{YAMLvars}{xfm with "= or /" error on var "'..var..'"}{}') --
+ end
+ if c > 0 then
+ return _YV_no_return
+ end
return YAMLvars.valTemp
end
end
@@ -363,8 +378,9 @@ local function transform_and_prc(var, val)
local f = YAMLvars.xfm[func]
if f == nil then
local val2 = eval_expr(func, var, val)
- if val2 == nil then
- tex.print('\\PackageWarning{YAMLvars}{xfm function "'..func..'" not defined, skipping}{}')
+ if val2 == _YV_invalid_expression then
+ tex.print('\\PackageError{YAMLvars}{xfm function "'..func..'" not defined or invalid expression passed on var "'..var..'"}{}')
+ elseif val == _YV_no_return then
else
val = val2
end
@@ -374,7 +390,7 @@ local function transform_and_prc(var, val)
end
f = YAMLvars.prc[YAMLvars.varspecs[var]['prc']]
if f == nil then
- tex.print('\\PackageError{YAMLvars}{prc function "'..YAMLvars.varspecs[var]['prc']..'" not defined}{}')
+ tex.print('\\PackageError{YAMLvars}{prc function "'..YAMLvars.varspecs[var]['prc']..'" on var "'..var..'" not defined}{}')
end
f(var, val) -- prc the value of the variable
end
@@ -383,7 +399,10 @@ function YAMLvars.parseYAMLvarsStr(y)
YAMLvars.varsvals = YAMLvars.yaml.parse(y)
for var, val in pairs(YAMLvars.varsvals) do
if YAMLvars.varspecs[var] == nil then
- check_def(var, val)
+ check_def(var, val) -- if not declared
+ -- todo consider free form parse declaring
+ -- variable name: {xfm:, dec:, prc:, val: }
+ -- definitely doable here
else
transform_and_prc(var, val)
end
diff --git a/macros/luatex/latex/yamlvars/YAMLvars.pdf b/macros/luatex/latex/yamlvars/YAMLvars.pdf
index eeeab7ea6c..974873680d 100644
--- a/macros/luatex/latex/yamlvars/YAMLvars.pdf
+++ b/macros/luatex/latex/yamlvars/YAMLvars.pdf
Binary files differ
diff --git a/macros/luatex/latex/yamlvars/YAMLvars.sty b/macros/luatex/latex/yamlvars/YAMLvars.sty
index 2392800651..73c40ba693 100644
--- a/macros/luatex/latex/yamlvars/YAMLvars.sty
+++ b/macros/luatex/latex/yamlvars/YAMLvars.sty
@@ -1,6 +1,6 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2021-12-15
-% Copyright (C) 2021 Kale Ewasiuk
+% 2022-01-18
+% Copyright (C) 2021-2022 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
% of this software and associated documentation files (the "Software"), to deal
@@ -23,15 +23,17 @@
% OR OTHER DEALINGS IN THE SOFTWARE.
+
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{YAMLvars}[2021-12-15]
+\ProvidesPackage{YAMLvars}[2022-01-18]
+
+\IfFileExists{markdown-tinyyaml.lua}{}{\PackageError{YAMLvars}{This package requires installation of the 'markdown' package, please install it and try again}{}}
\RequirePackage{luacode}
\RequirePackage{xspace}
\RequirePackage{etoolbox}
\RequirePackage[pl,extras]{penlight}
-
\luadirect{YAMLvars = require('YAMLvars')}
\DeclareOption{useyv}{
@@ -43,7 +45,11 @@
}
\DeclareOption{allowundeclared}{
\luadirect{YAMLvars.allowUndeclared = true}
-}\DeclareOption{debug}{
+}
+\DeclareOption{overwritedefs}{
+ \luadirect{YAMLvars.overwritedefs = true}
+}
+\DeclareOption{debug}{
\luadirect{YAMLvars.debug = true}
}
diff --git a/macros/luatex/latex/yamlvars/YAMLvars.tex b/macros/luatex/latex/yamlvars/YAMLvars.tex
index 5e32058dab..057aac5d39 100644
--- a/macros/luatex/latex/yamlvars/YAMLvars.tex
+++ b/macros/luatex/latex/yamlvars/YAMLvars.tex
@@ -1,6 +1,6 @@
% Kale Ewasiuk (kalekje@gmail.com)
-% 2021-12-15
-% Copyright (C) 2021 Kale Ewasiuk
+% 2022-01-18
+% Copyright (C) 2021-2022 Kale Ewasiuk
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
% of this software and associated documentation files (the "Software"), to deal
@@ -29,6 +29,7 @@
\newcommand{\cmd}[1]{\texttt{\detokenize{#1}}}
\newcommand{\qcmd}[1]{``\cmd{#1}''}
\usepackage{url}
+\usepackage{xcolor}
\usepackage{showexpl}
\lstset{explpreset={justification=\raggedright,pos=r,wide=true}}
\setlength\ResultBoxRule{0mm}
@@ -53,13 +54,26 @@
-\usepackage{YAMLvars}
+\usepackage[overwritedefs]{YAMLvars}
\title{YAMLvars}
\subtitle{a YAML variable parser for LuaLaTeX}
\begin{document}
+
+
\maketitle
+
+%%%%%
+
+%{NOTE::: \Huge todo use LTXexample and improve examples/testing\\
+%todo need way better error tracing for this pkg}
+
+
+
+%%%%%%%%%%%
+
+
YAMLvars is a LuaLaTeX-based package to help make definitions or produce LaTeX code using a YAML file.
This package might be useful for you if you want to batch create docummnts
by pushing various sets YAML data to a fixed LaTeX template,
@@ -85,25 +99,31 @@ declare the variables somewhere in the preamble.
This option is offered to help with automation scripts.
An example is showin in Section \ref{example}.
-\leavevmode\llap{\texttt{allowundeclared}\ \ \ }%
+\hspace*{3ex}\llcmd{allowundeclared}%
It might be helpful to define something in your YAML parsing doc without declaring it.
If you want this flexibility, use this setting. Note that eisting definitions will not be overwritten and an error
will br thrown if the name exists.
+\llcmd{overwritedefs}Danger! This will allow you to \cmd{gdef} commands with YAML. Caution should be taken to not set definitions like \cmd{begin}, \cmd{section}, etc.
+
\section{Dependencies}
-This package contains the \texttt{tinyyaml} Lua package.
-If you want to use it for other purposes, you can bring it into Lua by either:
+%This package contains the \texttt{tinyyaml} Lua package.
+\llcmd{Note:}This package requires that the \cmd{markdown} (\url{https://ctan.org/pkg/markdown}) be installed. This package does not use the package in its entirety, but rather depends on the YAML interpreter it comes with: \cmd{markdown-tinyyaml.lua}. This dependency is chosen to avoid redundancy in your TeX installation and align development of the \cmd{tinyyaml} Lua package.
+If you want to use the YAML interpreter for other purposes, you can bring it into Lua by either:
\begin{verbatim}
\directlua{yaml = YAMLvars.yaml} or
-\directlua{yaml = require('tinyyaml')}
+\directlua{yaml = require'markdown-tinyyaml'}
\end{verbatim}
-The distribution: \url{https://github.com/peposso/lua-tinyyaml}\\
+The distribution: \url{https://github.com/api7/lua-tinyyaml}\\
The YAML specification: \url{https://yaml.org/spec/}\\
-Many of the ``transform'' and ``processing'' functions built-in to this package rely on other packages.
-\texttt{penlight},
-\texttt{xspace},
-\texttt{hyperref} for example.
+Many of the ``transform'' and ``processing'' functions built-in to this package rely on other packages,
+like
+\texttt{hyperref}, for example, but it is not loaded, and this package will only load
+\cmd{penlight},
+\cmd{luacode},
+\cmd{xspace}, and
+\cmd{etoolbox}.
\section{Declaring variables}
A declaration file can either be parsed with the command \texttt{declareYAMLvarsFile} command,
@@ -117,6 +137,9 @@ be a table that contains at least one of the following keys:\\
\texttt{prc} (processing, must be a single string), or \\
\texttt{dft} (default value, if being defined. Must be a string).
+If you want to change the way a variable is initialized, you can change the function
+\cmd{YAMLvars.dec.PRC = function (var) ... end } where \cmd{PRC} is how the variable will be processed (\cmd{gdef}, \cmd{yvdef}, \cmd{length}, or something of your choosing).
+
The default value for variables is the Lua \texttt{nil}.
YAMLvars will first check if the definition exists, if so, an error will be thrown
so that we avoid overwriting.
@@ -210,7 +233,49 @@ This package includes \texttt{gdef} to set a definition, \texttt{yvdef} to defin
\texttt{title, author, date} to set \texttt{\textbackslash @title, \textbackslash @author, \textbackslash @date},
respectively
- \section{Example}\label{example}
+\pagebreak
+
+\section{Some Examples}
+
+\begin{LTXexample}
+%! language = yaml
+\begin{declareYAMLvars}
+address:
+ xfm:
+ - list2nl
+ - = x..'!!!'
+name: null
+
+title:
+ xfm:
+ - lb2nl
+# - / YAMLvars.prvcmd(titletext, YAMLvars.varsvals['atitle']:gsub('\n', ' ')..'\\xspace{}')
+\end{declareYAMLvars}
+
+%! language = yaml
+\begin{parseYAMLvars}
+title: |-
+ A Multiline
+ Monumental Title!
+
+name: Joe Smith
+address:
+ - 1234 Fake St.
+ - City
+\end{parseYAMLvars}
+
+\title
+
+%\titletext!
+
+\name
+
+\address
+
+\end{LTXexample}
+
+\pagebreak
+ \section{Automation Example}\label{example}
Suppose you had a number of bills of sales in yaml format and wanted to produce some nice pdfs.
The following code shows how this could be done.
diff --git a/macros/luatex/latex/yamlvars/tinyyaml.lua b/macros/luatex/latex/yamlvars/tinyyaml.lua
deleted file mode 100644
index b1a6470863..0000000000
--- a/macros/luatex/latex/yamlvars/tinyyaml.lua
+++ /dev/null
@@ -1,816 +0,0 @@
--------------------------------------------------------------------------------
--- tinyyaml - YAML subset parser
--------------------------------------------------------------------------------
-
-local table = table
-local string = string
-local schar = string.char
-local ssub, gsub = string.sub, string.gsub
-local sfind, smatch = string.find, string.match
-local tinsert, tconcat, tremove = table.insert, table.concat, table.remove
-local setmetatable = setmetatable
-local pairs = pairs
-local type = type
-local tonumber = tonumber
-local math = math
-local getmetatable = getmetatable
-local error = error
-
-local UNESCAPES = {
- ['0'] = "\x00", z = "\x00", N = "\x85",
- a = "\x07", b = "\x08", t = "\x09",
- n = "\x0a", v = "\x0b", f = "\x0c",
- r = "\x0d", e = "\x1b", ['\\'] = '\\',
-};
-
--------------------------------------------------------------------------------
--- utils
-local function select(list, pred)
- local selected = {}
- for i = 0, #list do
- local v = list[i]
- if v and pred(v, i) then
- tinsert(selected, v)
- end
- end
- return selected
-end
-
-local function startswith(haystack, needle)
- return ssub(haystack, 1, #needle) == needle
-end
-
-local function ltrim(str)
- return smatch(str, "^%s*(.-)$")
-end
-
-local function rtrim(str)
- return smatch(str, "^(.-)%s*$")
-end
-
-local function trim(str)
- return smatch(str, "^%s*(.-)%s*$")
-end
-
--------------------------------------------------------------------------------
--- Implementation.
---
-local class = {__meta={}}
-function class.__meta.__call(cls, ...)
- local self = setmetatable({}, cls)
- if cls.__init then
- cls.__init(self, ...)
- end
- return self
-end
-
-function class.def(base, typ, cls)
- base = base or class
- local mt = {__metatable=base, __index=base}
- for k, v in pairs(base.__meta) do mt[k] = v end
- cls = setmetatable(cls or {}, mt)
- cls.__index = cls
- cls.__metatable = cls
- cls.__type = typ
- cls.__meta = mt
- return cls
-end
-
-
-local types = {
- null = class:def('null'),
- map = class:def('map'),
- omap = class:def('omap'),
- pairs = class:def('pairs'),
- set = class:def('set'),
- seq = class:def('seq'),
- timestamp = class:def('timestamp'),
-}
-
-local Null = types.null
-function Null.__tostring() return 'yaml.null' end
-function Null.isnull(v)
- if v == nil then return true end
- if type(v) == 'table' and getmetatable(v) == Null then return true end
- return false
-end
-local null = Null()
-
-function types.timestamp:__init(y, m, d, h, i, s, f, z)
- self.year = tonumber(y)
- self.month = tonumber(m)
- self.day = tonumber(d)
- self.hour = tonumber(h or 0)
- self.minute = tonumber(i or 0)
- self.second = tonumber(s or 0)
- if type(f) == 'string' and sfind(f, '^%d+$') then
- self.fraction = tonumber(f) * math.pow(10, 3 - #f)
- elseif f then
- self.fraction = f
- else
- self.fraction = 0
- end
- self.timezone = z
-end
-
-function types.timestamp:__tostring()
- return string.format(
- '%04d-%02d-%02dT%02d:%02d:%02d.%03d%s',
- self.year, self.month, self.day,
- self.hour, self.minute, self.second, self.fraction,
- self:gettz())
-end
-
-function types.timestamp:gettz()
- if not self.timezone then
- return ''
- end
- if self.timezone == 0 then
- return 'Z'
- end
- local sign = self.timezone > 0
- local z = sign and self.timezone or -self.timezone
- local zh = math.floor(z)
- local zi = (z - zh) * 60
- return string.format(
- '%s%02d:%02d', sign and '+' or '-', zh, zi)
-end
-
-
-local function countindent(line)
- local _, j = sfind(line, '^%s+')
- if not j then
- return 0, line
- end
- return j, ssub(line, j+1)
-end
-
-local function parsestring(line, stopper)
- stopper = stopper or ''
- local q = ssub(line, 1, 1)
- if q == ' ' or q == '\t' then
- return parsestring(ssub(line, 2))
- end
- if q == "'" then
- local i = sfind(line, "'", 2, true)
- if not i then
- return nil, line
- end
- return ssub(line, 2, i-1), ssub(line, i+1)
- end
- if q == '"' then
- local i, buf = 2, ''
- while i < #line do
- local c = ssub(line, i, i)
- if c == '\\' then
- local n = ssub(line, i+1, i+1)
- if UNESCAPES[n] ~= nil then
- buf = buf..UNESCAPES[n]
- elseif n == 'x' then
- local h = ssub(i+2,i+3)
- if sfind(h, '^[0-9a-fA-F]$') then
- buf = buf..schar(tonumber(h, 16))
- i = i + 2
- else
- buf = buf..'x'
- end
- else
- buf = buf..n
- end
- i = i + 1
- elseif c == q then
- break
- else
- buf = buf..c
- end
- i = i + 1
- end
- return buf, ssub(line, i+1)
- end
- if q == '{' or q == '[' then -- flow style
- return nil, line
- end
- if q == '|' or q == '>' then -- block
- return nil, line
- end
- if q == '-' or q == ':' then
- if ssub(line, 2, 2) == ' ' or ssub(line, 2, 2) == '\n' or #line == 1 then
- return nil, line
- end
- end
- local buf = ''
- while #line > 0 do
- local c = ssub(line, 1, 1)
- if sfind(stopper, c, 1, true) then
- break
- elseif c == ':' and (ssub(line, 2, 2) == ' ' or ssub(line, 2, 2) == '\n' or #line == 1) then
- break
- elseif c == '#' and (ssub(buf, #buf, #buf) == ' ') then
- break
- else
- buf = buf..c
- end
- line = ssub(line, 2)
- end
- return rtrim(buf), line
-end
-
-local function isemptyline(line)
- return line == '' or sfind(line, '^%s*$') or sfind(line, '^%s*#')
-end
-
-local function equalsline(line, needle)
- return startswith(line, needle) and isemptyline(ssub(line, #needle+1))
-end
-
-local function compactifyemptylines(lines)
- -- Appends empty lines as "\n" to the end of the nearest preceding non-empty line
- local compactified = {}
- local lastline = {}
- for i = 1, #lines do
- local line = lines[i]
- if isemptyline(line) then
- if #compactified > 0 and i < #lines then
- tinsert(lastline, "\n")
- end
- else
- if #lastline > 0 then
- tinsert(compactified, tconcat(lastline, ""))
- end
- lastline = {line}
- end
- end
- if #lastline > 0 then
- tinsert(compactified, tconcat(lastline, ""))
- end
- return compactified
-end
-
-local function checkdupekey(map, key)
- if map[key] ~= nil then
- -- print("found a duplicate key '"..key.."' in line: "..line)
- local suffix = 1
- while map[key..'_'..suffix] do
- suffix = suffix + 1
- end
- key = key ..'_'..suffix
- end
- return key
-end
-
-local function parseflowstyle(line, lines)
- local stack = {}
- while true do
- if #line == 0 then
- if #lines == 0 then
- break
- else
- line = tremove(lines, 1)
- end
- end
- local c = ssub(line, 1, 1)
- if c == '#' then
- line = ''
- elseif c == ' ' or c == '\t' or c == '\r' or c == '\n' then
- line = ssub(line, 2)
- elseif c == '{' or c == '[' then
- tinsert(stack, {v={},t=c})
- line = ssub(line, 2)
- elseif c == ':' then
- local s = tremove(stack)
- tinsert(stack, {v=s.v, t=':'})
- line = ssub(line, 2)
- elseif c == ',' then
- local value = tremove(stack)
- if value.t == ':' or value.t == '{' or value.t == '[' then error() end
- if stack[#stack].t == ':' then
- -- map
- local key = tremove(stack)
- key.v = checkdupekey(stack[#stack].v, key.v)
- stack[#stack].v[key.v] = value.v
- elseif stack[#stack].t == '{' then
- -- set
- stack[#stack].v[value.v] = true
- elseif stack[#stack].t == '[' then
- -- seq
- tinsert(stack[#stack].v, value.v)
- end
- line = ssub(line, 2)
- elseif c == '}' then
- if stack[#stack].t == '{' then
- if #stack == 1 then break end
- stack[#stack].t = '}'
- line = ssub(line, 2)
- else
- line = ','..line
- end
- elseif c == ']' then
- if stack[#stack].t == '[' then
- if #stack == 1 then break end
- stack[#stack].t = ']'
- line = ssub(line, 2)
- else
- line = ','..line
- end
- else
- local s, rest = parsestring(line, ',{}[]')
- if not s then
- error('invalid flowstyle line: '..line)
- end
- tinsert(stack, {v=s, t='s'})
- line = rest
- end
- end
- return stack[1].v, line
-end
-
-local function parseblockstylestring(line, lines, indent)
- if #lines == 0 then
- error("failed to find multi-line scalar content")
- end
- local s = {}
- local firstindent = -1
- local endline = -1
- for i = 1, #lines do
- local ln = lines[i]
- local idt = countindent(ln)
- if idt <= indent then
- break
- end
- if ln == '' then
- tinsert(s, '')
- else
- if firstindent == -1 then
- firstindent = idt
- elseif idt < firstindent then
- break
- end
- tinsert(s, ssub(ln, firstindent + 1))
- end
- endline = i
- end
-
- local striptrailing = true
- local sep = '\n'
- local newlineatend = true
- if line == '|' then
- striptrailing = true
- sep = '\n'
- newlineatend = true
- elseif line == '|+' then
- striptrailing = false
- sep = '\n'
- newlineatend = true
- elseif line == '|-' then
- striptrailing = true
- sep = '\n'
- newlineatend = false
- elseif line == '>' then
- striptrailing = true
- sep = ' '
- newlineatend = true
- elseif line == '>+' then
- striptrailing = false
- sep = ' '
- newlineatend = true
- elseif line == '>-' then
- striptrailing = true
- sep = ' '
- newlineatend = false
- else
- error('invalid blockstyle string:'..line)
- end
- local _, eonl = s[#s]:gsub('\n', '\n')
- s[#s] = rtrim(s[#s])
- if striptrailing then
- eonl = 0
- end
- if newlineatend then
- eonl = eonl + 1
- end
- for i = endline, 1, -1 do
- tremove(lines, i)
- end
- return tconcat(s, sep)..string.rep('\n', eonl)
-end
-
-local function parsetimestamp(line)
- local _, p1, y, m, d = sfind(line, '^(%d%d%d%d)%-(%d%d)%-(%d%d)')
- if not p1 then
- return nil, line
- end
- if p1 == #line then
- return types.timestamp(y, m, d), ''
- end
- local _, p2, h, i, s = sfind(line, '^[Tt ](%d+):(%d+):(%d+)', p1+1)
- if not p2 then
- return types.timestamp(y, m, d), ssub(line, p1+1)
- end
- if p2 == #line then
- return types.timestamp(y, m, d, h, i, s), ''
- end
- local _, p3, f = sfind(line, '^%.(%d+)', p2+1)
- if not p3 then
- p3 = p2
- f = 0
- end
- local zc = ssub(line, p3+1, p3+1)
- local _, p4, zs, z = sfind(line, '^ ?([%+%-])(%d+)', p3+1)
- if p4 then
- z = tonumber(z)
- local _, p5, zi = sfind(line, '^:(%d+)', p4+1)
- if p5 then
- z = z + tonumber(zi) / 60
- end
- z = zs == '-' and -tonumber(z) or tonumber(z)
- elseif zc == 'Z' then
- p4 = p3 + 1
- z = 0
- else
- p4 = p3
- z = false
- end
- return types.timestamp(y, m, d, h, i, s, f, z), ssub(line, p4+1)
-end
-
-local function parsescalar(line, lines, indent)
- line = trim(line)
- line = gsub(line, '^%s*#.*$', '') -- comment only -> ''
- line = gsub(line, '^%s*', '') -- trim head spaces
-
- if line == '' or line == '~' then
- return null
- end
-
- local ts, _ = parsetimestamp(line)
- if ts then
- return ts
- end
-
- local s, _ = parsestring(line)
- -- startswith quote ... string
- -- not startswith quote ... maybe string
- if s and (startswith(line, '"') or startswith(line, "'")) then
- return s
- end
-
- if startswith('!', line) then -- unexpected tagchar
- error('unsupported line: '..line)
- end
-
- if equalsline(line, '{}') then
- return {}
- end
- if equalsline(line, '[]') then
- return {}
- end
-
- if startswith(line, '{') or startswith(line, '[') then
- return parseflowstyle(line, lines)
- end
-
- if startswith(line, '|') or startswith(line, '>') then
- return parseblockstylestring(line, lines, indent)
- end
-
- -- Regular unquoted string
- line = gsub(line, '%s*#.*$', '') -- trim tail comment
- local v = line
- if v == 'null' or v == 'Null' or v == 'NULL'then
- return null
- elseif v == 'true' or v == 'True' or v == 'TRUE' then
- return true
- elseif v == 'false' or v == 'False' or v == 'FALSE' then
- return false
- elseif v == '.inf' or v == '.Inf' or v == '.INF' then
- return math.huge
- elseif v == '+.inf' or v == '+.Inf' or v == '+.INF' then
- return math.huge
- elseif v == '-.inf' or v == '-.Inf' or v == '-.INF' then
- return -math.huge
- elseif v == '.nan' or v == '.NaN' or v == '.NAN' then
- return 0 / 0
- elseif sfind(v, '^[%+%-]?[0-9]+$') or sfind(v, '^[%+%-]?[0-9]+%.$')then
- return tonumber(v) -- : int
- elseif sfind(v, '^[%+%-]?[0-9]+%.[0-9]+$') then
- return tonumber(v)
- end
- return s or v
-end
-
-local parsemap; -- : func
-
-local function parseseq(line, lines, indent)
- local seq = setmetatable({}, types.seq)
- if line ~= '' then
- error()
- end
- while #lines > 0 do
- -- Check for a new document
- line = lines[1]
- if startswith(line, '---') then
- while #lines > 0 and not startswith(lines, '---') do
- tremove(lines, 1)
- end
- return seq
- end
-
- -- Check the indent level
- local level = countindent(line)
- if level < indent then
- return seq
- elseif level > indent then
- error("found bad indenting in line: ".. line)
- end
-
- local i, j = sfind(line, '%-%s+')
- if not i then
- i, j = sfind(line, '%-$')
- if not i then
- return seq
- end
- end
- local rest = ssub(line, j+1)
-
- if sfind(rest, '^[^\'\"%s]*:%s*$') or sfind(rest, '^[^\'\"%s]*:%s+.') then
- -- Inline nested hash
- -- There are two patterns need to match as inline nested hash
- -- first one should have no other characters except whitespace after `:`
- -- and the second one should have characters besides whitespace after `:`
- --
- -- value:
- -- - foo:
- -- bar: 1
- --
- -- and
- --
- -- value:
- -- - foo: bar
- --
- -- And there is one pattern should not be matched, where there is no space after `:`
- -- in below, `foo:bar` should be parsed into a single string
- --
- -- value:
- -- - foo:bar
- local indent2 = j
- lines[1] = string.rep(' ', indent2)..rest
- tinsert(seq, parsemap('', lines, indent2))
- elseif sfind(rest, '^%-%s+') then
- -- Inline nested seq
- local indent2 = j
- lines[1] = string.rep(' ', indent2)..rest
- tinsert(seq, parseseq('', lines, indent2))
- elseif isemptyline(rest) then
- tremove(lines, 1)
- if #lines == 0 then
- tinsert(seq, null)
- return seq
- end
- if sfind(lines[1], '^%s*%-') then
- local nextline = lines[1]
- local indent2 = countindent(nextline)
- if indent2 == indent then
- -- Null seqay entry
- tinsert(seq, null)
- else
- tinsert(seq, parseseq('', lines, indent2))
- end
- else
- -- - # comment
- -- key: value
- local nextline = lines[1]
- local indent2 = countindent(nextline)
- tinsert(seq, parsemap('', lines, indent2))
- end
- elseif rest then
- -- Array entry with a value
- tremove(lines, 1)
- tinsert(seq, parsescalar(rest, lines))
- end
- end
- return seq
-end
-
-local function parseset(line, lines, indent)
- if not isemptyline(line) then
- error('not seq line: '..line)
- end
- local set = setmetatable({}, types.set)
- while #lines > 0 do
- -- Check for a new document
- line = lines[1]
- if startswith(line, '---') then
- while #lines > 0 and not startswith(lines, '---') do
- tremove(lines, 1)
- end
- return set
- end
-
- -- Check the indent level
- local level = countindent(line)
- if level < indent then
- return set
- elseif level > indent then
- error("found bad indenting in line: ".. line)
- end
-
- local i, j = sfind(line, '%?%s+')
- if not i then
- i, j = sfind(line, '%?$')
- if not i then
- return set
- end
- end
- local rest = ssub(line, j+1)
-
- if sfind(rest, '^[^\'\"%s]*:') then
- -- Inline nested hash
- local indent2 = j
- lines[1] = string.rep(' ', indent2)..rest
- set[parsemap('', lines, indent2)] = true
- elseif sfind(rest, '^%s+$') then
- tremove(lines, 1)
- if #lines == 0 then
- tinsert(set, null)
- return set
- end
- if sfind(lines[1], '^%s*%?') then
- local indent2 = countindent(lines[1])
- if indent2 == indent then
- -- Null array entry
- set[null] = true
- else
- set[parseseq('', lines, indent2)] = true
- end
- end
-
- elseif rest then
- tremove(lines, 1)
- set[parsescalar(rest, lines)] = true
- else
- error("failed to classify line: "..line)
- end
- end
- return set
-end
-
-function parsemap(line, lines, indent)
- if not isemptyline(line) then
- error('not map line: '..line)
- end
- local map = setmetatable({}, types.map)
- while #lines > 0 do
- -- Check for a new document
- line = lines[1]
- if startswith(line, '---') then
- while #lines > 0 and not startswith(lines, '---') do
- tremove(lines, 1)
- end
- return map
- end
-
- -- Check the indent level
- local level, _ = countindent(line)
- if level < indent then
- return map
- elseif level > indent then
- error("found bad indenting in line: ".. line)
- end
-
- -- Find the key
- local key
- local s, rest = parsestring(line)
-
- -- Quoted keys
- if s and startswith(rest, ':') then
- local sc = parsescalar(s, {}, 0)
- if sc and type(sc) ~= 'string' then
- key = sc
- else
- key = s
- end
- line = ssub(rest, 2)
- else
- error("failed to classify line: "..line)
- end
-
- key = checkdupekey(map, key)
- line = ltrim(line)
-
- if ssub(line, 1, 1) == '!' then
- -- ignore type
- local rh = ltrim(ssub(line, 3))
- local typename = smatch(rh, '^!?[^%s]+')
- line = ltrim(ssub(rh, #typename+1))
- end
-
- if not isemptyline(line) then
- tremove(lines, 1)
- line = ltrim(line)
- map[key] = parsescalar(line, lines, indent)
- else
- -- An indent
- tremove(lines, 1)
- if #lines == 0 then
- map[key] = null
- return map;
- end
- if sfind(lines[1], '^%s*%-') then
- local indent2 = countindent(lines[1])
- map[key] = parseseq('', lines, indent2)
- elseif sfind(lines[1], '^%s*%?') then
- local indent2 = countindent(lines[1])
- map[key] = parseset('', lines, indent2)
- else
- local indent2 = countindent(lines[1])
- if indent >= indent2 then
- -- Null hash entry
- map[key] = null
- else
- map[key] = parsemap('', lines, indent2)
- end
- end
- end
- end
- return map
-end
-
-
--- : (list<str>)->dict
-local function parsedocuments(lines)
- lines = compactifyemptylines(lines)
-
- if sfind(lines[1], '^%%YAML') then tremove(lines, 1) end
-
- local root = {}
- local in_document = false
- while #lines > 0 do
- local line = lines[1]
- -- Do we have a document header?
- local docright;
- if sfind(line, '^%-%-%-') then
- -- Handle scalar documents
- docright = ssub(line, 4)
- tremove(lines, 1)
- in_document = true
- end
- if docright then
- if (not sfind(docright, '^%s+$') and
- not sfind(docright, '^%s+#')) then
- tinsert(root, parsescalar(docright, lines))
- end
- elseif #lines == 0 or startswith(line, '---') then
- -- A naked document
- tinsert(root, null)
- while #lines > 0 and not sfind(lines[1], '---') do
- tremove(lines, 1)
- end
- in_document = false
- -- XXX The final '-+$' is to look for -- which ends up being an
- -- error later.
- elseif not in_document and #root > 0 then
- -- only the first document can be explicit
- error('parse error: '..line)
- elseif sfind(line, '^%s*%-') then
- -- An array at the root
- tinsert(root, parseseq('', lines, 0))
- elseif sfind(line, '^%s*[^%s]') then
- -- A hash at the root
- local level = countindent(line)
- tinsert(root, parsemap('', lines, level))
- else
- -- Shouldn't get here. @lines have whitespace-only lines
- -- stripped, and previous match is a line with any
- -- non-whitespace. So this clause should only be reachable via
- -- a perlbug where \s is not symmetric with \S
-
- -- uncoverable statement
- error('parse error: '..line)
- end
- end
- if #root > 1 and Null.isnull(root[1]) then
- tremove(root, 1)
- return root
- end
- return root
-end
-
---- Parse yaml string into table.
-local function parse(source)
- local lines = {}
- for line in string.gmatch(source .. '\n', '(.-)\r?\n') do
- tinsert(lines, line)
- end
-
- local docs = parsedocuments(lines)
- if #docs == 1 then
- return docs[1]
- end
-
- return docs
-end
-
-return {
- version = 0.1,
- parse = parse,
-}