词条 | Module:Sandbox/Swpb/Transpose |
释义 | local p = {} function p.transpose(frame) input = frame.args[1] -- ==============================================
opening = mw.ustring.match(input, '{%|.-(?=%|%-)' ) opening = mw.ustring.match(input, '{%|.-%|%-' )
first_row_index = mw.ustring.find(input, '%|%-' ) rows = 1 cols = 1 output = input .. opening .. ' ' .. first_row_index
out_table = '{| class="wikitable" \\ |- \\ | test \\ |}' -- ============================================== return out_table end --return p--Approach:--1) Replace col-spanning cells with separate cells and indicate which cells to merge--2) Replace row-spanning cells with separate cells and indicate which cells to merge--3) Capture the cells of the unspanned table in two 2D arrays (format, content)-- ) Transpose the cells-- ) Create the new table-- ) Recreate col (now row) spans-- ) Recreate row (now col) spans |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。