편집 요약 없음 |
편집 요약 없음 |
||
22번째 줄: | 22번째 줄: | ||
value = value:gsub("|", "<nowiki>||</nowiki>") | value = value:gsub("|", "<nowiki>||</nowiki>") | ||
if j == 1 then | |||
value = '<span style="color: blue; font-weight: bold;">' .. value .. '</span>' | value = '<span style="color: blue; font-weight: bold;">' .. value .. '</span>' | ||
end | end | ||
table.insert(values, value) | table.insert(values, value) | ||
end | end | ||
result = result .. "|-\n| " .. table.concat(values, " || ") .. "\n" | result = result .. "|-\n| " .. table.concat(values, " || ") .. "\n" | ||
end | end |
2025년 8월 8일 (금) 23:50 판
이 모듈에 대한 설명문서는 모듈:Timetable/설명문서에서 만들 수 있습니다
local p = {}
-- CSV 데이터를 받아 wikitable 형식으로 변환하는 함수
function p.csv(frame)
local csv = frame.args[1] or ''
local lines = {}
local result = '{| class="wikitable"\n'
-- CSV 데이터를 줄 단위로 분리
for line in csv:gmatch("[^\r\n]+") do
table.insert(lines, line)
end
-- 데이터 줄 처리
for i = 1, #lines do
local row = lines[i]
local values = {}
for j, value in ipairs(row:gmatch("[^,]+")) do
value = value:gsub("x", "…")
value = value:gsub("/", "<br/>")
value = value:gsub("v", "レ")
value = value:gsub("|", "<nowiki>||</nowiki>")
if j == 1 then
value = '<span style="color: blue; font-weight: bold;">' .. value .. '</span>'
end
table.insert(values, value)
end
result = result .. "|-\n| " .. table.concat(values, " || ") .. "\n"
end
result = result .. "|}"
return result
end
return p