Difference between revisions of "Module:SB"
Jump to navigation
Jump to search
Line 7: | Line 7: | ||
function sb.item_id2( frame ) | function sb.item_id2( frame ) | ||
− | local vNum = frame.args['volume'] | + | local vNum = string.format("%.2d", frame.args['volume']) |
− | local | + | local iNum = string.format("%.2d", frame.args['item']) |
− | local | + | print(vNum) |
− | + | local p_int, p_frac = math.modf(frame.args['page']) | |
− | + | local pNum = string.format("%.3d", p_int) | |
− | + | if p_frac > 0 then | |
− | + | pNum = pNum .. '.' .. p_frac | |
− | |||
− | if | ||
− | |||
end | end | ||
− | + | local id = string.format("%.2d", frame.args['volume']) .. '-' .. pNum .. '-' .. iNum | |
− | + | -- local id= string.format("{0:d4}", frame.args['volume']) | |
− | local id= string.format("{0:d4}", frame.args['volume']) | ||
return id | return id | ||
end | end |
Revision as of 08:24, 22 April 2021
Lua functions for HPB Scrapbooks.
Functions
item_id
Called from {{HPB-SB-item}} for setting semantic property [[HPB SB item ID]].
{{#invoke: SB | item_id | volume=1 | page=17 | item=4 }}
footnote
Called from {{HPB-SB-item}}.
{{#invoke: SB | footnote | title= | author= | author_signed= | type= | source_title= | source_details= | notes= | archivist_notes= | language = | translator = }}
Debug example
=p.item_id{args={["volume"]="1",["page"]="17.2",["item"]="3"}}
Module code
local sb = {} -- functions package for HPB Scrapbooks
function sb.item_id( frame )
local id = frame.args['volume'] .. '-' .. frame.args['page'] .. '-' .. frame.args['item']
return id
end
function sb.item_id2( frame )
local vNum = string.format("%.2d", frame.args['volume'])
local iNum = string.format("%.2d", frame.args['item'])
print(vNum)
local p_int, p_frac = math.modf(frame.args['page'])
local pNum = string.format("%.3d", p_int)
if p_frac > 0 then
pNum = pNum .. '.' .. p_frac
end
local id = string.format("%.2d", frame.args['volume']) .. '-' .. pNum .. '-' .. iNum
-- local id= string.format("{0:d4}", frame.args['volume'])
return id
end
return sb