<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2F%C3%9Ejarkur%2FIPAc-is</id>
	<title>Module:Sandbox/Þjarkur/IPAc-is - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2F%C3%9Ejarkur%2FIPAc-is"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/%C3%9Ejarkur/IPAc-is&amp;action=history"/>
	<updated>2026-08-02T10:08:07Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Sandbox/%C3%9Ejarkur/IPAc-is&amp;diff=146657&amp;oldid=prev</id>
		<title>imported&gt;Þjarkur: Module sandboxing</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/%C3%9Ejarkur/IPAc-is&amp;diff=146657&amp;oldid=prev"/>
		<updated>2019-01-26T13:55:13Z</updated>

		<summary type="html">&lt;p&gt;Module sandboxing&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- This module implements [[Template:IPAc-is]].&lt;br /&gt;
&lt;br /&gt;
local data = mw.loadData(&amp;#039;Module:Sandbox/Þjarkur/IPAc-is/data&amp;#039;)&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- Global container for tracking categories&lt;br /&gt;
local categoryHandler = require(&amp;#039;Module:Category handler&amp;#039;).main&lt;br /&gt;
local categories = {}&lt;br /&gt;
&lt;br /&gt;
-- Trims whitespace from a string&lt;br /&gt;
local function trim(s)&lt;br /&gt;
  return s:match(&amp;#039;^%s*(.-)%s*$&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- This implements [[Template:Nowrap]].&lt;br /&gt;
local function makeNowrapSpan(s)&lt;br /&gt;
  local span = mw.html.create(&amp;#039;span&amp;#039;)&lt;br /&gt;
  :addClass(&amp;#039;nowrap&amp;#039;)&lt;br /&gt;
  :wikitext(s)&lt;br /&gt;
  return tostring(span)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- This adds a tooltip icon to a label. It implements [[Template:H:title]].&lt;br /&gt;
local function makeTooltip(label, tooltip)&lt;br /&gt;
  local span = mw.html.create(&amp;#039;span&amp;#039;)&lt;br /&gt;
  :attr(&amp;#039;title&amp;#039;, tooltip)&lt;br /&gt;
  :wikitext(label)&lt;br /&gt;
  return tostring(span)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function formatPhonemeGroup(phonemes)&lt;br /&gt;
  if #phonemes &amp;gt; 0 then&lt;br /&gt;
    local span = mw.html.create(&amp;#039;span&amp;#039;)&lt;br /&gt;
    :css(&amp;#039;border-bottom&amp;#039;, &amp;#039;1px dotted&amp;#039;)&lt;br /&gt;
    :wikitext(table.concat(phonemes))&lt;br /&gt;
    return tostring(span)&lt;br /&gt;
  else&lt;br /&gt;
    return &amp;#039;&amp;#039;&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function renderCategories()&lt;br /&gt;
  local ret = &amp;#039;&amp;#039;&lt;br /&gt;
  ret = categoryHandler{&lt;br /&gt;
    [1] = &amp;#039;yes&amp;#039;, -- Add categories in these namespaces&lt;br /&gt;
    main = 1,&lt;br /&gt;
    wikipedia = 1,&lt;br /&gt;
    file = 1,&lt;br /&gt;
    template = 1,&lt;br /&gt;
    help = 1,&lt;br /&gt;
    category = 1,&lt;br /&gt;
    portal = 1,&lt;br /&gt;
    book = 1,&lt;br /&gt;
    draft = 1,&lt;br /&gt;
    module = 1,&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  if ret == &amp;#039;yes&amp;#039; then&lt;br /&gt;
    ret = {}&lt;br /&gt;
    for cat in pairs(categories) do&lt;br /&gt;
      table.insert(ret, string.format(&amp;#039;[[Category:%s]]&amp;#039;, cat))&lt;br /&gt;
    end&lt;br /&gt;
    table.sort(ret)&lt;br /&gt;
    ret = table.concat(ret)&lt;br /&gt;
  else&lt;br /&gt;
    ret = &amp;#039;&amp;#039;&lt;br /&gt;
  end&lt;br /&gt;
  return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p._main(args)&lt;br /&gt;
  local ret = {}&lt;br /&gt;
  local i = 0 -- Keeps track of numbered args&lt;br /&gt;
&lt;br /&gt;
  -- Phonemes&lt;br /&gt;
  do&lt;br /&gt;
    -- Loop through the numbered args, separating them into phoneme groups&lt;br /&gt;
    -- and separator strings (both called &amp;quot;words&amp;quot; for convenience). We only&lt;br /&gt;
    -- underline the phoneme groups, not the separators.&lt;br /&gt;
    local words = {}&lt;br /&gt;
    words[#words + 1] = &amp;#039;/&amp;#039; -- Opening slash&lt;br /&gt;
    i = i - 1 -- Set up i again as it was changed in the pronunciation loop&lt;br /&gt;
    local id&lt;br /&gt;
    repeat&lt;br /&gt;
      local phonemes = {}&lt;br /&gt;
      local isWordEnd = false&lt;br /&gt;
      while not isWordEnd do&lt;br /&gt;
        i = i + 1&lt;br /&gt;
        id = args[i]&lt;br /&gt;
        id = id and trim(id)&lt;br /&gt;
        if not id then&lt;br /&gt;
          isWordEnd = true&lt;br /&gt;
          words[#words + 1] = formatPhonemeGroup(phonemes)&lt;br /&gt;
        elseif id ~= &amp;#039;&amp;#039; then&lt;br /&gt;
          local t = data.phonemes[id]&lt;br /&gt;
          if not t then&lt;br /&gt;
            -- We were passed an invalid id.&lt;br /&gt;
            isWordEnd = true&lt;br /&gt;
            categories[&amp;quot;Ill-formatted IPAc-en transclusions&amp;quot;] = true&lt;br /&gt;
            words[#words + 1] = formatPhonemeGroup(phonemes)&lt;br /&gt;
            words[#words + 1] = makeTooltip(&lt;br /&gt;
              string.format(&lt;br /&gt;
                &amp;quot;&amp;lt;strong class=\&amp;quot;error\&amp;quot;&amp;gt;[invalid input: &amp;#039;%s&amp;#039;]&amp;lt;/strong&amp;gt;&amp;quot;,&lt;br /&gt;
                id&lt;br /&gt;
              ),&lt;br /&gt;
              &amp;#039;Unrecognized symbol&amp;#039;&lt;br /&gt;
            )&lt;br /&gt;
          elseif not t.label then&lt;br /&gt;
            -- The data module contains bad data, so throw an error.&lt;br /&gt;
            error(string.format(&lt;br /&gt;
              &amp;quot;no label was found for id &amp;#039;%s&amp;#039;&amp;quot;,&lt;br /&gt;
              tostring(id)&lt;br /&gt;
            ))&lt;br /&gt;
          elseif t.tooltip then&lt;br /&gt;
            -- We are dealing with a regular phoneme.&lt;br /&gt;
            phonemes[#phonemes + 1] = makeTooltip(&lt;br /&gt;
              t.label,&lt;br /&gt;
              t.tooltip&lt;br /&gt;
            )&lt;br /&gt;
          else&lt;br /&gt;
            -- We are dealing with a separator.&lt;br /&gt;
            isWordEnd = true&lt;br /&gt;
            words[#words + 1] = formatPhonemeGroup(phonemes)&lt;br /&gt;
            words[#words + 1] = t.label&lt;br /&gt;
          end&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    until not id&lt;br /&gt;
    words[#words + 1] = &amp;#039;/&amp;#039; -- Closing slash&lt;br /&gt;
&lt;br /&gt;
    -- Wrap the words in a link to IPA help.&lt;br /&gt;
    local span = mw.html.create(&amp;#039;span&amp;#039;)&lt;br /&gt;
    -- Suppress Navigation popups and Page Previews (aka Hovercards)&lt;br /&gt;
    :addClass(&amp;#039;IPA nopopups noexcerpt&amp;#039;)&lt;br /&gt;
    :wikitext(string.format(&lt;br /&gt;
      &amp;#039;[[Help:IPA/Icelandic|%s]]&amp;#039;,&lt;br /&gt;
      table.concat(words)&lt;br /&gt;
    ))&lt;br /&gt;
&lt;br /&gt;
    ret[#ret + 1] = tostring(span)&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  -- Audio link&lt;br /&gt;
  do&lt;br /&gt;
    local file = args.audio and trim(args.audio)&lt;br /&gt;
    if file and file ~= &amp;#039;&amp;#039; then&lt;br /&gt;
      -- if args[1] and string.lower(trim(args[1])) == &amp;#039;uk&amp;#039; then&lt;br /&gt;
      --   categories[&amp;quot;Pages including recorded pronunciations (UK English)&amp;quot;] = true&lt;br /&gt;
      -- elseif args[1] and string.lower(trim(args[1])) == &amp;#039;us&amp;#039; then&lt;br /&gt;
      --   categories[&amp;quot;Pages including recorded pronunciations (US English)&amp;quot;] = true&lt;br /&gt;
      -- else&lt;br /&gt;
      --   categories[&amp;quot;Pages including recorded pronunciations (English)&amp;quot;] = true&lt;br /&gt;
      -- end&lt;br /&gt;
&lt;br /&gt;
      ret[#ret + 1] = mw.getCurrentFrame():expandTemplate{&lt;br /&gt;
      title = &amp;#039;Template:IPA audio link&amp;#039;, args = { file } }&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
&lt;br /&gt;
  -- Nowrap and categories&lt;br /&gt;
  ret = makeNowrapSpan(table.concat(ret)) .. renderCategories()&lt;br /&gt;
&lt;br /&gt;
  -- Reset the categories table in case we are run again.&lt;br /&gt;
  categories = {}&lt;br /&gt;
&lt;br /&gt;
  return ret&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
  return p._main(frame:getParent().args)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>imported&gt;Þjarkur</name></author>
	</entry>
</feed>