Module:User:Surjection/script utilities/tag text/lite

local export = {}

-- Wrap text in the appropriate HTML tags with language and script class. function export.tag_text(text, lang, sc, face, class, id) if not sc then sc = require("Module:scripts").findBestScript(text, lang) end if sc:getCode == "Imag" then face = nil end

local data = mw.loadData("Module:script utilities/data").faces[face or "nil"] if not data then error('Invalid script face "' .. face .. '".') end local post = "" if sc:getDirection == "rtl" and (face == "translation" or mw.ustring.find(text, "%p$")) then post = "&lrm;" end -- Add a script wrapper -- classes local result = ( data.prefix or "" ) .. '<' .. data.tag .. ' class="' .. sc:getCode	if data.class then		result = result .. ' ' .. data.class	end	if class and class ~= '' then		result = result .. ' ' .. class	end	result = result .. '"' if id then -- id result = result .. ' id="' .. require("Module:senseid").anchor(lang, id) .. '"' end if lang then -- lang result = result .. ' lang="' .. lang:getCode .. '"' end return result .. '>' .. text .. '' .. post end

return export