<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.thegoonshow.co.uk/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AExcerpt</id>
	<title>Module:Excerpt - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.thegoonshow.co.uk/wiki/index.php?action=history&amp;feed=atom&amp;title=Module%3AExcerpt"/>
	<link rel="alternate" type="text/html" href="https://www.thegoonshow.co.uk/wiki/index.php?title=Module:Excerpt&amp;action=history"/>
	<updated>2026-05-14T07:02:44Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.38.2</generator>
	<entry>
		<id>https://www.thegoonshow.co.uk/wiki/index.php?title=Module:Excerpt&amp;diff=7497&amp;oldid=prev</id>
		<title>Kurt: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://www.thegoonshow.co.uk/wiki/index.php?title=Module:Excerpt&amp;diff=7497&amp;oldid=prev"/>
		<updated>2022-07-24T17:45:04Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 12:45, 24 July 2022&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Kurt</name></author>
	</entry>
	<entry>
		<id>https://www.thegoonshow.co.uk/wiki/index.php?title=Module:Excerpt&amp;diff=7496&amp;oldid=prev</id>
		<title>en&gt;Sophivorus: Update to 1.2</title>
		<link rel="alternate" type="text/html" href="https://www.thegoonshow.co.uk/wiki/index.php?title=Module:Excerpt&amp;diff=7496&amp;oldid=prev"/>
		<updated>2022-06-05T13:43:46Z</updated>

		<summary type="html">&lt;p&gt;Update to 1.2&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;-- Module:Excerpt implements the Excerpt template&lt;br /&gt;
-- Documentation https://www.mediawiki.org/wiki/Module:Excerpt&lt;br /&gt;
-- By User:Sophivorus, User:Certes &amp;amp; others&lt;br /&gt;
-- Version 1.2&lt;br /&gt;
-- License CC-BY-SA-4.0&lt;br /&gt;
&lt;br /&gt;
local Transcluder = require('Module:Transcluder')&lt;br /&gt;
&lt;br /&gt;
local yesno = require('Module:Yesno')&lt;br /&gt;
&lt;br /&gt;
local ok, config = pcall(require, 'Module:Excerpt/config')&lt;br /&gt;
if not ok then config = {} end&lt;br /&gt;
&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- Helper function to get arguments&lt;br /&gt;
local args&lt;br /&gt;
function getArg(key, default)&lt;br /&gt;
	value = args[key]&lt;br /&gt;
	if value and mw.text.trim(value) ~= '' then&lt;br /&gt;
		return value&lt;br /&gt;
	end&lt;br /&gt;
	return default&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Helper function to handle errors&lt;br /&gt;
function getError(message, value)&lt;br /&gt;
	if type(message) == 'string' then&lt;br /&gt;
		message = Transcluder.getError(message, value)&lt;br /&gt;
	end&lt;br /&gt;
	if config.categories and config.categories.errors and mw.title.getCurrentTitle().isContentPage then&lt;br /&gt;
		message:node('[[Category:' .. config.categories.errors .. ']]')&lt;br /&gt;
	end&lt;br /&gt;
	return message&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Helper function to get localized messages&lt;br /&gt;
function getMessage(key)&lt;br /&gt;
	local ok, TNT = pcall(require, 'Module:TNT')&lt;br /&gt;
	if not ok then return key end&lt;br /&gt;
	return TNT.format('I18n/Module:Excerpt.tab', key)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
	args = Transcluder.parseArgs(frame)&lt;br /&gt;
&lt;br /&gt;
	-- Make sure the requested page exists&lt;br /&gt;
	local page = getArg(1)&lt;br /&gt;
	if not page then return getError('no-page') end&lt;br /&gt;
	local title = mw.title.new(page)&lt;br /&gt;
	if not title then return getError('no-page') end&lt;br /&gt;
	if title.isRedirect then title = title.redirectTarget end&lt;br /&gt;
	if not title.exists then return getError('page-not-found', page) end&lt;br /&gt;
	page = title.prefixedText&lt;br /&gt;
