Module:la-noun/table: Difference between revisions
(Created page with "local export = {} local Array = require 'Module:array' local function add_forms(wikitable, forms) if type(wikitable) ~= 'string' then error('Expected string, got ' .. type(wikitable)) end wikitable = wikitable:gsub('{{{([^}]+)}}}', forms) return wikitable end local stylesheet = require("Module:TemplateStyles")("Template:la-decl-1st/style.css") function export.make_table_sg(data) local output = Array(data.title, stylesheet) output:insert [=[ {| class="wikit...") |
No edit summary |
||
Line 23: | Line 23: | ||
! class="number-header" | Singular | ! class="number-header" | Singular | ||
|- | |- | ||
! class="case-header" | ! class="case-header" | Nominative | ||
| class="form-cell" | {{{nom_sg}}} | | class="form-cell" | {{{nom_sg}}} | ||
|- | |- | ||
! class="case-header" | ! class="case-header" | Genitive | ||
| class="form-cell" | {{{gen_sg}}} | | class="form-cell" | {{{gen_sg}}} | ||
|- | |- | ||
! class="case-header" | ! class="case-header" | Dative | ||
| class="form-cell" | {{{dat_sg}}} | | class="form-cell" | {{{dat_sg}}} | ||
|- | |- | ||
! class="case-header" | ! class="case-header" | Accusative | ||
| class="form-cell" | {{{acc_sg}}} | | class="form-cell" | {{{acc_sg}}} | ||
|- | |- | ||
! class="case-header" | ! class="case-header" | Ablative | ||
| class="form-cell" | {{{abl_sg}}} | | class="form-cell" | {{{abl_sg}}} | ||
|- | |- | ||
! class="case-header" | ! class="case-header" | Vocative | ||
| class="form-cell" | {{{voc_sg}}} | | class="form-cell" | {{{voc_sg}}} | ||
|-]=] | |-]=] | ||
Line 44: | Line 44: | ||
output:insert [=[ | output:insert [=[ | ||
! class="case-header" | | ! class="case-header" | Locative | ||
| class="form-cell" | {{{loc_sg}}}]=] | | class="form-cell" | {{{loc_sg}}}]=] | ||
end | end | ||
Line 64: | Line 64: | ||
! class="number-header" | Plural | ! class="number-header" | Plural | ||
|- | |- | ||
! class="case-header" | ! class="case-header" | Nominative | ||
| class="form-cell" | {{{nom_pl}}} | | class="form-cell" | {{{nom_pl}}} | ||
|- | |- | ||
! class="case-header" | ! class="case-header" | Genitive | ||
| class="form-cell" | {{{gen_pl}}} | | class="form-cell" | {{{gen_pl}}} | ||
|- | |- | ||
! class="case-header" | ! class="case-header" | Dative | ||
| class="form-cell" | {{{dat_pl}}} | | class="form-cell" | {{{dat_pl}}} | ||
|- | |- | ||
! class="case-header" | ! class="case-header" | Accusative | ||
| class="form-cell" | {{{acc_pl}}} | | class="form-cell" | {{{acc_pl}}} | ||
|- | |- | ||
! class="case-header" | ! class="case-header" | Ablative | ||
| class="form-cell" | {{{abl_pl}}} | | class="form-cell" | {{{abl_pl}}} | ||
|- | |- | ||
! class="case-header" | ! class="case-header" | Vocative | ||
| class="form-cell" | {{{voc_pl}}} | | class="form-cell" | {{{voc_pl}}} | ||
|- | |- | ||
Line 86: | Line 86: | ||
output:insert [=[ | output:insert [=[ | ||
! class="case-header" | | ! class="case-header" | Locative | ||
| class="form-cell" | {{{loc_pl}}}]=] | | class="form-cell" | {{{loc_pl}}}]=] | ||
end | end | ||
Line 107: | Line 107: | ||
! class="number-header" | Plural | ! class="number-header" | Plural | ||
|- | |- | ||
! class="case-header" | ! class="case-header" | Nominative | ||
| class="form-cell" | {{{nom_sg}}} | | class="form-cell" | {{{nom_sg}}} | ||
| class="form-cell" | {{{nom_pl}}} | | class="form-cell" | {{{nom_pl}}} | ||
|- | |- | ||
! class="case-header" | ! class="case-header" | Genitive | ||
| class="form-cell" | {{{gen_sg}}} | | class="form-cell" | {{{gen_sg}}} | ||
| class="form-cell" | {{{gen_pl}}} | | class="form-cell" | {{{gen_pl}}} | ||
|- | |- | ||
! class="case-header" | ! class="case-header" | Dative | ||
| class="form-cell" | {{{dat_sg}}} | | class="form-cell" | {{{dat_sg}}} | ||
| class="form-cell" | {{{dat_pl}}} | | class="form-cell" | {{{dat_pl}}} | ||
|- | |- | ||
! class="case-header" | ! class="case-header" | Accusative | ||
| class="form-cell" | {{{acc_sg}}} | | class="form-cell" | {{{acc_sg}}} | ||
| class="form-cell" | {{{acc_pl}}} | | class="form-cell" | {{{acc_pl}}} | ||
|- | |- | ||
! class="case-header" | ! class="case-header" | Ablative | ||
| class="form-cell" | {{{abl_sg}}} | | class="form-cell" | {{{abl_sg}}} | ||
| class="form-cell" | {{{abl_pl}}} | | class="form-cell" | {{{abl_pl}}} | ||
|- | |- | ||
! class="case-header" | ! class="case-header" | Vocative | ||
| class="form-cell" | {{{voc_sg}}} | | class="form-cell" | {{{voc_sg}}} | ||
| class="form-cell" | {{{voc_pl}}} | | class="form-cell" | {{{voc_pl}}} | ||
Line 134: | Line 134: | ||
output:insert [=[ | output:insert [=[ | ||
! class="case-header" | | ! class="case-header" | Locative | ||
| class="form-cell" | {{{loc_sg}}} | | class="form-cell" | {{{loc_sg}}} | ||
| class="form-cell" | {{{loc_pl}}}]=] | | class="form-cell" | {{{loc_pl}}}]=] |
Latest revision as of 16:18, 15 February 2023
Documentation for this module may be created at Module:la-noun/table/doc
local export = {}
local Array = require 'Module:array'
local function add_forms(wikitable, forms)
if type(wikitable) ~= 'string' then
error('Expected string, got ' .. type(wikitable))
end
wikitable = wikitable:gsub('{{{([^}]+)}}}', forms)
return wikitable
end
local stylesheet = require("Module:TemplateStyles")("Template:la-decl-1st/style.css")
function export.make_table_sg(data)
local output = Array(data.title, stylesheet)
output:insert [=[
{| class="wikitable inflection-table inflection-table-la"
|-
! class="corner-header" | Case
! class="number-header" | Singular
|-
! class="case-header" | Nominative
| class="form-cell" | {{{nom_sg}}}
|-
! class="case-header" | Genitive
| class="form-cell" | {{{gen_sg}}}
|-
! class="case-header" | Dative
| class="form-cell" | {{{dat_sg}}}
|-
! class="case-header" | Accusative
| class="form-cell" | {{{acc_sg}}}
|-
! class="case-header" | Ablative
| class="form-cell" | {{{abl_sg}}}
|-
! class="case-header" | Vocative
| class="form-cell" | {{{voc_sg}}}
|-]=]
if data.forms.loc_sg then
output:insert [=[
! class="case-header" | Locative
| class="form-cell" | {{{loc_sg}}}]=]
end
output:insert('\n|}')
if data.footnotes and data.footnotes ~= "" then
output:insert('\n' .. data.footnotes)
end
return add_forms(output:concat(), data.forms)
end
function export.make_table_pl(data)
local output = Array(data.title, stylesheet)
output:insert [=[
{| class="wikitable inflection-table inflection-table-la"
|-
! class="corner-header" | Case
! class="number-header" | Plural
|-
! class="case-header" | Nominative
| class="form-cell" | {{{nom_pl}}}
|-
! class="case-header" | Genitive
| class="form-cell" | {{{gen_pl}}}
|-
! class="case-header" | Dative
| class="form-cell" | {{{dat_pl}}}
|-
! class="case-header" | Accusative
| class="form-cell" | {{{acc_pl}}}
|-
! class="case-header" | Ablative
| class="form-cell" | {{{abl_pl}}}
|-
! class="case-header" | Vocative
| class="form-cell" | {{{voc_pl}}}
|-
]=]
if data.forms.loc_pl then
output:insert [=[
! class="case-header" | Locative
| class="form-cell" | {{{loc_pl}}}]=]
end
output:insert('\n|}')
if data.footnotes and data.footnotes ~= "" then
output:insert('\n' .. data.footnotes)
end
return add_forms(output:concat(), data.forms)
end
function export.make_table(data)
local output = Array(data.title, stylesheet)
output:insert [=[
{| class="wikitable inflection-table inflection-table-la"
|-
! class="corner-header" | Case
! class="number-header" | Singular
! class="number-header" | Plural
|-
! class="case-header" | Nominative
| class="form-cell" | {{{nom_sg}}}
| class="form-cell" | {{{nom_pl}}}
|-
! class="case-header" | Genitive
| class="form-cell" | {{{gen_sg}}}
| class="form-cell" | {{{gen_pl}}}
|-
! class="case-header" | Dative
| class="form-cell" | {{{dat_sg}}}
| class="form-cell" | {{{dat_pl}}}
|-
! class="case-header" | Accusative
| class="form-cell" | {{{acc_sg}}}
| class="form-cell" | {{{acc_pl}}}
|-
! class="case-header" | Ablative
| class="form-cell" | {{{abl_sg}}}
| class="form-cell" | {{{abl_pl}}}
|-
! class="case-header" | Vocative
| class="form-cell" | {{{voc_sg}}}
| class="form-cell" | {{{voc_pl}}}
|-]=]
if data.forms.loc_sg or data.forms.loc_pl then
output:insert [=[
! class="case-header" | Locative
| class="form-cell" | {{{loc_sg}}}
| class="form-cell" | {{{loc_pl}}}]=]
end
output:insert('\n|}')
if data.footnotes and data.footnotes ~= "" then
output:insert('\n' .. data.footnotes)
end
return add_forms(output:concat(), data.forms)
end
return export