跳转到内容

模組:NoteTA/MediaWiki

维基百科,自由的百科全书

这是本页的一个历史版本,由SunAfterRain留言 | 贡献2020年2月4日 (二) 06:55编辑。这可能和当前版本存在着巨大的差异。

local z = {}
local WikitextLC = require( 'Module:WikitextLC' )
local NoteTA = require( 'Module:NoteTA' )

local function makeText( frame, v )
	return mw.text.trim( frame:preprocess(v.text) ) .. '\n'
end

local function makeItem( frame, v )
	local text = '* '
	if v.original then
		text = text .. '原文:' .. v.original .. ';'
	end
	return text .. '-{D|' .. v.rule .. '}-当前显示为:-{|' .. v.rule .. '}-\n'
end

function z.showdate( frame )
	local data = require( 'Module:NoteTA/MediaWiki/code' )
	local pieces = { '<strong>以下是[[Wikipedia:字詞轉換處理/公共轉換組|公共转换组]]“MediaWiki”。</strong>\n\n' }
	for i, v in ipairs( data.content ) do
		if v.type == 'text' then
			table.insert( pieces, makeText( frame, v ) )
		elseif v.type == 'item' then
			table.insert( pieces, makeItem( frame, v ) )
		end
	end
	table.insert( pieces, '[[Category:公共轉換組模板|' .. name .. ']]' )
	return table.concat( pieces )
end

function z._main( args )
	local Tc = NoteTA.Tcode( args )
	--local Gc = NoteTA.Gcode( args, frame )
	--==>不接受轉換組
	local Gc
	local Lc = NoteTA.Lcode( args )
	local code = Tc .. Gc .. Lc
	if code ~= '' then
		local hash = require( 'Module:Crc32lua' ).crc32( mw.dumpObject( args ) )
		code = frame:extensionTag{
			name = 'indicator',
			content = '[[File:Zh conversion icon m.svg|35px|本页使用了标题或全文手工转换|link=]]',
			args = { name = string.format( 'noteTA-%x', hash ) },
		} .. tostring( mw.html.create( 'div' )
				:attr( 'id', string.format( 'noteTA-%x', hash ) )
				:attr( 'class', 'noteTA' )
				:wikitext( code ) )
		if mw.title.getCurrentTitle():inNamespace( 'Template' ) then
			code = code .. '[[Category:放置于模板的noteTA]]'
		end
	end
	return code
end