Title: Module:Separated entries - freem URL Source: https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries Markdown Content: _Documentation for this module may be created at [Module:Separated entries/doc](https://freemwiki.com/index.php?title=Module:Separated\_entries/doc&action=edit&redlink=1 "Module:Separated entries/doc (page does not exist)")_ [](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-1)-- This module takes positional parameters as input and concatenates them with[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-2)-- an optional separator. The final separator (the "conjunction") can be[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-3)-- specified independently, enabling natural-language lists like[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-4)-- "foo, bar, baz and qux". The starting parameter can also be specified.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-5)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-6)local compressSparseArray = require('Module:TableTools').compressSparseArray[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-7)local p = {}[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-8)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-9)function p._main(args)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-10)local dataPlural = args.dataPlural[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-11)local separator = args.separator[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-12)-- Decode (convert to Unicode) HTML escape sequences, such as " " for space.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-13)and mw.text.decode(args.separator) or ''[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-14)local conjunction = args.conjunction and mw.text.decode(args.conjunction) or separator[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-15)-- Discard values before the starting parameter.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-16)local start = tonumber(args.start)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-17)if start then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-18)for i = 1, start - 1 do args[i] = nil end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-19)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-20)-- Discard named parameters.[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-21)local values = compressSparseArray(args)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-22)local result = mw.text.listToText(values, separator, conjunction)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-23)if dataPlural and #values > 0 and (#separator > 0 or #conjunction > 0) then[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-24)-- flag to [[Module:Detect singular]] whether this is a list with >1 element[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-25)result = result..''[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-26)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-27)return result[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-28)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-29)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-30)local function makeInvokeFunction(separator, conjunction, first)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-31)return function (frame)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-32)local args = require('Module:Arguments').getArgs(frame, {frameOnly = (frame.args.frameOnly or '') ~= ''})[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-33)args.separator = separator or args.separator[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-34)args.conjunction = conjunction or args.conjunction[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-35)args.first = first or args.first[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-36)return p._main(args)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-37)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-38)end[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-39)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-40)p.main = makeInvokeFunction()[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-41)p.br = makeInvokeFunction('
')[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-42)p.comma = makeInvokeFunction(mw.message.new('comma-separator'):plain())[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-43)[](https://freemwiki.com/index.php?mobileaction=toggle_view_mobile&title=Module%3ASeparated_entries#L-44)return p