%-----------------------------------------------------------------------------
%  Copyright (C) 2004-2019 Andrew Mathas, University of Sydney
%
%  Distributed under the terms of the GNU General Public License (GPL)
%                  http://www.gnu.org/licenses/
%
% This file is part of the WebQuiz system.
%
% <Andrew.Mathas@sydney.edu.au>
%-----------------------------------------------------------------------------

% common latex code in the documentation files
\RequirePackage{cmap} % fix search and cut-and-paste in Acrobat

\RequirePackage[utf8]{inputenc}
\RequirePackage[T1]{fontenc}

\RequirePackage{enumitem}
\setlist[itemize]{nosep}
\setlist[description]{
    font=\sffamily\bfseries\color{DodgerBlue},
    labelwidth=\textwidth
}

\RequirePackage{graphicx}

\RequirePackage{xspace}
\RequirePackage[svgnames]{xcolor}

\usepackage{hologo}
\newcommand\TeXfht{\href{https://www.ctan.org/tex4ht}{\hologo{TeX4ht}}\xspace}

\NewDocumentCommand\ctan{ O{pkg/#2} m}{\href{https://www.ctan.org/#1}{\texttt{#2}}\xspace}

\newcommand\HTML{\href{https://www.w3schools.com/html/html_intro.asp}{HTML}\xspace}
\newcommand\CSS{\href{https://www.w3schools.com/css}{CSS}\xspace}
\newcommand\XML{\href{https://www.w3schools.com/xml/xml_whatis.asp}{XML}\xspace}
\newcommand\Javascript{\href{https://www.w3schools.com/Js/}{Javascript}\xspace}
\newcommand\python[1][python]{\href{https://www.python.org/}{#1}\xspace}
\newcommand\Ghostscript{\href{https://www.ghostscript.com/}{Ghostscript}\xspace}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% listings code for python and latex examples in webquiz documentation
\RequirePackage{listings}
\lstset{%
    % Basic design
    backgroundcolor=\color{LightYellow!50!White},
    basicstyle={\small\ttfamily},
    boxpos=c, % centered
    % frame
    framerule=2pt,
    frame=l,
    framerule=0.5mm,
    rulesep=10mm,
    rulecolor=\color{Peru},
    breaklines=true,
    % colours for keywords etc
    commentstyle=\color{DarkRed},
    keywordstyle=\color{MediumBlue},
    linewidth=14cm,
    basewidth  = {.5em,0.5em},
    numbers=none,
    resetmargins=true,
    tabsize=2,
    xleftmargin=10mm,
    classoffset=1,
    % Code design
    keywordstyle={[1]\color{Blue}\bfseries},
    keywordstyle={[2]\color{ForestGreen}},
    keywordstyle={[3]\color{LimeGreen}},
    keywordstyle={[4]\color{DarkBlue}},
    commentstyle=\color{BurlyWood}\ttfamily,
    stringstyle=\color{Coral},
    tabsize=4,
    showtabs=false,
    showspaces=false,
    showstringspaces=false,
    inputencoding=utf8,
    extendedchars=true,
    literate={á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1
      {Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1
      {à}{{\`a}}1 {è}{{\`e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1
      {À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1
      {ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1
      {Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1
      {â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1
      {Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1
      {œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1
      {ű}{{\H{u}}}1 {Ű}{{\H{U}}}1 {ő}{{\H{o}}}1 {Ő}{{\H{O}}}1
      {ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1
      {€}{{\euro}}1 {£}{{\pounds}}1 {«}{{\guillemotleft}}1
      {»}{{\guillemotright}}1{ñ}{{\~n}}1{Ñ}{{\~N}}1{¿}{{?`}}1
      {á}{{\'a}}1{í}{{\'i}}1{é}{{\'e}}1{ý}{{\'y}}1{ú}{{\'u}}1{ó}{{\'o}}1
      {ě}{{\v{e}}}1{š}{{\v{s}}}1{č}{{\v{c}}}1{ř}{{\v{r}}}1{ž}{{\v{z}}}1{ď}{{\v{d}}}1
      {ť}{{\v{t}}}1{ň}{{\v{n}}}1{ů}{{\r{u}}}1{Á}{{\'A}}1{Í}{{\'I}}1{É}{{\'E}}1
      {Ý}{{\'Y}}1{Ú}{{\'U}}1{Ó}{{\'O}}1{Ě}{{\v{E}}}1{Š}{{\v{S}}}1{Č}{{\v{C}}}1
      {Ř}{{\v{R}}}1{Ž}{{\v{Z}}}1{Ď}{{\v{D}}}1{Ť}{{\v{T}}}1{Ň}{{\v{N}}}1{Ů}{{\r{U}}}1
}
\lstdefinestyle{latexcode}{
  language=[LaTeX]TeX,
  texcsstyle=*\bfseries\color{DodgerBlue},
  classoffset=1,
  morekeywords={UnitCode,UnitName,UnitURL,QuizzesURL,BreadCrumbs,BreadCrumb,Department,DepartmentURL,
                includegraphics,DeclareGraphicsExtensions,DisplayAsImage,thechoice,quiz,
                Institution,InstitutionURL,feedback,correct,incorrect,whenRight,whenWrong,answer,
                dref, qref, Qref},
  classoffset=2,
  morekeywords={quizindex, discussion, question, multiple, single, columns, choice},
  classoffset=3,
  alsoletter=2,
  morekeywords={theme, language, hide side menu, pst2pdf, tikz, fixed order, random order,
                show side menu, one page, separate pages, english, french, integer, complex,
                number, string, lowercase, pspicture},
  classoffset=4,
  morekeywords={tikzset, foreach, draw, filldraw, Configure, NewConfigure, csdef, csletcs, csuse,
                Picture, EndPicture, psplotThreeD, pstThreeDCoor, RequirePackage, DeclareGraphicsExtensions},
}
\lstnewenvironment{latexcode}{\lstset{style=latexcode}}{}
\NewDocumentCommand\LatexCode{v}{\lstinline[style=latexcode]|#1|}
\NewDocumentCommand\InputLatexCode{ O{examples/} m}{\lstinputlisting[style=latexcode]{#1#2}}

\lstdefinestyle{bashcode}{
  language=bash,
  upquote=true,
  classoffset=1,
  morekeywords={webquiz, kpsewhich, latex, pdflatex, xelatex. lualatex},
  classoffset=2,
  morekeywords={>}
}
\lstnewenvironment{bashcode}{\lstset{style=bashcode}}{}
\NewDocumentCommand\BashCode{v}{\lstinline[style=bashcode]|#1|}
\newcommand\InputBashCode[1]{\lstinputlisting[style=bashcode]{#1}}

\lstdefinestyle{pythoncode}{
  language=HTML,
  upquote=true,
  classoffset=1,
  morekeywords={quiz_page},
}
\lstnewenvironment{pythoncode}{\lstset{style=pythoncode}}{}
\NewDocumentCommand\PythonCode{v}{\lstinline[style=pythoncode]|#1|}
\newcommand\InputPythoCode[1]{\lstinputlisting[style=pythoncode]{#1}}

\lstdefinestyle{htmlcode}{
  language=HTML,
  upquote=true,
  morekeywords={no}
  classoffset=1,
  morekeywords={quiz_page, side_menu, quiz_questions, quiz_header, no_script, include, breadcrumbs,},
}
\lstnewenvironment{htmlcode}{\lstset{style=htmlcode}}{}
\NewDocumentCommand\HTMLCode{v}{\lstinline[style=htmlcode]|#1|}

\newcommand\DefaultValue[1]{\textcolor{ForestGreen}{\texttt{#1}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{tcolorbox}
\tcbuselibrary{skins}
\NewDocumentCommand\ScreenShot{ O{0.7} m O{examples/} m }{%
  \begin{center}
    \begin{tcolorbox}[width=#1\textwidth, title=#2, arc=3mm,
      colframe=Peru,
      boxrule=0.2mm,
      colback=white,
      halign=center,
      enhanced,
      attach boxed title to bottom right={yshift=3mm, xshift=-3mm},
      fonttitle=\footnotesize,
      boxed title style={size=fbox, colback=white, arc=2mm},
      coltitle=Peru,
    ] \includegraphics[width=\textwidth]{#3#4}
    \end{tcolorbox}
  \end{center}%
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% hyperref settings

\AtEndPreamble{
  \RequirePackage{hyperref}
  \hypersetup{%
      colorlinks=true,
      linkcolor=SaddleBrown,
      urlcolor=Brown,
      pdfauthor   = {\webquiz{authors}                       },
      pdfkeywords = {\webquiz{keywords}                      },
      pdfsubject  = {\webquiz{description}                   },
      pdfinfo     = {%
          copyright    = {\webquiz{copyright}},
          licence      = {\webquiz{licence}},
          release date = {\webquiz{release date}},
          url          = {\webquiz{url}},
      }
  }
}
\endinput