&lt;br /&gt;
	-- Set variables from the template parameters&lt;br /&gt;
	local section = getArg(2, mw.ustring.match( getArg(1), '[^#]+#(.+)') )&lt;br /&gt;
	local hat = yesno( getArg('hat', true) )&lt;br /&gt;
	local edit = yesno( getArg('edit', true) )&lt;br /&gt;
	local this = getArg('this')&lt;br /&gt;
	local only = getArg('only')&lt;br /&gt;
	local files = getArg('files', getArg('file', ( only == 'file' and 1 ) ) )&lt;br /&gt;
	local lists = getArg('lists', getArg('list', ( only == 'list' and 1 ) ) )&lt;br /&gt;
	local tables = getArg('tables', getArg('table', ( only == 'table' and 1 ) ) )&lt;br /&gt;
	local templates = getArg('templates', getArg('template', ( only == 'template' and 1 ) ) )&lt;br /&gt;
	local paragraphs = getArg('paragraphs', getArg('paragraph', ( only == 'paragraph' and 1 ) ) )&lt;br /&gt;
	local references = getArg('references')&lt;br /&gt;
	local subsections = not yesno( getArg('subsections') )&lt;br /&gt;
	local noBold = not yesno( getArg('bold') )&lt;br /&gt;
	local freefiles = yesno( getArg('freefiles') )&lt;br /&gt;
	local inline = yesno( getArg('inline') )&lt;br /&gt;
	local quote = yesno( getArg('quote') )&lt;br /&gt;
	local more = yesno( getArg('more') )&lt;br /&gt;
	local class = getArg('class')&lt;br /&gt;
