Content deleted Content added
use preprocessing with safesubst to avoid trying to parse wikitext |
fix whitespace-trimming pattern |
||
Line 49:
-- template is processed correctly when both transcluding and when
-- substituting.
mw.log(short_description_content)
local preprocessed_short_description_template = mw.getCurrentFrame():preprocess(
'{{safesubst:short description|' .. short_description_content .. '}}'
)
mw.log(preprocessed_short_description_template)
-- Get the short description from the preprocessed template.
local short_description = mw.ustring.match(
Line 57 ⟶ 59:
'>%s*(.-)%s*<'
)
mw.log(short_description)
if not short_description then
return nil
Line 65 ⟶ 68:
return nil
end
mw.log(short_description)
-- It could still be a completely useless string e.g.
-- {{short description| }}
-- creates an 8 character short description of entirely whitespace.
-- Trim the result before return.
if trimmed_short_description ~= '' then
return trimmed_short_description
else
return nil
end
end
|