打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

目前wiki关闭了自行注册账号的功能,如需注册账号,请查阅Help:注册账号

模块:Outdent

来自RIA | Wiki
Aunst留言 | 贡献2023年8月7日 (一) 22:18的版本 (创建页面,内容为“local p = {} local getArgs = require('Module:Arguments').getArgs function p.outdent (frame) local args = getArgs(frame) local width = 0 local reversed = args['reverse'] or args['indent'] or args['r'] or args['in'] -- aliases for reverse if not args[1] then args[1] = '' end -- un-nil args[1] width = width + select(2, string.gsub(args[1],':','')) -- increase by 1 for every : width = width + select(2, string.…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

此模块的文档可以在模块:Outdent/doc创建

local p = {}
local getArgs = require('Module:Arguments').getArgs

function p.outdent (frame) 
	local args = getArgs(frame)
	local width = 0
	
	local reversed = args['reverse'] or args['indent'] or args['r'] or args['in']	-- aliases for reverse
	if not args[1] then args[1] = '' end                                        -- un-nil args[1]
	
	width = width + select(2, string.gsub(args[1],':',''))						-- increase by 1 for every :
	width = width + select(2, string.gsub(args[1],'*',''))						-- increase by 1 for every *
	width = width + select(2, string.gsub(args[1],'#','')) * 2					-- increase by 2 for every #
	
	if width == 0 then width = tonumber(args[1]) end							-- set width to args[1] if needed

	if not width then width = 10 end											-- default width
	if width < 0
	then
		width = -width
		reversed = not reversed
	end
	if width > 40 then width = 40 end											-- max width
	
	width = width * 1.6															-- set width to proper width
	
	local top = '<span style="display:block;width:' .. width .. 'em;height:0.5em;' .. (width == 0 and '' or 'border-bottom:1px solid #a2a9b1;') .. 'border-' .. ((width == 0 or reversed) and 'left' or 'right') ..':1px solid #a2a9b1;"></span>' -- top half
	local bottom = '<span style="display:block;width:' .. width .. 'em;height:0.5em;border-' .. (reversed and 'right' or 'left') .. ':1px solid #a2a9b1;"></span>' -- bottom half
	local note = args[2] and '([[wikipedia:Wikipedia:Indentation#Outdenting|外缩进]])' or '' -- note

	local templatestyles = mw.getCurrentFrame():extensionTag{
		name = 'templatestyles', args = { src = 'Module:Outdent/styles.css' }
	}

	return templatestyles .. '<div class="template-outdent' .. (reversed and ' reversed') .. '" style="width: ' .. width .. 'em;"><div class="template-outdent-line"></div></div>' .. '\n' .. note;
end

return p