Module:Hatnote inline

From Wayne's Dusty Box of Words

{{#ifeq:Hatnote inline|doc|{{#if:|Template:Pp}}|{{#switch:

 {{#if:
 |     
 | {{#ifeq:Module|Module
   | module
   | other
   }}
 }}

| module =

| other | #default = Script error: No such module "Error". }}}}

This module produces hatnote-style notes ≠ self-references and notes-to-reader – usually to related articles or a section/anchor at the same page. It does this inside a {{#switch:pair

 |c|close =
 |e|empty|s|single|v|void
 |o|open
 |p|pair = <{{#if:|span|span}}{{#if:| {{{attribs}}}}}
}}{{#switch:pair
 |c|close = 
 |e|empty|s|single|v|void =  />
 |o|open = >
 |p|pair = {{#ifeq:span|!--||>}}...
}}{{#switch:pair
 |e|empty|s|single|v|void
 |o|open =
 |c|close
 |p|pair = {{#ifeq:span|!--|-->|</span>}}
}}, instead of the {{#switch:pair
 |c|close =
 |e|empty|s|single|v|void
 |o|open
 |p|pair = <{{#if:|div|div}}{{#if:| {{{attribs}}}}}
}}{{#switch:pair
 |c|close = 
 |e|empty|s|single|v|void =  />
 |o|open = >
 |p|pair = {{#ifeq:div|!--||>}}...
}}{{#switch:pair
 |e|empty|s|single|v|void
 |o|open =
 |c|close
 |p|pair = {{#ifeq:div|!--|-->|</div>}}
}} used by Module:Hatnote.  It implements the {{[[{{#if:|{{{SISTER}}}Template|Template}}:hatnote inline|hatnote inline]]{{#if:||{{{2}}}}}{{#if:||{{{3}}}}}{{#if:||{{{4}}}}}{{#if:||{{{5}}}}}{{#if:||{{{6}}}}}{{#if:||{{{7}}}}}{{#if:||...}}}} meta-template.

Usage

{{#invoke:Hatnote inline|hatnote|text}}

{{#if:{{#ifeq:Hatnote|sandbox|1}}{{#ifeq:Hatnote inline|doc|1}}|| }}


--------------------------------------------------------------------------------
--                              Module:Hatnote-inline                         --
--                                                                            --
-- This module produces hatnote-style links, and links to related articles,	  --
-- but inside a <span>, instead of the <div> used by Module:Hatnote.  It      --
-- implements the {{hatnote-inline}} meta-template.                           --
--------------------------------------------------------------------------------

local mHatnote = require('Module:Hatnote')
local mArguments = require('Module:Arguments')
local yesno = require('Module:Yesno')
local p = {}

function p.hatnoteInline (frame)
	local args = mArguments.getArgs(frame)
	local hatnote = mHatnote.hatnote(frame)
	if args.inline == nil or yesno(args.inline, true) then
		local subs = {
			['<div'] = '<span',
			['</div>$'] = '</span>'
		}
		for k, v in pairs(subs) do hatnote = string.gsub(hatnote, k, v, 1) end
	end
	return hatnote
end

p.hatnote = p.hatnoteInline --alias

return p