<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://mywikibiz.com/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://mywikibiz.com/index.php?action=history&amp;feed=atom&amp;title=Module%3AExcerpt"/>
	<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:Excerpt&amp;action=history"/>
	<updated>2026-06-13T21:13:46Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.3</generator>
	<entry>
		<id>https://mywikibiz.com/index.php?title=Module:Excerpt&amp;diff=471607&amp;oldid=prev</id>
		<title>Zoran: Pywikibot 6.4.0</title>
		<link rel="alternate" type="text/html" href="https://mywikibiz.com/index.php?title=Module:Excerpt&amp;diff=471607&amp;oldid=prev"/>
		<updated>2021-07-15T21:29:31Z</updated>

		<summary type="html">&lt;p&gt;Pywikibot 6.4.0&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&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, getArg('article') )&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&lt;br /&gt;
	local fragment = getArg('fragment')&lt;br /&gt;
	local section = fragment or getArg(2, getArg('section', mw.ustring.match( getArg(1, getArg('article') ), '[^#]+#([^#]+)') ) )&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', getArg('reference', ( only == 'reference' and 1 ) ) )&lt;br /&gt;
	local sections = not yesno( getArg('sections') )&lt;br /&gt;
	local noBold = not yesno( getArg('bold') )&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;
	local blacklist = table.concat((config.templates or {}), ',')&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;quot;''&amp;quot; .. '&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;' .. &amp;quot;''&amp;quot;&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;
		end&lt;br /&gt;
		hat = mw.html.create('div'):addClass('dablink excerpt-hat'):wikitext(hat)&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 arguments 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;
		templates = templates or '-' .. blacklist,&lt;br /&gt;
		sections = sections,&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 = true,&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;
	-- Add a line break in case the excerpt starts with a table or list&lt;br /&gt;
	excerpt = '\n' .. excerpt&lt;br /&gt;
&lt;br /&gt;
	-- If no file was found, try to excerpt one from the removed infoboxes&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;
		local templates = Transcluder.get(title, { only = 'templates', templates = blacklist, fixReferences = true } )&lt;br /&gt;
		local parameters = Transcluder.getParameters(templates)&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;
				excerpt = Transcluder.removeNonFreeFiles(excerpt)&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&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>Zoran</name></author>
	</entry>
</feed>