From 882fb8f154cced15063a1a2371bdc2fb7cdd189b Mon Sep 17 00:00:00 2001 From: Pierre Beaujean Date: Tue, 23 Apr 2024 21:34:51 +0200 Subject: [PATCH] [WIP] Upgrade and clean (#143) * add GH action (that will fail) * caching * star * at least one successful test to create cache * add extra packages * non mais ...OH! * fix all other tests * exemple of complex tables * parbox in Quotation (fix #141) * use new member URL (fix #136) * no more bsc on authors (fix #100) * correct iframe color * I indeed forgot to texlua --- .github/workflows/tests.yml | 59 +++++++++++++++++++ .travis.yml | 45 -------------- documentation.md | 15 ++++- scripts/install_texlive.sh | 4 -- scripts/packages | 2 + tests/Makefile | 2 - tests/test.tex | 114 +++++++++++++++++++----------------- tests/testlua.lua.expected | 10 ++-- tests/travis.patch | 3 - tobi.txt | 5 -- zmdocument.cls | 20 +++---- zmdocument.lua | 15 +++-- 12 files changed, 160 insertions(+), 134 deletions(-) create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml delete mode 100644 tests/travis.patch delete mode 100644 tobi.txt diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..3dd1514 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,59 @@ +name: Run tests + +env: + TEXMFDIR: ${HOME}/.texlive/texmf-local/tex/latex/ + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.12' + - name: Install dependencies + run: | + sudo apt-get install imagemagick librsvg2-bin + pip install Pygments + - name: Use cache + id: cache-install + uses: actions/cache@v3 + with: + path: | + ~/.texlive + key: texlive + - name: Set up TeXLive + run: | + ./scripts/install_font.sh + ./scripts/install_texlive.sh + echo "PATH=${HOME}/.texlive/bin/x86_64-linux:$PATH" >> $GITHUB_ENV + - name: Set up template + run: | + mkdir -p ${{ env.TEXMFDIR }} + ln -s ${PWD} ${{ env.TEXMFDIR }}/latex-template + texhash + - name: Test Lua + run: | + cd tests + make lua-test + - name: Test LaTeX + run: | + cd tests + make simple-test + make author-test + make images-test + make nocolor-test + make big-test + make big-toc-test + - name: Remove template from TeXLive before caching + run: | + rm ${{ env.TEXMFDIR }}/latex-template + texhash diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e89e362..0000000 --- a/.travis.yml +++ /dev/null @@ -1,45 +0,0 @@ -# Copied from Zeste de Savoir, -# https://github.com/zestedesavoir/zds-site/blob/a16c5fc932b361cbee5c6e61b24167605e24cd8b/.travis.yml - -dist: trusty - -language: python - -python: - - 2.7 - -git: - depth: 1 - -cache: - apt: true - directories: - - $HOME/.texlive - -addons: - apt: - packages: - - imagemagick - - librsvg2-bin - -install: - - ./scripts/install_font.sh - - ./scripts/install_texlive.sh - - export PATH=$HOME/.texlive/bin/x86_64-linux:$PATH - - pip install Pygments - -script: - - CURR=$(pwd) - - cd tests/ # run lua test first, otherwise it will not find zmdocument.lua - - make lua-test - - cd .. - - TEMPLATEDIR=$HOME/.texlive/texmf-local/tex/latex/latex-template - - TESTDIR=/tmp/latex-template-test - - mkdir -p $TEMPLATEDIR && cp -r . $TEMPLATEDIR && texhash - - mkdir -p $TESTDIR && cp -r ./tests/* $TESTDIR - - cd $TESTDIR - - patch Makefile < travis.patch # no cheating - - make tests - - cd $CURR - - rm -Rf $TESTDIR && rm -Rf $TEMPLATEDIR # avoid the package to be cached! - - texhash # avoid weird stuffs diff --git a/documentation.md b/documentation.md index 6a4b3be..0e8cd4f 100644 --- a/documentation.md +++ b/documentation.md @@ -165,7 +165,7 @@ A \LaTeX command. ## Float environments -In addition to standard float (`table`, `figure`), the `equationFloat` could be used to have mathematics floats or to add a caption to an equation. +In addition to standard float (`figure`), the `equationFloat` could be used to have mathematics floats or to add a caption to an equation. ```latex \[ @@ -174,6 +174,19 @@ In addition to standard float (`table`, `figure`), the `equationFloat` could be \captionof{equationfloat}{A sum} ``` +## Tabl + +This template now relies on [`tabularray`](https://github.com/lvjr/tabularray), and one should thus use the specific `zdstblr` environment to create table. + +```latex +\begin{zdstblr}{ccc} +element & element & element\\ +element & element & element\\ +element & element & element\\ +\end{zdstblr} +\captionof{table}{Légende du tableau} +``` + ## Appendices To add an appendix, use the `Appendix` environment. Appendix will be grouped in order of apparition at the end of the document. diff --git a/scripts/install_texlive.sh b/scripts/install_texlive.sh index a29e861..f75a1c9 100755 --- a/scripts/install_texlive.sh +++ b/scripts/install_texlive.sh @@ -36,10 +36,6 @@ function install_texlive { $HOME/.texlive/bin/x86_64-linux/tlmgr update --self $HOME/.texlive/bin/x86_64-linux/tlmgr install $EXTRA_PACKAGES - # Install tabu-fixed packages - mkdir -p $HOME/.texlive/texmf-local/tex/latex/tabu - wget -P $HOME/.texlive/texmf-local/tex/latex/tabu https://raw.githubusercontent.com/tabu-issues-for-future-maintainer/tabu/master/tabu.sty - # save list of extra packages printf "$EXTRA_PACKAGES" > $EXTRA_PACKAGES_CACHE diff --git a/scripts/packages b/scripts/packages index ace169b..c6f9324 100644 --- a/scripts/packages +++ b/scripts/packages @@ -37,3 +37,5 @@ xfor xifthen xpatch xstring +tabularray +ninecolors diff --git a/tests/Makefile b/tests/Makefile index 4a49983..85690e2 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -11,8 +11,6 @@ help: @echo " help to get this help" %.pdf: %.tex - export TEXINPUTS=".:../:$${TEXINPUTS}";\ - export LUAINPUTS=".:../:$${LUAINPUTS}";\ $(TEX) $(TEXFLAGS) $(DRAFTFLAG) $<;\ $(TEX) $(TEXFLAGS) $(DRAFTFLAG) $<;\ makeglossaries $(basename $<); \ diff --git a/tests/test.tex b/tests/test.tex index 6f08e38..eb449b3 100644 --- a/tests/test.tex +++ b/tests/test.tex @@ -97,6 +97,8 @@ \begin{Quotation}[Clem] Zeste de Savoir, la connaissance pour tous et sans pépins \smiley{diable} + +Avec des vrais morceaux de paragraphe dedans ! \end{Quotation} La suite, avec des touches \keys{CTRL + A}. Et on peut avoir une ligne avec @@ -202,35 +204,35 @@ Et finalement, un tableau: -\begin{longtabu}{|c|c|c|} \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -\caption{Légende} -\end{longtabu} +\begin{zdstblr}{ccc} +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +\end{zdstblr} +\captionof{table}{Légende du tableau} Notons que si une image est dans un tableau, elle est redimensionnée si elle est trop grande. @@ -238,17 +240,19 @@ De plus, on peut faire des tableaux compliqués, avec de la fusion de ligne ou de colonnes, et même des paragraphes dans les cases du tableau. -\begin{longtabu}{|m{\dimexpr(\linewidth) / 3}|m{\dimexpr(\linewidth) / 3}|m{\dimexpr(\linewidth) / 3}|} \hline - 1 - 1 & \multirow{2}{*}{\parbox{\linewidth}{\centering 1 - 2 \endgraf 2 - 2}} & 1 \par 32 \par 4 \\ \cline{1-1} \cline{3-3} - \rowfont[l]{} - 2 - 1 & & 2 - 3 \\ \hline - \rule{\linewidth}{1.0pt} & 3 - 2 & 3 - 3 \\ \hline - \end{longtabu} +\begin{zdstblr}{colspec={X[-1] X[-1] X[-1] X[-1]},rowhead=1,row{1}={font=\bfseries}} + Header 1 & Header 2 & Header 3 & Header 4 \\ + Cell 1 & Cell 2 & Cell 3 & Cell 4 \\ + Cell 5 & Cell 6 & Cell 7 & Cell 8 \\ +\end{zdstblr} -\begin{longtabu}{|m{\dimexpr(\linewidth) / 3}|m{\dimexpr(\linewidth) / 3}|m{\dimexpr(\linewidth) / 3}|} \hline - Colonne 1 & Colonne 2 & \inlineImage{test-images/logo.png} \\ \hline - \rule{\linewidth}{1.0pt} & 3 - 2 & 3 - 3 \\ \hline - \end{longtabu} +\begin{zdstblr}{colspec={X[-1] X[-1] X[-1] X[-1]},rowhead=2,row{1,2}={font=\bfseries}} + \SetCell[c=2]{l} Table Headings & & Here \\ + Sub & Headings & Too \\ + \SetCell[r=2]{l} cell \endgraf spans \endgraf rows & \SetCell[c=2]{l} column spanning & \\ + & normal & cell \\ + multi \endgraf line \endgraf \endgraf cells \endgraf too & \SetCell[c=2]{l} cells can be \endgraf \textit{formatted} \endgraf \textbf{paragraphs} & \\ +\end{zdstblr} \begin{Spoiler} @@ -268,14 +272,14 @@ Et un tableau: -\begin{longtabu}{|c|c|c|} \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -element & element & element\\ \hline -\caption{Légende du tableau} -\end{longtabu} +\begin{zdstblr}{ccc} +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +element & element & element\\ +\end{zdstblr} +\captionof{table}{Légende du tableau} Et une citation: @@ -324,14 +328,14 @@ ou des tableaux \footnote{Exemple de note \begin{Appendix} -\begin{longtabu}{|c|c|c|} \hline - element & element & element\\ \hline - element & element & element\\ \hline - element & element & element\\ \hline - element & element & element\\ \hline - element & element & element\\ \hline - \caption{Légende du tableau} - \end{longtabu} +\begin{zdstblr}{ccc} + element & element & element\\ + element & element & element\\ + element & element & element\\ + element & element & element\\ + element & element & element\\ + \end{zdstblr} + \captionof{table}{Légende du tableau} \end{Appendix} où il y a un tableau } ; diff --git a/tests/testlua.lua.expected b/tests/testlua.lua.expected index 32935c6..8958df3 100644 --- a/tests/testlua.lua.expected +++ b/tests/testlua.lua.expected @@ -1,14 +1,14 @@ % --- Test authors % one author: -\href{/Eskimon/}{\color{titlePageAuthorColor}\bsc{Eskimon}}\\ +\href{Eskimon}{\color{titlePageAuthorColor}{Eskimon}}\\ % three authors: -\href{/Karnaj/}{\color{titlePageAuthorColor}\bsc{Karnaj}}\\,\href{/Heziode/}{\color{titlePageAuthorColor}\bsc{Heziode}}\\,\href{/pierre_24/}{\color{titlePageAuthorColor}\bsc{pierre_24}}\\ +\href{Karnaj}{\color{titlePageAuthorColor}{Karnaj}}\\,\href{Heziode}{\color{titlePageAuthorColor}{Heziode}}\\,\href{pierre_24}{\color{titlePageAuthorColor}{pierre_24}}\\ % one author with link: -\href{http://test.com/author/Eskimon/}{\color{titlePageAuthorColor}\bsc{Eskimon}}\\ +\href{http://test.com/authorEskimon}{\color{titlePageAuthorColor}{Eskimon}}\\ % one author with long name: -\href{/that_author_with_a_very_long_name/}{\color{titlePageAuthorColor}\bsc{that_author_...}}\\ +\href{that_author_with_a_very_long_name}{\color{titlePageAuthorColor}{that_author_with_a_ver...}}\\ % one author with long name (but in author list, so full name): -\href{/that_author_with_a_very_long_name/}{\color{titlePageAuthorColor}\bsc{that_author_with_a_very_long_name}}\\ +\href{that_author_with_a_very_long_name}{\color{titlePageAuthorColor}{that_author_with_a_very_long_name}}\\ % --- Test abbrv AT(amp)T pierre(und)24 diff --git a/tests/travis.patch b/tests/travis.patch deleted file mode 100644 index 3b21e49..0000000 --- a/tests/travis.patch +++ /dev/null @@ -1,3 +0,0 @@ -14,15d13 -< export TEXINPUTS=".:../:$${TEXINPUTS}";\ -< export LUAINPUTS=".:../:$${LUAINPUTS}";\ diff --git a/tobi.txt b/tobi.txt deleted file mode 100644 index 348a616..0000000 --- a/tobi.txt +++ /dev/null @@ -1,5 +0,0 @@ - a - - b - c - \href{pokemon} diff --git a/zmdocument.cls b/zmdocument.cls index 71481ee..3b89eb7 100644 --- a/zmdocument.cls +++ b/zmdocument.cls @@ -160,6 +160,12 @@ \definecolor{ZdSBoxBorderNeutral}{HTML}{\iftoggle{nocolor}{4D4D4D}{4D4D4D}} \definecolor{ZdSBoxLogoBackgroundNeutral}{HTML}{\iftoggle{nocolor}{808080}{808080}} +% Iframe +\definecolor{ZdSBoxForegroundIframe}{HTML}{\iftoggle{nocolor}{424242}{7BB027}} +\definecolor{ZdSBoxBackgroundIframe}{HTML}{\iftoggle{nocolor}{FFFFFF}{F3FDE2}} +\definecolor{ZdSBoxBorderIframe}{HTML}{\iftoggle{nocolor}{4D4D4D}{7BB027}} +\definecolor{ZdSBoxLogoBackgroundIframe}{HTML}{\iftoggle{nocolor}{808080}{7BB027}} + % SPOILER \definecolor{ZdSBoxForegroundSpoiler}{HTML}{555555} \definecolor{ZdSBoxBackgroundSpoiler}{HTML}{EEEEEE} @@ -339,8 +345,6 @@ {\end{#2}\end{minipage}} } -\newZdSBox{IframeBox}{Élément externe}{iframeColor} - % Create box icon \newcommand{\createBoxIcon}[2]{ \begin{tikzpicture} % @@ -381,6 +385,7 @@ \newBox{Warning}{ZdSBoxBackgroundWarning}{ZdSBoxForegroundWarning}{ZdSBoxBorderWarning}{ZdSBoxLogoBackgroundWarning}[!] \newBox{Error}{ZdSBoxBackgroundError}{ZdSBoxForegroundError}{ZdSBoxBorderError}{ZdSBoxLogoBackgroundError}[\times] \newBox{Neutral}{ZdSBoxBackgroundNeutral}{ZdSBoxForegroundNeutral}{ZdSBoxBorderNeutral}{ZdSBoxLogoBackgroundNeutral} +\newBox{Iframe}{ZdSBoxBackgroundIframe}{ZdSBoxForegroundIframe}{ZdSBoxBorderIframe}{ZdSBoxLogoBackgroundIframe}[\#] %%% QUOTATION \DeclareTColorBox{Quotation}{ o }{% @@ -389,6 +394,7 @@ borderline west={1mm}{0pt}{ZdSBoxBorderLeftQuotation}, coltext=ZdSBoxForegroundQuotation, left=18pt, + parbox=false, IfValueTF={#1}{after upper={\par\center\textit{#1}}}{} } @@ -447,14 +453,8 @@ \newcommand{\CodeInline}[1]{\texorpdfstring{\hl{\texttt{\small #1}}}{#1}} %%% IFRAMES -\newenvironment{Iframe}[1]{% - ~\\ \begin{minipage}{\linewidth}\begin{IframeBox}[#1] -}{% - \end{IframeBox}\end{minipage} -} - \NewDocumentCommand\iframe{mO{vidéo}o}{% - \begin{Iframe}{#2} + \begin{Iframe}[#2] Consultez cet élément à l'adresse \url{#1}.\IfValueT{#3}{\\ #3} \end{Iframe} } @@ -636,7 +636,7 @@ \renewcommand{\maketitle}{% \setcounter{page}{0} - \ifcsdef{@authorlink}{}{\authorlink{https://zestedesavoir.com/membres/voir}} + \ifcsdef{@authorlink}{}{\authorlink{https://zestedesavoir.com/@}} \ifcsdef{@website}{}{\website{https://zestedesavoir.com}} \ifcsdef{@editor}{}{\editor{https://zestedesavoir.com}} \ifcsdef{@logo}{}{\logo{default_logo.png}} diff --git a/zmdocument.lua b/zmdocument.lua index 9a6baeb..3e1a87d 100644 --- a/zmdocument.lua +++ b/zmdocument.lua @@ -1,7 +1,7 @@ package.path = 'utf8.lua/?.lua;' .. package.path utf8 = require 'utf8' -AUTHOR_MAX_SIZE = 15 +AUTHOR_MAX_SIZE = 25 AUTHOR_MAX_DISPLAY = 11 AUTHOR_LINK = "" ARRAY_AUTHORS = {} @@ -107,14 +107,21 @@ function createStrAuthors(all) display_name = ARRAY_AUTHORS[i].name end - tab[i] = "\\href{" .. AUTHOR_LINK .. "/" .. ARRAY_AUTHORS[i].name .. "/}{\\color{titlePageAuthorColor}\\bsc{" .. display_name .. "}}\\\\" + tab[i] = "\\href{" .. AUTHOR_LINK .. ARRAY_AUTHORS[i].name .. "}{\\color{titlePageAuthorColor}{" .. display_name .. "}}\\\\" end local strAuthors = implode (",", tab) if ARRAY_AUTHORS_SIZE > AUTHOR_MAX_DISPLAY and not all then - strAuthors = strAuthors .. ", \\hyperlink{authorsList}{\\color{titlePageAuthorColor}\\bsc{et " .. - (ARRAY_AUTHORS_SIZE - AUTHOR_MAX_DISPLAY) .. " autre(s) auteur(s)}}\\\\" + strAuthors = strAuthors .. ", \\hyperlink{authorsList}{\\color{titlePageAuthorColor}{et " .. (ARRAY_AUTHORS_SIZE - AUTHOR_MAX_DISPLAY) + + if (ARRAY_AUTHORS_SIZE - AUTHOR_MAX_DISPLAY) > 1 then + strAuthors = strAuthors .. " autres auteurs" + else + strAuthors = strAuthors .. " autre auteur" + end + + strAuthors = strAuthors .. ".}}\\\\" end return strAuthors