יחידה:קידוד תווים מיוחדים – הבדלי גרסאות
מראה
תוכן שנמחק תוכן שנוסף
יצירת דף חדש |
אין תקציר עריכה |
||
שורה 12: | שורה 12: | ||
function p.decode_html_entities( frame ) |
function p.decode_html_entities( frame ) |
||
str = frame.args.string |
str = frame.args.string |
||
return p. |
return p.decode_html_entities_internal(str) |
||
end |
end |
||
גרסה מ־09:54, 22 במאי 2024
ניתן ליצור תיעוד על היחידה הזאת בדף יחידה:קידוד תווים מיוחדים/תיעוד
local p = {}
local html_entities = {
["""] = '"',
["'"] = "'",
["&"] = "&",
["<"] = "<",
[">"] = ">",
["'"] = "'"
}
function p.decode_html_entities( frame )
str = frame.args.string
return p.decode_html_entities_internal(str)
end
function p.decode_html_entities_internal(str)
return (str:gsub("(&.-;)", function(entity)
return html_entities[entity] or entity
end))
end
return p