I am working on a macro which will build revision history table in my document using Git tags. Each published version of my document has a tag with short description. I want to use them to automatically build revision table while compiling with XeLaTeX in Windows.
Using Git command below i get all information I need to create the revision history table. Output is formatted in CSV-like format.
git for-each-ref --format='%(refname:short); %(taggerdate:short); %(subject); %(*authorname); %(*authoremail)' refs/tags
I modified a macro for parsing CSV file so that I can read the output of the Git command and build my revision history table (not formatted yet as table in the script).
\documentclass{article}
\newcommand{\printrow}[5]{tag: #1 (#3) at #2 by #4 #5 + \}
\begin{document}
\def\readrow #1;#2;#3;#4;#5;{\ifx^#5^\else
\printrow{#1}{#2}{#3}{#4}{#5}%
\expandafter\readrow\fi}
\def\startread {\readrow} % skip first row
\begingroup
\endlinechar=; \everyeof={;;;;;} \catcode@=11
\expandafter \startread @@input |"git revhist" %
\endgroup %
\end{document}
It works with pre-saved output of the command, but when I paste the full command string into \@@input and try to compile (xelatex -shell-escape .\read-git-history-test.tex), XeLaTeX complains:
{|"git for-each-ref --format='
! Paragraph ended before \@iinput was complete.
<to be read again>
\par
I did a workaround by defining Git alias (git revhist -see below) but if one of my colleagues will try to compile it without defining the alias, it will fail. No, they do not read REDAME's...
git config --global alias.revhist "for-each-ref --format='%(refname:short); %(taggerdate:short); %(subject); %(*authorname); %(*authoremail);' refs/tags"
Is it possible to call the full Git command in *.tex file not to corrupt it by the % signs?
\@percentcharor locally make%have catcode 12 – David Carlisle Apr 15 '22 at 12:09