Module:Sandbox/Yestarhumeler/Test

From Fallen London Wiki

Documentation for this module may be created at Module:Sandbox/Yestarhumeler/Test/doc

local p = {}

function p.xh2(frame)
	local text = frame.args[1]
	text = text:gsub('h2', 'xh2')
	mw.log(text)
	text = text:gsub(
		'==%s*(.+)%s*==',
		'<xh2>%1</xh2>'
	)
	mw.log(text)
	while text:find('<xh2>.+</xh2>') do
		local _, header, dbg
		_, _, header = text:find('<xh2>(.+)</xh2>')
		_, _, dbg = header:find('(.\'"`UNIQ%-%-[%w%d]+%-%d+%-QINU`"\'.)')
		mw.log(dbg)
		local header_clean = mw.text.trim(
			mw.text.killMarkers(header)
		)
		mw.log(header)
		mw.log(header_clean)
		mw.log(text)
		header = header:gsub('(%W)', '%%%1')
		_, _, dbg = text:find('(<xh2>' .. header .. '</xh2>)')
		text = text:gsub(
			'<xh2>' .. header .. '</xh2>',
			frame:extensionTag('xh2', header_clean)
		)
	end
	mw.log(text)
	return text
end

return p