« Module:ZoteroItem » : différence entre les versions
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| Ligne 230 : | Ligne 230 : | ||
for _, item in ipairs(data.notes) do | for _, item in ipairs(data.notes) do | ||
if item.data and item.data.itemType == "note" then | if item.data and item.data.itemType == "note" then | ||
local | local rawHtml = item.data.note or "" | ||
local url = (item.links and item.links.alternate and item.links.alternate.href) or "" | local url = (item.links and item.links.alternate and item.links.alternate.href) or "" | ||
-- | -- Étape 1 : supprimer tout sauf les balises autorisées | ||
-- Autorisé : <p>, </p>, <h1>, </h1>, <a href="...">, </a> | |||
local cleaned = rawHtml:gsub('<(.-)>', function(tag) | |||
-- Cas <a href="..."> | |||
if tag:match('^a%s+href=') then | |||
return "<" .. tag .. ">" | return "<" .. tag .. ">" | ||
end | end | ||
-- Cas </a>, <p>, </p>, <h1>, </h1> | |||
if tag == "/a" or tag == "p" or tag == "/p" or tag == "h1" or tag == "/h1" then | |||
return "<" .. tag .. ">" | |||
end | |||
-- Sinon : supprimer | |||
return "" | |||
end) | end) | ||
if | if cleaned ~= "" then | ||
table.insert(output, | table.insert(output, cleaned) | ||
end | end | ||
if url ~= "" then | if url ~= "" then | ||