-- Convertit les divs avec classes sémantiques en balises HTML5 appropriées local semantic_tags = { ['section'] = true, ['article'] = true, ['aside'] = true, ['nav'] = true, ['header'] = true, ['footer'] = true, ['main'] = true } function Div(el) for tag, _ in pairs(semantic_tags) do if el.classes:includes(tag) then -- Build attributes (your existing code is good) local attrs = {} if el.identifier ~= '' then table.insert(attrs, 'id="' .. el.identifier .. '"') end local filtered_classes = {} for _, class in ipairs(el.classes) do if class ~= tag then table.insert(filtered_classes, class) end end if #filtered_classes > 0 then table.insert(attrs, 'class="' .. table.concat(filtered_classes, ' ') .. '"') end for key, value in pairs(el.attributes) do table.insert(attrs, key .. '="' .. value .. '"') end local attr_string = #attrs > 0 and ' ' .. table.concat(attrs, ' ') or '' -- THE FIX: Modify and return the content list directly -- 1. Prepend the opening tag el.content:insert(1, pandoc.RawBlock('html', '<' .. tag .. attr_string .. '>')) -- 2. Append the closing tag el.content:insert(pandoc.RawBlock('html', '')) -- 3. Return the modified pandoc.List return el.content end end -- If no semantic class is found, return the element unchanged return el end