[Tex/LaTex] Contract Bridge diagrams with LaTeX

diagrams

I write bridge diagram with LaTeX. Source file is in PBN format.
Hand is for exampe QT2 98 J962 AKJ6. How this string change to
\pika Q102\srdce 98 \karo J962 \tref AKJ6 ?

To begin \pika, first space \srdce , second space \karo and last space \tref and T is change to 10

Samples of diagram is on page http://new.bridgekosice.sk/bridzove-diagramy-vykrelene-pomocou-tex:

Source code for next diagram wittout parameters is

\begin{tabular}{|lll|}
\hline
Board 1 & \quad\pika Q102 &  \\

Deals: North& \quad\srdce 98 &   \\

Vul: none & \quad\karo J962 &  \\

& \quad\tref AKJ6  &  \\

\pika AJ54       & \multirow{4}{1}{\mstul}     & \pika K76       \\
\srdce 76        &                                    & \srdce AKQ52     \\
\karo A85         &                                    & \karo  Q107     \\

\tref  8432             &  & \tref 95 \\

\multirow{3}{1}{ \begin{tabular}{ccc} & 11 \\ & \,9 \quad\, 14 \\ & 6 \end{tabular}} & \quad\pika 983 &  \\

& \quad\srdce J1043 &  \\

& \quad\karo K43 &  \\

& \quad\tref Q107 &  \\

\hline
\end{tabular}

I can this write with

\bgdiagram{board}{n}{e}{s}{w}{visible}

where parameters is: board – number of board
n,e,s,w – north,east,south,west hand
visible – 1111 all hand are visible, 1010 only north and south hand are visible

enter image description here

Best Answer

Let us assume that you can add `\1` at the beginning of a line. Then

\documentclass{article}

\begin{document}

\def\pika{{$\spadesuit$}}
\def\srdce{{$\heartsuit$}}
\def\karo{{$\diamondsuit$}}
\def\trefl{{$\clubsuit$}}
\catcode`\T=13
\defT{10}
\def\1#1 #2 #3 #4 {\pika #1 \srdce #2 \karo #3 \trefl #4 }


\1QT2 98 J962 AKJ6 

\end{document}

enter image description here

Warning: It changes the meaning of the letter T!