Module:Ref info/sandbox explained

-- This module counts the number of times that various reference tags and cs1|2 templates appear.-- -- --

require('strict');local data = mw.loadData ('Module:Ref info/data');

--mw.logObject (data.cs12_stripped_list, 'data.cs12_stripped_list')local collapsible_tables =

----------------------------< T E M P L A T E _ N A M E _ T A B L E _ M A K E >------------------------------

makes a collapsed html table that holds a list of cs1 or cs2 template used in an article. The list occupies asingle row of the parent table.

local function template_name_table_make (name_list, group) local name_table = ;

local function comp (a, b) -- used in following table.sort return a:lower < b:lower; -- case-insensitive ascending alpha sort end

table.insert (name_table, '\n|-\n|scope="row" colspan="2" style="vertical-align:top;text-align:left" |\n'); -- create a blank row in parent table for this table table.insert (name_table, '

List of '); -- begin simple header row always displays table.insert (name_table, group); -- template group (cs1, cs2 TODO: vcite? harv?) table.insert (name_table, ' templates \n'); -- end of simple heading table.insert (name_table, '-\n\n
    \n'); -- new row, row content begins with
    ; open unordered list local t = ; for k, v in pairs (name_list) do -- spin through the list table.insert (t, string.format ('
  • %s (%s)
  • ', k, v)) -- make pretty unordered list of name with count end if not t[1] then return ; -- nothing in the list so abandon end

    table.sort (t, comp); -- case-insensitive ascending alpha sort table.insert (t, '

\n'); -- close unordered list table.insert (name_table, table.concat (t, '\n')); -- make a string and add to main table table.insert (name_table, '\n

'); -- close the table return table.concat (name_table); -- return html table as a stringend

----------------------------< C O L L E C T _ T E M P L A T E S >--------------------------------------------

function to collect every template

local function collect_templates (Article_content) local template_list = ; local tstart, tend = Article_content:find ("