Portál AbcLinuxu, 16. července 2025 19:48
$ cat pokus.tex \documentclass{article} \begin{document} \begin{description} \item[second]And something else is here \item[first]Something is here \item[andthird]Last but not least item \end{description} \end{document} $ cat dsort.pl #!/usr/bin/perl while(<>){ if(/\\begin\{description\}/){ print; $d=1; %d=(); undef $k; } if(/\\end\{description\}/){ print "\\item[$_]$d{$_}" for sort keys %d; $d=0; } print and next unless $d; if(/\\item\s*\[(.*?)\](.*)/){ $k=$1; $d{$k}="$2\n"; } elsif(defined $k){ $d{$k}.=$_; } } $ perl dsort.pl pokus.tex \documentclass{article} \begin{document} \begin{description} \item[andthird]Last but not least item \item[first]Something is here \item[second]And something else is here \end{description} \end{document}
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.