&lt;br /&gt;
	-- Build the hatnote&lt;br /&gt;
	if hat and not inline then&lt;br /&gt;
		if this then&lt;br /&gt;
			hat = this&lt;br /&gt;
		elseif quote then&lt;br /&gt;
			hat = getMessage('this')&lt;br /&gt;
		elseif only then&lt;br /&gt;
			hat = getMessage(only)&lt;br /&gt;
		else&lt;br /&gt;
			hat = getMessage('section')&lt;br /&gt;
		end&lt;br /&gt;
		hat = hat .. ' ' .. getMessage('excerpt') .. ' '&lt;br /&gt;
		if section and not fragment then&lt;br /&gt;
			hat = hat .. '[[:' .. page .. '#' .. mw.uri.anchorEncode(section) .. '|' .. page&lt;br /&gt;
				.. ' § ' .. mw.ustring.gsub(section, '%[%[([^]|]+)|?[^]]*%]%]', '%1') .. ']].' -- remove nested links&lt;br /&gt;
		else&lt;br /&gt;
			hat = hat .. '[[:' .. page .. '|' .. page .. ']].'&lt;br /&gt;
		end&lt;br /&gt;
		if edit then&lt;br /&gt;
			hat = hat .. '&amp;lt;span class=&amp;quot;mw-editsection-like plainlinks&amp;quot;&amp;gt;&amp;lt;span class=&amp;quot;mw-editsection-bracket&amp;quot;&amp;gt;[&amp;lt;/span&amp;gt;['&lt;br /&gt;
			hat = hat .. title:fullUrl('action=edit') .. ' ' .. mw.message.new('editsection'):plain()&lt;br /&gt;
			hat = hat .. ']&amp;lt;span class=&amp;quot;mw-editsection-bracket&amp;quot;&amp;gt;]&amp;lt;/span&amp;gt;&amp;lt;/span&amp;gt;'&lt;br /&gt;
		end&lt;br /&gt;
		if config.hat then&lt;br /&gt;
			hat = config.hat .. hat .. '}}'&lt;br /&gt;
			hat = frame:preprocess(hat)&lt;br /&gt;
		else&lt;br /&gt;
			hat = mw.html.create('div'):addClass('dablink excerpt-hat'):wikitext(hat)&lt;br /&gt;
		end&lt;br /&gt;
	else&lt;br /&gt;
		hat = nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Build the &amp;quot;Read more&amp;quot; link&lt;br /&gt;
	if more and not inline then&lt;br /&gt;
		more = &amp;quot;'''[[&amp;quot; .. page .. '#' .. (section or '') .. &amp;quot;|&amp;quot; .. getMessage('more') .. &amp;quot;]]'''&amp;quot;&lt;br /&gt;
		more = mw.html.create('div'):addClass('noprint excerpt-more'):wikitext(more)&lt;br /&gt;
	else&lt;br /&gt;
		more = nil&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Build the options for Module:Transcluder out of the template parameters and the desired defaults&lt;br /&gt;
	local options = {&lt;br /&gt;
		files = files,&lt;br /&gt;
		lists = lists,&lt;br /&gt;
		tables = tables,&lt;br /&gt;
		paragraphs = paragraphs,&lt;br /&gt;
		sections = subsections,&lt;br /&gt;
		categories = 0,&lt;br /&gt;
		references = references,&lt;br /&gt;
		only = only and mw.text.trim(only, 's') .. 's',&lt;br /&gt;
		noBold = noBold,&lt;br /&gt;
		noSelfLinks = true,&lt;br /&gt;
		noNonFreeFiles = freefiles,&lt;br /&gt;
		noBehaviorSwitches = true,&lt;br /&gt;
		fixReferences = true,&lt;br /&gt;
		linkBold = true,&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	-- Get the excerpt itself&lt;br /&gt;
	local title = page .. '#' .. (section or '')&lt;br /&gt;
	local ok, excerpt = pcall(Transcluder.get, title, options)&lt;br /&gt;
	if not ok then return getError(excerpt) end&lt;br /&gt;
	if mw.text.trim(excerpt) == '' and not only then&lt;br /&gt;
		if section then return getError('section-empty', section) else return getError('lead-empty') end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- If no file was found, try to get one from the infobox&lt;br /&gt;
	local fileNamespaces = Transcluder.getNamespaces('File')&lt;br /&gt;
	if ((only == 'file' or only == 'files') or (not only and (files ~= '0' or not files))) and -- caller asked for files&lt;br /&gt;
		not Transcluder.matchAny(excerpt, '%[%[', fileNamespaces, ':') and -- and there are no files in Transcluder's output&lt;br /&gt;
		config.captions -- and we have the config option required to try finding files in templates&lt;br /&gt;
	then&lt;br /&gt;
		-- We cannot distinguish the infobox from the other templates so we search them all&lt;br /&gt;
		local infobox = Transcluder.getTemplates(excerpt);&lt;br /&gt;
		infobox = table.concat(infobox)&lt;br /&gt;
		local parameters = Transcluder.getParameters(infobox)&lt;br /&gt;
		local file, captions, caption&lt;br /&gt;
		for _, pair in pairs(config.captions) do&lt;br /&gt;
			file = pair[1]&lt;br /&gt;
			file = parameters[file]&lt;br /&gt;
			if file and Transcluder.matchAny(file, '^.*%.', {'[Jj][Pp][Ee]?[Gg]','[Pp][Nn][Gg]','[Gg][Ii][Ff]','[Ss][Vv][Gg]'}, '.*') then&lt;br /&gt;
				file = mw.ustring.match(file, '%[?%[?.-:([^{|]+)%]?%]?') or file -- [[File:Example.jpg{{!}}upright=1.5]] to Example.jpg&lt;br /&gt;
				captions = pair[2]&lt;br /&gt;
				for _, p in pairs(captions) do&lt;br /&gt;
					if parameters[p] then caption = parameters[p] break end&lt;br /&gt;
				end&lt;br /&gt;
				excerpt = '[[File:' .. file .. '|thumb|' .. (caption or '') .. ']]' .. excerpt&lt;br /&gt;
				if ( freefiles ) then&lt;br /&gt;
					excerpt = Transcluder.removeNonFreeFiles(excerpt)&lt;br /&gt;
				end&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Unlike other elements, templates are filtered here&lt;br /&gt;
	-- because we had to search the infoboxes for files&lt;br /&gt;
	local trash&lt;br /&gt;
	if only and (only == 'template' or only == 'templates') then&lt;br /&gt;
		trash, excerpt = Transcluder.getTemplates(excerpt, templates);&lt;br /&gt;
	else -- Remove blacklisted templates&lt;br /&gt;
		local blacklist = config.blacklist and table.concat(config.blacklist, ',') or ''&lt;br /&gt;
		if templates then&lt;br /&gt;
			if string.sub(templates, 1, 1) == '-' then --Unwanted templates. Append to blacklist&lt;br /&gt;
				blacklist = templates .. ',' .. blacklist&lt;br /&gt;
			else --Wanted templates. Replaces blacklist and acts as whitelist&lt;br /&gt;
				blacklist = templates&lt;br /&gt;
			end&lt;br /&gt;
		else&lt;br /&gt;
			blacklist = '-' .. blacklist&lt;br /&gt;
		end&lt;br /&gt;
		trash, excerpt = Transcluder.getTemplates(excerpt, blacklist);&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Remove extra line breaks but leave one before and after so the parser interprets lists, tables, etc. correctly&lt;br /&gt;
	excerpt = mw.text.trim(excerpt)&lt;br /&gt;
	excerpt = string.gsub(excerpt, '\n\n\n+', '\n\n')&lt;br /&gt;
	excerpt = '\n' .. excerpt .. '\n'&lt;br /&gt;
&lt;br /&gt;
	-- Remove nested categories&lt;br /&gt;
	excerpt = frame:preprocess(excerpt)&lt;br /&gt;
	local categories, excerpt = Transcluder.getCategories(excerpt, options.categories)&lt;br /&gt;
&lt;br /&gt;
	-- Add tracking categories&lt;br /&gt;
	if config.categories then&lt;br /&gt;
		local contentCategory = config.categories.content&lt;br /&gt;
		if contentCategory and mw.title.getCurrentTitle().isContentPage then&lt;br /&gt;
			excerpt = excerpt .. '[[Category:' .. contentCategory .. ']]'&lt;br /&gt;
		end&lt;br /&gt;
		local namespaceCategory = config.categories[ mw.title.getCurrentTitle().namespace ]&lt;br /&gt;
		if namespaceCategory then&lt;br /&gt;
			excerpt = excerpt .. '[[Category:' .. namespaceCategory .. ']]'&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Load the styles&lt;br /&gt;
	local styles&lt;br /&gt;
	if config.styles then&lt;br /&gt;
		styles = frame:extensionTag( 'templatestyles', '', { src = config.styles } )&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Combine and return the elements&lt;br /&gt;
	local tag1 = 'div'&lt;br /&gt;
	local tag2 = 'div'&lt;br /&gt;
	if inline then&lt;br /&gt;
		tag1 = 'span'&lt;br /&gt;
		tag2 = 'span'&lt;br /&gt;
	elseif quote then&lt;br /&gt;
		tag2 = 'blockquote'&lt;br /&gt;
	end&lt;br /&gt;
	excerpt = mw.html.create(tag1):addClass('excerpt'):wikitext(excerpt)&lt;br /&gt;
	local block = mw.html.create(tag2):addClass('excerpt-block'):addClass(class)&lt;br /&gt;
	return block:node(styles):node(hat):node(excerpt):node(more)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Entry points for backwards compatibility&lt;br /&gt;
function p.lead(frame) return p.main(frame) end&lt;br /&gt;
function p.excerpt(frame) return p.main(frame) end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>en&gt;Sophivorus</name></author>
	</entry>
</feed>