Module:AbilitySection: Difference between revisionsGive feedback
Identify interaction boxes by their data attributes rather than CSS class names, so box styling can change independently (with help from vergir-bot LLM) |
Read the iconbox- data attributes from the box (with help from vergir-bot LLM) |
||
| Line 29: | Line 29: | ||
local function process_interactions(html, ability_num) | local function process_interactions(html, ability_num) | ||
local manual, idx, seen = {}, 0, {} | local manual, idx, seen = {}, 0, {} | ||
-- Boxes are identified by their data- | -- Boxes are identified by their data-iconbox-* attributes, which are the | ||
-- with Template:IconBox. Class names are presentational and | -- contract with Template:IconBox. Class names are presentational and | ||
-- matched here, so box styling can change without touching this. | -- deliberately not matched here, so box styling can change without touching this. | ||
local out = html:gsub('(<div)([^>]*data%- | local out = html:gsub('(<div)([^>]*data%-iconbox%-icon="[^"]*"[^>]*)(>)', function(pre, attrs, post) | ||
local file = attrs:match('data%- | local file = attrs:match('data%-iconbox%-icon="([^"]*)"') | ||
if file and file ~= '' then | if file and file ~= '' then | ||
local base = mw.ustring.lower((file:gsub('%.%w+$', ''))) | local base = mw.ustring.lower((file:gsub('%.%w+$', ''))) | ||
| Line 43: | Line 43: | ||
table.insert(manual, { | table.insert(manual, { | ||
file = file, | file = file, | ||
title = attrs:match('data%- | title = attrs:match('data%-iconbox%-title="([^"]*)"') or '', | ||
state = attrs:match('data%- | state = attrs:match('data%-iconbox%-state="([^"]*)"') or 'normal', | ||
anchor = box_id, | anchor = box_id, | ||
}) | }) | ||