Jump to content

Module:Hatnote inline/sandbox: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
rm doc duplication
sync
Line 1: Line 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/sandbox')
local mHatnote = require('Module:Hatnote/sandbox')
local mArguments = require('Module:Arguments')
local mArguments = require('Module:Arguments')
Line 6: Line 14:
function p.hatnoteInline (frame)
function p.hatnoteInline (frame)
local args = mArguments.getArgs(frame)
local args = mArguments.getArgs(frame)
local s = args[1]
local hatnote = mHatnote.hatnote(frame)
if not s then
return p.makeWikitextError(
'no text specified',
'Template:Hatnote#Errors',
args.category
)
end
local options = {
extraclasses = args.extraclasses,
selfref = args.selfref,
inline = 0
}
if args.inline == nil or yesno(args.inline, true) then
if args.inline == nil or yesno(args.inline, true) then
options.inline = 1
local subs = {
['<div'] = '<span',
['</div>$'] = '</span>'
}
for k, v in pairs(subs) do hatnote = string.gsub(hatnote, k, v, 1) end
end
end
return hatnote
return mHatnote._hatnote(s, options)
end
end



Revision as of 20:40, 21 December 2023

--------------------------------------------------------------------------------
--                              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/sandbox')
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