\ProvidesPackage{rustex}[2022/01/11]
\RequirePackage{xspace}

\ifcsname if@rustex\endcsname\else
	\expandafter\newif\csname if@rustex\endcsname
	\@rustexfalse
\fi

\if@rustex\else
	\def\rustex@directHTML#1{}
	% usage: plain HTML as argument, e.g.
	% \rustex@directHTML{<div>foo</div>}
	
	\def\rustex@annotateHTML#1{}
	\def\rustex@annotateHTMLEnd{}
	% usage: First argument: attributes and styles
	% attribute names may contain URL prefixes
	% styles should be prefixed with style:
	% second argument: The stuff that gets annotated
	% e.g.
	%\rustex@annotateHTML{rustex:mycolor="grey" style:fontsize="150\%"}hello\rustex@annotateHTMLEnd

	\def\rustex@addNamespaceAbbrev#1#2{}
	% e.g. \rustex@addNamespaceAbbrev{stex}{http://kwarc.info/ns/sTeX}
	\def\rustexBREAK{}
\fi

\ifcsname ExplSyntaxOn\endcsname
	\ExplSyntaxOn
		\prg_new_conditional:Nnn \rustex_if: {p, T, F, TF} {
			\if@rustex
				\prg_return_true:
			\else:
				\prg_return_false:
			\fi:
		}
		\rustex_if:TF {
			\cs_new_protected:Nn\rustex_direct_HTML:n {
				\cs:w rustex@directHTML\cs_end:{#1}
			}
			\cs_set_eq:Nc\rustex_annotate_HTML_begin:n {rustex@annotateHTML}
			\cs_set_eq:Nc\rustex_annotate_HTML_end: {rustex@annotateHTMLEnd}
			\cs_new_protected:Nn\rustex_annotate_HTML:nn {
				\rustex_annotate_HTML_begin:n{#1}
					#2
				\rustex_annotate_HTML_end:
			}
			\cs_set_eq:Nc\rustex_add_Namespace:nn{rustex@addNamespaceAbbrev}
		}{
			\cs_new_protected:Nn\rustex_direct_HTML:n {}
			\cs_new_protected:Nn\rustex_annotate_HTML_begin:n {}
			\cs_new_protected:Nn\rustex_annotate_HTML_end: {}
			\cs_new_protected:Nn\rustex_annotate_HTML:nn {#2}
			\cs_new_protected:Nn\rustex_add_Namespace:nn {}
		}
	\ExplSyntaxOff
\fi

\protected\def\RusTeX{%
  \@ifundefined{texorpdfstring}%
  {\let\texorpdfstring\@firstoftwo}%
  {}%
  \texorpdfstring{R\kern-0.1em\raise-0.1em\hbox{\scriptsize US}\kern-0.2em\TeX}{RusTeX}\xspace%
}
\let\rustex\RusTeX