% \iffalse meta-comment
% ======================================================================
% scrkernel-tagging.dtx
% Copyright (c) Markus Kohm, 2026
%
% This file is part of the LaTeX2e KOMA-Script bundle.
%
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, version 1.3c of the license.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later and of this work.
%
% This work has the LPPL maintenance status "author-maintained".
%
% The Current Maintainer and author of this work is Markus Kohm.
%
% This work consists of all files listed in MANIFEST.md.
% ======================================================================
%%% From File: $Id: scrkernel-tagging.dtx 4032 2023-04-17 09:45:11Z kohm $
%%%% (run: init)
%%%% (run: verylate)
%<*dtx>
\ifx\ProvidesFile\undefined\def\ProvidesFile#1[#2]{}\fi
\begingroup
\def\filedate$#1: #2-#3-#4 #5${\gdef\filedate{#2/#3/#4}}
\filedate$Date: 2023-04-17 11:45:11 +0200 (Mo, 17. Apr 2023) $
\def\filerevision$#1: #2 ${\gdef\filerevision{r#2}}
\filerevision$Revision: 4032 $
\edef\reserved@a{%
\noexpand\endgroup
\noexpand\ProvidesFile{scrkernel-tagging.dtx}%
[\filedate\space\filerevision\space
KOMA-Script source
(tagging)]%
}%
\reserved@a
\documentclass[USenglish]{koma-script-source-doc}
\usepackage{babel}
\setcounter{StandardModuleDepth}{2}
\begin{document}
\DocInput{scrkernel-tagging.dtx}
\end{document}
%
% \fi
%
% \changes{v3.49.3}{2026/06/16}{new}
%
% \GetFileInfo{scrkernel-tagging.dtx}
% \title{Preparation for PDF Tagging}
% \author{\href{mailto:komascript@gmx.info}{Markus Kohm}}
% \date{Revision \fileversion{} of \filedate}
% \maketitle
% \begin{abstract}
% \filename{} is used by generation of classes and packages for PDF tagging.
% Note, that currently the file itself does not contain any code for PDF
% tagging but for detection of PDF tagging and automatic loading of external
% files if those are available.
% \end{abstract}
% \tableofcontents
%
% \section{User Manual}
%
% Currently not available.
%
% \MaybeStop{\PrintIndex}
%
% \section{Implementation of the Detection of Usage of Meta Data or Tagging}
%
% \changes{v3.49}{2025/09/11}{tagging warning added}
% \ExplSyntaxOn
% \begin{macro}{
% \komascript_tagging_test:,
% \komascript_documentmetadata_test:
% }
% \ExplSyntaxOff
% \changes{v3.49.3}{2026/06/13}{meta data error added}
% \changes{v3.49.3}{2026/06/16}{moved to from
% \file{scrkernel-miscellaneous.dtx}}
% \changes{v3.49.3}{2026/06/16}{message module name expansion added}
% In future \KOMAScript{} classes should support tagging, but currently they
% don't. So if tagging is enabled, we warn. I expect the tagging support to
% be added step by step. So the warning here will also change step by
% step. However the name of the message used to warn, will not change. So
% packages can add tagging support and also deactivate the message using
%\begin{verbatim}
%\msg_redirect_name:nnn { \KOMAClassName } { tagging-not-supported } { none }
%\end{verbatim}
% As an alternative packages (and wrapper classes) can change the test and
% messages by defining \cs{komascript_documentmetadata_test:}
% resp. \cs{komascript_tagging_test:} before loading the \KOMAScript{}
% class.
% \begin{macrocode}
%<*class>
\ExplSyntaxOn
%<*init>
\cs_if_exist:NF \komascript_documentmetadata_test:
{
\exp_args:NV \msg_new:nnn \KOMAClassName { metadata-not-supported }
{
\token_to_str:N\DocumentMetadata\ not~supported!\\
Note:~This~class~currently~does~not~support~usage~of~
\token_to_str:N\DocumentMetadata.\\
Instead~of~using~\token_to_str:N\DocumentMetadata\ you~should~
currently~use:\\
\ \ \token_to_str:N\RequirePackage{pdfmanagement}\\
\ \ \token_to_str:N\SetKeys[document/metadata]{...}\\
before~\token_to_str:N\documentclass.
}
\cs_new:Npn \komascript_documentmetadata_test:
{
\cs_if_exist:NT \IfDocumentMetadataT
{
\IfDocumentMetadataT
{
\exp_args:NV \msg_fatal:nn \KOMAClassName
{ metadata-not-supported }
}
}
}
}
%
% \end{macrocode}
% \begin{description}
% \item[Important note:] The following code of the test, i.e., with loading
% external tagging code from a package or file is very provisionally. It
% will be replaced soon by something completely different!
% \end{description}
% \begin{macrocode}
%<*verylate>
\IfDocumentMetadataT
{
\IfFileExists
{\KOMAClassName-tagging.sty}
{
\RequirePackage
{\KOMAClassName-tagging}
}
{
\InputIfFileExists
{\KOMAClassName-tagging-code.tex}
{}
{\komascript_documentmetadata_test:}
}
}
%
%<*init>
\cs_if_exist:NF \komascript_tagging_test:
{
\cs_new:Npn \komascript_tagging_test:
{
\cs_if_exist:NT \tag_if_active:T
{
\exp_args:NV \msg_new:nnn \KOMAClassName { tagging-not-supported }
{
Activated~tagging~detected~but~not~supported!\\
Note:~This~class~currently~does~not~actively~support~tagging.~
This~means:~Several~elements~will~not~be~tagged~correctly~
and~also~several~errors~could~happen.\\
Sorry!
}
\hook_gput_code:nnn { begindocument } { \KOMAClassName }
{
\tag_if_active:T
{
\exp_args:NV \msg_warning:nn
\KOMAClassName
{ tagging-not-supported }
}
}
}
}
}
%
%\komascript_tagging_test:
\ExplSyntaxOff
%
% \end{macrocode}
% \end{macro}
% \ExplSyntaxOff
%
% \Finale
% \PrintChanges
%
\endinput
% Local Variables:
% mode: doctex
% ispell-local-dictionary: "en_US"
% eval: (flyspell-mode 1)
% TeX-master: t
% TeX-engine: luatex-dev
% eval: (setcar (or (cl-member "Index" (setq-local TeX-command-list (copy-alist TeX-command-list)) :key #'car :test #'string-equal) (setq-local TeX-command-list (cons nil TeX-command-list))) '("Index" "mkindex %s" TeX-run-index nil t :help "makeindex for dtx"))
% End: