وحدة:ملعب/Mr. Ibrahem/fixhtml
< وحدة:ملعب | Mr. Ibrahem
الاستخدام
{{#استدعاء:ملعب/Mr. Ibrahem/fixhtml|to_wikitable|text}}
مثال
{| cellpadding="4" cellspacing="0" style="border:1px solid rgb(200,200,200); color:black; margin:0 0 0.5em 0;background-color:rgb(255, 255, 255); padding:5px; clear:right; text-align:left; font-size:85%; line-height:1.6em;" |- style="background-color:#FFDF80;text-align:center" ! style="white-space:nowrap" | [[File:Wikidata-logo S.svg| 12px|link=d:Q16027296#P527]]المرحلة ! التاريخ ! الدورة ! style="color:#FFDF80" | type ! المسافة (كم) ! الفائز بالمرحلة ! القائد العام |}
مثال1
<strong class="error"><span class="scribunto-error" id="mw-scribunto-error-0">خطأ لوا في وحدة:Cycling_race على السطر 1477: attempt to concatenate local 'title' (a nil value).</span></strong>
فرق
− | <strong class="error"><span class="scribunto-error" id="mw-scribunto-error- | + | <strong class="error"><span class="scribunto-error" id="mw-scribunto-error-2">خطأ لوا في وحدة:Cycling_race على السطر 1477: attempt to concatenate local 'title' (a nil value).</span></strong> |
local p = {}
function to_wikitable(final, note)
final = tostring(final)
final = string.gsub(final, '<span style%=%"white%-space%:nowrap%">% %;</span>', "")
if note == nil
and final:find("{{مرحلة سباق الدراجات")
then
mw.log("no note")
-- remove html (td, tr, th) style="text-align:center; white-space:nowrap"
final = string.gsub(final, ' style%=%"text%-align%:center%;%s*white%-space%:nowrap%;*%s*"', " ")
final = string.gsub(final, ' style%=%"white%-space%:nowrap%;%s*text%-align%:right%;%s*padding%-right%:0px%;*%s*"', ' style="padding-right:0px"')
final = string.gsub(final, '<td style%=%"text%-align%:center%;*%s*">([%d%٫]+)</td>', '<td>%1</td>')
--final = string.gsub(final, '<td style%=%"text%-align%:center%;*%s*">(%d+%٫*%d*)</td>', '<td>%1</td>')
end
final = string.gsub(final, "<table([^>]*)>", "{| %1 \n")
final = string.gsub(final, "</table>", "\n|}")
-- convert <tr>
final = string.gsub(final, '<tr ([%w-]+%=%".-%")>(.-)</tr>', '\n|- %1 \n%2\n')
final = string.gsub(final, "<tr%s*>(.-)</tr>", "\n|-\n%1\n")
final = string.gsub(final, "<tr([^>])>(.-)</tr>", "\n|- %1 \n%2\n")
-- convert <th>
final = string.gsub(final, '<th ([%w-]+%=%".-%")>(.-)</th>', "! %1 | %2\n")
final = string.gsub(final, "<th%s*>(.-)</th>", "\n! %1 \n")
final = string.gsub(final, "<th([^>])>(.-)</th>", "! %1 | %2\n")
-- convert <td>
final = string.gsub(final, '<td ([%w-]+%=%".-%")>(.-)</td>', '\n| %1 | %2\n')
final = string.gsub(final, "<td%s*>(.-)</td>", "\n| %1 \n")
final = string.gsub(final, "<td([^>])>(.-)</td>", "\n| %1 | %2\n")
-- convert liks like [[link]]
-- convert flags like [[File:Flag of the United Kingdom.svg|border|20px|GBR]]
final = string.gsub(final, "%[%[File%:Flag of (the |)(.-)%.(svg|png)%|border%|%d+px%|%w+%]%]", "{{رمز علم|%2}}")
final = string.gsub(final, "%[%[File%:Flag of (the |)(.-)%.(svg|png)%|border%|%d+px%|%(Wikidata%:Q%d+%)%]%]", "{{رمز علم|%2}}")
-- remove newlines
final = string.gsub(final, "\n+", "\n")
-- remove leading and trailing newlines
final = string.gsub(final, "^\n+", "")
final = string.gsub(final, '<span style%=%"float%:left%; margin%: 0 5px">%[%[File:Wikidata-logo S%.svg%|%d+px%|link%=d%:(Q%d+)%]%] </span>', "{{عدل في ويكي بيانات|type1=1|id=%1}}")
final = string.gsub(final, '<span style%=%"float%:left%; margin%: 0 5px">%[%[File:Wikidata-logo S%.svg%|%d+px%|link%=d%:(Q%d+#P%d)%]%] </span>', "{{عدل في ويكي بيانات|type1=1|id=%1}}")
final = string.gsub(final, '<span style%=%"float%:right%;">%[%[File:Wikidata-logo S%.svg%|%d+px%|link%=d%:(Q%d+)%]%]%s*</span>', "{{عدل في ويكي بيانات|type1=1|id=%1}}")
final = string.gsub(final, '<span style%=%"float%:right%;">%[%[File:Wikidata-logo S%.svg%|%d+px%|link%=d%:(Q%d+#P%d+)%]%]%s*</span>', "{{عدل في ويكي بيانات|type1=1|id=%1}}")
final = string.gsub(final, '<span style%=%"white%-space%:nowrap%">% %;</span>', "")
final = string.gsub(final, "\n+$", "")
final = string.gsub(final, '%|%-%s*style%s*%=%""', "|-")
return final
end
function p.to_wikitable(frame)
local args = frame.args
local final = args[1]
local note = args.note
final = to_wikitable(final, note)
return final
end
function p.fix(frame)
return p.to_wikitable(frame)
end
return p