% \title{Commands to show \href{https://www.first.org/tlp/}{TLP 2.0} \\ (Traffic Light Protocol) \\ labels} % % \author{Jan Starke \\ \texttt{jan.starke@bdosecurity.de}} % % \changes{0.1}{07.04.2025}{inital Version} % \changes{0.2}{08.04.2025}{rename package to traffic-light-protocol} % \iffalse %<*driver> \ProvidesFile{traffic-light-protocol.dtx} % %<*package> \NeedsTeXFormat{LaTeX2e}[2003/12/01] \ProvidesPackage{traffic-light-protocol}[2025/04/08 v0.2] % %<*driver> \PassOptionsToPackage{numbered}{hypdoc} \documentclass{ltxdoc} \usepackage{hypdoc} \usepackage{hyperref} \usepackage{traffic-light-protocol} \RecordChanges \begin{document} \DocInput{\jobname.dtx} \end{document} % % \fi % % \maketitle % % \AtEndDocument{\PrintChanges} % % \tableofcontents % \newpage % \PrintIndex % \newpage % \begin{abstract} % This document describes usage and implementation of the |traffic-light-protocol| package, % which allows typesetting TLP labels in your document.tags % \end{abstract} % % \section{Usage} % % You can simply use this package by calling the |\tlp| \marg{level} command. % For example, calling |\tlp{red}| yields \tlp{red}. % % This package provides the following options for the |\tlp| command: % % \begin{center} % \begin{tabular}{ll} % \tt red & \tlp{red}\\\hline % \tt amber & \tlp{amber}\\\hline % \tt amber+strict & \tlp{amber+strict}\\\hline % \tt green & \tlp{green}\\\hline % \tt clear & \tlp{clear}\\ % \end{tabular} % \end{center} % % \section{Package options} % This package allows to set one of the options |rgb| or |cmyk|, which % control whether use CMYK or RGB to define colors % (the TLP standard allow any of them). % % \clearpage % % \section{Implementation} % % We rely on some package to display colored boxes: % % \begin{macrocode} \RequirePackage{expl3} \RequirePackage{l3keys2e} \RequirePackage{xcolor} % \end{macrocode} % % Load and execute package options % % \begin{macrocode} \ExplSyntaxOn \str_new:N\tlp_font_color \str_new:N\tlp_name \str_new:N\tlp_bg_color \str_set:Nn\tlp_bg_color{tlp-bg-black} \str_new:N\color_mode \str_set:Nn\color_mode{rgb} \keys_define:nn { tlp }{ color-mode .choice:, color-mode/rgb .code:n = \str_set:N\color_mode{rgb}, color-mode/cmyk .code:n = \str_set:N\color_mode{cmyk}, level .choice:, level / red .code:n = \str_set:Nn\tlp_font_color{tlp-font-red} \str_set:Nn\tlp_name{RED}, level / amber .code:n = \str_set:Nn\tlp_font_color{tlp-font-amber} \str_set:Nn\tlp_name{AMBER}, level / amber+strict .code:n = \str_set:Nn\tlp_font_color{tlp-font-amber} \str_set:Nn\tlp_name{AMBER+STRICT}, level / green .code:n = \str_set:Nn\tlp_font_color{tlp-font-green} \str_set:Nn\tlp_name{GREEN}, level / clear .code:n = \str_set:Nn\tlp_font_color{tlp-font-clear} \str_set:Nn\tlp_name{CLEAR}, } \ProcessKeysPackageOptions{tlp/color-mode} \ExplSyntaxOff % \end{macrocode} % % \subsection{Color definitions} % % The following color definitions are based on the % \href{https://www.first.org/tlp/}{TLP 2.0} standard. % % \begin{macrocode} % \ExplSyntaxOn \msg_new:nnn{traffic-light-protocol}{illegal_color_mode} {Illegal\ color\ mode:\ #1\ (only\ 'rgb'\ and\ 'cmyk'\ are\ supported)} \cs_new_protected_nopar:Npn\tlp_set_rgb_colornames:{ \definecolor{tlp-bg-black}{RGB}{0,0,0} \definecolor{tlp-font-red}{RGB}{255,43,43} \definecolor{tlp-font-amber}{RGB}{255,192,0} \definecolor{tlp-font-green}{RGB}{51,255,0} \definecolor{tlp-font-clear}{RGB}{255,255,255} } \cs_new_protected_nopar:Npn\tlp_set_cmyk_colornames:{ \definecolor{tlp-bg-black}{CMYK}{0,0,0,255} \definecolor{tlp-font-red}{CMYK}{0,83,83,0} \definecolor{tlp-font-amber}{CMYK}{0,25,100,0} \definecolor{tlp-font-green}{CMYK}{79,0,100,0} \definecolor{tlp-font-clear}{CMYK}{0,0,0,0} } \str_case:NnF\color_mode { {rgb} {\tlp_set_rgb_colornames:} {cmyk} {\tlp_set_cmyk_colornames:} } {\msg_err:nnV{traffic-light-protocol}{illegal_color_mode}{\color_mode}} \ExplSyntaxOff % \end{macrocode} % % Now we can define the |\tlp| macro. % % \begin{macro}{\tlp} % \begin{macrocode} \ExplSyntaxOn \NewDocumentCommand{\tlp}{m}{ \keys_set:nn{tlp/level}{#1} \colorbox{\str_use:N\tlp_bg_color} {\textcolor{\str_use:N\tlp_font_color}{ \textsf{\textbf{TLP:\str_use:N\tlp_name}}}} } \ExplSyntaxOff % \end{macrocode} % \end{macro} %