Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,26 @@
;; styles -
(style 'td "text-align:right")
(style 'table "border-spacing: 10px;border:1px solid red")
(style 'th "color:blue;")
;; generic html5 builder
;; pushes <tag style=..> (proc content) </tag>
(define (emit-tag tag html-proc content )
(if (style tag)
(push html (format "<%s style='%a'>" tag (style tag)))
(push html (format "<%s>" tag )))
(html-proc content)
(push html (format "</%s> " tag )))
;; html procs : 1 tag, 1 proc
(define (h-raw content)
(push html (format "%s" content)))
(define (h-header headers)
(for ((h headers)) (emit-tag 'th h-raw h)))
(define (h-row row)
(for ((item row)) (emit-tag 'td h-raw item)))
(define (h-table table )
(emit-tag 'tr h-header (first table))
;; add row-num i at head of row
(for ((i 1000)(row (rest table))) (emit-tag 'tr h-row (cons i row))))

View file

@ -0,0 +1,5 @@
(define my-table '(("" X Y Z) (-1111 111 11) (22 -222 2222) (4422 0 42) (33 333 3333) (6666 666 66)))
(stack (define html 'html)) ;; stack of html elements
(emit-tag 'table h-table my-table)
(string-join (stack->list html) " ")

View file

@ -0,0 +1,21 @@
define rand4dig => integer_random(9999, 1)
local(
output = '<table border=2 cellpadding=5 cellspace=0>\n<tr>'
)
with el in ('&#160;,X,Y,Z') -> split(',') do {
#output -> append('<th>' + #el + '</th>')
}
#output -> append('</tr>\n')
loop(5) => {
#output -> append('<tr>\n<td style="font-weight: bold;">' + loop_count + '</td>')
loop(3) => {
#output -> append('<td>' + rand4dig + '</td>')
}
#output -> append('</tr>\n')
}
#output -> append('</table>\n')
#output

View file

@ -0,0 +1,25 @@
on htmlTable (data)
str = "<table>"
-- table head
put "<thead><tr><th>&nbsp;</th>" after str
repeat with cell in data[1]
put "<th>"&cell&"</th>" after str
end repeat
put "</tr></thead>" after str
-- table body
put "<tbody>" after str
cnt = data.count
repeat with i = 2 to cnt
put "<tr><td>"&(i-1)&"</td>" after str
repeat with cell in data[i]
put "<td>"&cell&"</td>" after str
end repeat
put "</tr>" after str
end repeat
put "</tbody>" after str
put "</table>" after str
return str
end

View file

@ -0,0 +1,12 @@
tableData = [\
["X", "Y", "Z"],\
["1", "2", "3"],\
["4", "5", "6"],\
["7", "8", "9"]\
]
htmlCode = htmlTable(tableData)
-- render the result in a text member (which only supports simple/ancient HTML)
m = new(#text)
m.text = "<html><body>"&htmlCode&"</body></html>"

View file

@ -0,0 +1,14 @@
import math, htmlgen
randomize()
template randTD(): expr = td($random(1000..9999))
proc randTR(x): auto =
tr(td($x, style="font-weight: bold"), randTD, randTD, randTD)
echo table(
tr(th"", th"X", th"Y", th"Z"),
randTR 1,
randTR 2,
randTR 3,
randTR 4,
randTR 5)

View file

@ -0,0 +1,17 @@
<@ SDCLIT>
<@ DTBLIT>
<@ DTRLITLIT>
<@ DTDLITLIT>|[style]background-color:white</@>
<@ DTD>X</@>
<@ DTD>Y</@>
<@ DTD>Z</@>|[style]width:100%; background-color:brown;color:white; text-align:center</@>
<@ ITEFORLIT>10|
<@ DTRLITCAP>
<@ DTDPOSFORLIT>...|[style]background-color:Brown; color:white; text-align:right</@>
<@ DTDCAPLIT><@ SAYR!ILI2>1|9999</@>|[style]width:50;text-align:right</@>
<@ DTDCAPLIT><@ SAYR!ILI2>1|9999</@>|[style]width:50;text-align:right</@>
<@ DTDCAPLIT><@ SAYR!ILI2>1|9999</@>|[style]width:50;text-align:right</@>
|[style]background-color:white;color:black</@>
</@>
</@>
|Number Table</@>

View file

@ -0,0 +1,14 @@
puts(1,"<table>\n")
puts(1," <tr><th></th>")
for j=1 to 3 do
printf(1,"<th>%s</th>",'W'+j)
end for
puts(1,"</tr>\n")
for i=1 to 3 do
printf(1," <tr><td>%d</td>",i)
for j=1 to 3 do
printf(1,"<td>%d</td>",rand(10000))
end for
puts(1,"</tr>\n")
end for
puts(1,"</table>")

View file

@ -0,0 +1,7 @@
<table>
<table>
<tr><th></th><th>X</th><th>Y</th><th>Z</th></tr>
<tr><td>1</td><td>3287</td><td>6480</td><td>6510</td></tr>
<tr><td>2</td><td>8500</td><td>1908</td><td>5352</td></tr>
<tr><td>3</td><td>3287</td><td>6600</td><td>3953</td></tr>
</table>

View file

@ -0,0 +1,50 @@
class HTML {
method _attr(Hash h) {
h.keys.sort.map {|k| %Q' #{k}="#{h{k}}"' }.join('')
}
method _tag(Hash h, name, value) {
"<#{name}" + self._attr(h) + '>' + value + "</#{name}>"
}
method table(Hash h, *data) { self._tag(h, 'table', data.join('')) }
method table(*data) { self.table(Hash(), data...) }
}
class Table < HTML {
method th(Hash h, value) { self._tag(h, 'th', value) }
method th(value) { self.th(Hash(), value) }
method tr(Hash h, *rows) { self._tag(h, 'tr', rows.join('')) }
method tr(*rows) { self.tr(Hash(), rows...) }
method td(Hash h, value) { self._tag(h, 'td', value) }
method td(value) { self.td(Hash(), value) }
}
var header = %w(&nbsp; X Y Z);
var rows = 5;
var html = HTML.new;
var table = Table.new;
say html.table(
# attributes
Hash(
cellspacing => 4,
style => "text-align:right; border: 1px solid;"
),
# header
table.tr(header.map{|elem| table.th(elem)}...),
# rows
(1..rows).map { |i|
table.tr(
table.td(:(align => 'right'), i),
(header.len - 1).of {
table.td(Hash(align => 'right'), 10000.rand.int)
}...
)
}...
);

View file

@ -0,0 +1,18 @@
decl ursa.util.random random
out "<table>" endl console
# generate header
out "<tr><th></th><th>X</th><th>Y</th><th>Z</th></tr>" endl console
# generate five rows
decl int i
for (set i 1) (< i 6) (inc i)
out "<tr><td style=\"font-weight: bold;\">" i "</td>" console
out "<td>" (int (+ 1000 (random.getint 8999))) "</td>" console
out "<td>" (int (+ 1000 (random.getint 8999))) "</td>" console
out "<td>" (int (+ 1000 (random.getint 8999))) "</td>" console
out "</tr>" endl console
end for
out "</table>" endl console

View file

@ -0,0 +1,23 @@
def html_row:
"<tr>",
" \(.[] | "<td>\(.)</td>")",
"</tr>";
def html_header:
"<thead align = 'right'>",
" \(html_row)",
"</thead>";
def html_table(header):
"<table>",
" \(header | html_header)",
" <tbody align = 'right'>",
" \(.[] | html_row)",
" </tbody",
"</table>";
# Prepend the sequence number
def html_table_with_sequence(header):
length as $length
| . as $in
| [range(0;length) | [.+1] + $in[.]] | html_table(header);

View file

@ -0,0 +1,7 @@
def data:
[ [4,5,6],
[41, 51, 61],
[401, 501, 601] ];
# The first column has no header
data | html_table_with_sequence( ["", "X", "Y", "Z"] )

View file

@ -0,0 +1,31 @@
$ jq -r -n -f Create_an_HTML_table.jq
<table>
<thead align = 'right'>
<tr>
<td></td>
<td>X</td>
<td>Y</td>
<td>Z</td>
</tr>
</thead>
<tbody align = 'right'>
<tr>
<td>1</td>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>2</td>
<td>41</td>
<td>51</td>
<td>61</td>
</tr>
<tr>
<td>3</td>
<td>401</td>
<td>501</td>
<td>601</td>
</tr>
</tbody
</table>