From: Manuel Penschuck Date: Mon, 1 Dec 2014 15:39:03 +0000 (+0100) Subject: Collapse option for xml-db2tex X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=6263e33ae167f8d213cdf348abad1c072e1e1d8b;p=daqtools.git Collapse option for xml-db2tex --- diff --git a/xml-db/xml-db2tex.pl b/xml-db/xml-db2tex.pl index d8a2fed..b229bac 100755 --- a/xml-db/xml-db2tex.pl +++ b/xml-db/xml-db2tex.pl @@ -30,6 +30,7 @@ GetOptions( 'style=s' => \$opt->{style}, 'standalone' => \$opt->{standalone}, 'wide|w' => \$opt->{wideformat}, + 'collapse' => \$opt->{collapse}, 'dumpItem|d' => \$opt->{dumpItem} ); @@ -102,6 +103,9 @@ Options: alternating gray and white boxes (default) + --collapse Dont show extra field line, if a register contains + only single field without description + --standalone generate standalone compilable latex file --pdf compile directly to pdf (compiles twice) @@ -160,20 +164,38 @@ sub produceTable { my $xmldb = xmlDbMethods->new( entityFile => $self->{entityFile} ); my $list = $xmldb->unfoldTree($self->{group}); my $data = []; + my $skip = 0; for my $name (@$list) { # processing the list + if ($skip) { + $skip=0; + next; + } my $node = $xmldb->{entity}->{$name}; my $type = $node->{type}; my $description = $node->{description}; my $repeat = $node->{repeat} || 1; my $stepsize = $node->{stepsize}||1; my $bits = " "; + if ($type ne 'register'){ my $start = $node->{start}; my $stop = $node->{start}+$node->{bits}-1; if ($start == $stop){ - $bits = $start; + $bits = $start; } else { - $bits = "$start--$stop"; + $bits = "$start--$stop"; + } + } elsif ($self->{opt}->{collapse} && (scalar @{$node->{'children'}}) == 1) { + my $child = $xmldb->{entity}{$node->{'children'}[0]}; + if ($child->{'description'} eq $node->{'description'}) { + my $start = $child->{start}; + my $stop = $child->{start}+$child->{bits}-1; + if ($start == $stop){ + $bits = $start; + } else { + $bits = "$start--$stop"; + } + $skip = 1; } } # escape special latex characters