Module:User:Vorziblix/test

local export = {}

function export.concat(frame) return frame.args[1] .. frame.args[2] end

function export.blahblahdebug(frame) local default_title = frame.args['head'] or mw.title.getCurrentTitle.text default_title = 'Alternative hieroglyphic writings of ' .. frame:expandTemplate{title = 'lang', args = {'egy', default_title, face = 'term'}} local tabletitle = frame.args['title'] or default_title local text = ' \n ' .. tabletitle .. ' \n \n{| style="text-align:center;"' local i = 1 while frame.args[i] do text = text .. '\n| style="background-color:#efefef"| ' .. frame.args[i] .. ' '		i = i + 1 end text = text .. '\n| nothing\n|} ' return text end

function export.hieroforms(frame) local default_title = frame.args['head'] or mw.title.getCurrentTitle.text default_title = 'Alternative hieroglyphic writings of ' .. frame:expandTemplate{title = 'lang', args = {'egy', default_title, face = 'term'}} local tabletitle = frame.args['title'] or default_title local text = ' \n ' .. tabletitle .. ' \n \n{| style="text-align:center;"' local i = 1 while frame.args[i] do text = text .. '\n| style="background-color:#efefef"| ' .. frame.args[i] .. ' '		i = i + 1 end local j = 1 local no_read = true local since_last = 1 local read = 'read1' while j < i do		if frame.args[read] then if no_read then text = text .. '\n|-' no_read = false end while since_last > 0 do text = text .. '\n|' since_last = since_last - 1 end text = text .. 'style="background-color:#efefef"|' .. frame:expandTemplate{title = 'm-self', args = {'egy', frame.args[read]}} end since_last = since_last + 1 j = j + 1 read = 'read' .. j	end j = 1 local no_date = true since_last = 1 local date = 'date1' while j < i do		if frame.args[date] then if no_date then text = text .. '\n|-' no_date = false end while since_last > 0 do text = text .. '\n|' since_last = since_last - 1 end text = text .. 'style="background-color:#efefef"|' .. frame:expandTemplate{title = 'defdate', args = {frame.args[date]}} end since_last = since_last + 1 j = j + 1 date = 'date' .. j	end j = 1 local no_note = true since_last = 1 local since_note = 1 local note = 'note1' while j < i do		if frame.args[note] then if no_note then text = text .. '\n|- style="font-size:70%"' no_note = false end while since_last > 0 do text = text .. '\n|' since_last = since_last - 1 end text = text .. 'style="background-color:#efefef"|' .. frame.args[note] end since_last = since_last + 1 j = j + 1 note = 'note' .. j	end text = text .. '\n|} ' return text end

function export.remove_comments(input) return mw.ustring.gsub(input, '<!%-%-(.-)%-%->', '') end

function export.tokenize_hiero(input) input = mw.ustring.gsub(input, ' ', '-') input = mw.ustring.gsub(input, '\n', '-') input = mw.ustring.gsub(input, '\r', '-') input = mw.ustring.gsub(input, '\t', '-') input = mw.ustring.gsub(input, '%-%-+', '-') local quadrats = {} local i = 1 while true do		j = string.find(input, '-', i, true) if j ~= nil then table.insert(quadrats, string.sub(input, i, j - 1)) i = j + 1 else table.insert(quadrats, string.sub(input, i)) break end end return quadrats end

function export.mdc_to_image(mdc, height_in) local height = height_in or '38' local mirrored = '' if string.sub(mdc, -1) == '\\' then mirrored = '|class=mw-mirrored' mdc = string.sub(mdc, 1, -2) end local image = ' \ ' return image end

function export.render_quadrat(unrendered) if unrendered == '!' then rendered = '         ' .. ' \ ' .. ' '	else stack = string.find(unrendered, ':') if stack ~= nil then upper = export.mdc_to_image(string.sub(unrendered, 1, stack - 1), '19') lower = export.mdc_to_image(string.sub(unrendered, stack + 1), '19') rendered = ' ' .. upper .. ' ' .. lower .. ' '		else rendered = export.mdc_to_image(unrendered) rendered = ' ' .. rendered .. ' '		end end return rendered end

function export.hiero(frame) local output = {} local hieros = frame.args[1] hieros = export.remove_comments(hieros) local tokenized = export.tokenize_hiero(hieros) for k, v in ipairs(tokenized) do		v = export.render_quadrat(v) table.insert(output, v)	end return '  ' end

return export