Un outil pour aider à la traduction - retour accueil
git clone git://bebou.netlib.re/tpt
Log | Files | Refs | README |
makelayout (1293B)
1 #! /bin/sh 2 3 pl() { 4 tmpd=$(mktemp -d) 5 trap "rm -rf $tmpd" EXIT 6 7 layout=$(< $1 sed -E 's/\$[a-zA-Z]+/%s/g') 8 nbargs=$(echo "$layout" | grep -o '%s' | wc -l) 9 maxargs=$(echo "4096/$nbargs*$nbargs" | bc) 10 11 cat > $tmpd/in 12 13 < $tmpd/in head -n1 | tr ' ' '\n' | nl -n ln -w1 > $tmpd/vars 14 15 for var in $(< $1 grep -wEo '\$[a-zA-Z]+' | tr -d '$');do 16 grep "$var" $tmpd/vars 17 done | 18 cut -f1 | paste -s -d',' | 19 xargs -I{} awk -F'\t' -v col={} ' 20 BEGIN{getline;n=split(col,cols,",")} 21 { for (i=1;i<n+1;i++) { print $cols[i] } }' $tmpd/in | 22 xargs -d'\n' -n$maxargs printf "$layout\n" 23 } 24 25 <<. cat 26 <style> 27 /* Format tables */ 28 table { 29 border-collapse: collapse; 30 margin: 1.5rem 0; 31 } 32 33 figure > table { 34 width: max-content; 35 } 36 37 td, 38 th { 39 border: 1px solid; 40 text-align: start; 41 padding: 0.5rem; 42 } 43 44 th { 45 font-weight: bold; 46 } 47 48 tr:nth-child(even) { 49 /* Set every other cell slightly darker. Improves readability. */ 50 background-color: #EEEEEE; 51 } 52 53 table caption { 54 font-weight: bold; 55 margin-bottom: 0.5rem; 56 } 57 </style> 58 <table> 59 <thhead> 60 <tr> 61 <th>Source</th> 62 <th>Target</th> 63 <th>Result</th> 64 </tr> 65 </thead> 66 $(< $1 pl tablelayout | sed -E 's,,<mark class="red">,;s,,</mark>,' |sed -E 's,,<mark class="red">,;s,,</mark>,' | sed -E 's,,<mark class="red">,;s,,</mark>,' ) 67 </table> 68 .