Module:qlu-nouns: Difference between revisions

No edit summary
No edit summary
Line 143: Line 143:
   table.insert(out, '<table class="inflection-table" style="border-collapse:collapse; width:40%; font-size:90%;">')
   table.insert(out, '<table class="inflection-table" style="border-collapse:collapse; width:40%; font-size:90%;">')


   -- Header row
   -- Header row (without thead)
   table.insert(out, "<thead><tr>")
   table.insert(out, "<tr>")
   table.insert(out, cell("", true, "background:#444; color:#fff; padding:4px;"))
   table.insert(out, cell("", true, "background:#444; color:#fff; padding:4px;"))
   table.insert(out, cell("singular", true, "background:#444; color:#fff; padding:4px;"))
   table.insert(out, cell("singular", true, "background:#444; color:#fff; padding:4px;"))
   table.insert(out, cell("plural", true, "background:#444; color:#fff; padding:4px;"))
   table.insert(out, cell("plural", true, "background:#444; color:#fff; padding:4px;"))
   table.insert(out, "</tr></thead>")
   table.insert(out, "</tr>")


   -- Body rows
   -- Body rows (without tbody)
  table.insert(out, "<tbody>")
   for _, row in ipairs(rows) do
   for _, row in ipairs(rows) do
     table.insert(out, "<tr>")
     table.insert(out, "<tr>")
    -- Case name column with light gray background
     table.insert(out, cell(row.label, false, "background:#ddd; padding:4px; font-weight:bold; white-space:nowrap;"))
     table.insert(out, cell(row.label, false, "background:#ddd; padding:4px; font-weight:bold; white-space:nowrap;"))
    -- Singular form
     table.insert(out, cell(row.sg, false, "background:#fff; padding:4px; text-align:center;"))
     table.insert(out, cell(row.sg, false, "background:#fff; padding:4px; text-align:center;"))
    -- Plural form
     table.insert(out, cell(row.pl, false, "background:#fff; padding:4px; text-align:center;"))
     table.insert(out, cell(row.pl, false, "background:#fff; padding:4px; text-align:center;"))
     table.insert(out, "</tr>")
     table.insert(out, "</tr>")
   end
   end
  table.insert(out, "</tbody>")


   table.insert(out, "</table>")
   table.insert(out, "</table>")


  -- Append footnotes if any
   if data.footnotes and data.footnotes ~= "" then
   if data.footnotes and data.footnotes ~= "" then
     table.insert(out, '<div class="footnotes" style="font-size:80%; margin-top:0.5em;">' .. data.footnotes .. "</div>")
     table.insert(out, '<div class="footnotes" style="font-size:80%; margin-top:0.5em;">' .. data.footnotes .. "</div>")
Line 172: Line 166:


   return table.concat(out, "\n")
   return table.concat(out, "\n")
end
-- Main show function: receives root and declension type, outputs full table HTML
function export.show(frame)
  local args = frame.args
  local root = args[1] or error("No root provided.")
  local decltype = args["type"] or error("No declension type provided.")
  local decl = decls[decltype]
  if not decl then
    error("Unknown declension type: " .. decltype)
  end
  local data = { forms = {} }
  decl({ root }, data)
  return export.make_table(data)
end
end


return export
return export