Module:Wiki Utility

From Against the Storm Official Wiki
Revision as of 20:43, 26 October 2025 by Aeredor (talk | contribs) (created to help other modules with cleaner code for common functions)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:Wiki Utility/doc

-- Defines some utility functions for working with, among other things, mw library functions.
local Wiki_Utility = {}

-- Surrounds the given wikitext with no-wrap tags.
---@param wikitext Wikitext wikitext to surround
---@return Wikitext wikitext same wikitext, surrounded with no-wrap tags
function Wiki_Utility.surroundWithNoWrap(wikitext)
  return "<span style=\"white-space: nowrap;\">" .. wikitext .. "</span>"
end

-- Surrounds the given wikitext with the given classes.
---@param wikitext Wikitext wikitext to surround
---@param ... string classes to surround the wikitext with
---@return Wikitext wikitext same wikitext, surrounded with the given classes
function Wiki_Utility.surroundWithClasses(wikitext, ...)
  return "<span class=\"" .. table.concat({...}, " ") .. "\">" .. wikitext .. "</span>"
end

return Wiki_Utility