writing: common method to display (univer) legend
authorMischa POSLAWSKY <perl@shiar.org>
Sun, 23 Apr 2017 18:59:28 +0000 (20:59 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Thu, 25 May 2017 20:13:06 +0000 (22:13 +0200)
Shiar_Sheet/FormatChar.pm
apl.plp
writing.plp

index 0a8a50a..6772dfc 100644 (file)
@@ -274,5 +274,22 @@ sub print {
        }
 }
 
+sub legend {
+       my @classes = (
+               ["X l5" => 'unicode 1.1'],
+               ["X l4" => '20th century'],
+               ["X l3" => 'in 6.0 (2010)'],
+               ["X l2" => 'recent assignments'],
+               ["X l1" => 'proposed'],
+               ["ex"   => 'irregular'],
+       );
+
+       return (
+               '<div class="legend"><table class="glyphs"><tr>',
+               (map { sprintf '<td class="%s">%s', @{$_} } @classes),
+               '</table></div>',
+       );
+}
+
 1;
 
diff --git a/apl.plp b/apl.plp
index ba51a11..9ca9970 100644 (file)
--- a/apl.plp
+++ b/apl.plp
@@ -80,16 +80,6 @@ for my $op (@ops) {
 :></table>
 </div>
 
-<hr>
-
-<div class="legend">
-       <table class="glyphs"><tr>
-       <td class="X l5">unicode 1.1
-       <td class="X l4">20th century
-       <td class="X l3">in 6.0 (2010)
-       <td class="X l2">recent assignments
-       <td class="X l1">proposed
-       <td class="ex">irregular
-       </table>
-</div>
+<:
+say for '<hr/>', $glyphs->legend;
 
index ee2d825..2f08da6 100644 (file)
@@ -56,18 +56,7 @@ for (
        } @table]);
 }
 
-:></div>
+say "</div>\n";
 
-<hr>
-
-<div class="legend">
-       <table class="glyphs"><tr>
-       <td class="X l5">unicode 1.1
-       <td class="X l4">20th century
-       <td class="X l3">in 6.0 (2010)
-       <td class="X l2">recent assignments
-       <td class="X l1">proposed
-       <td class="ex">irregular
-       </table>
-</div>
+say for '<hr/>', $glyphs->legend;