跳转到内容

模組:NoteTA/MediaWiki

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

这是本页的一个历史版本,由SunAfterRain留言 | 贡献2020年2月4日 (二) 06:45 建立内容为“local z = {} local WikitextLC = require( 'Module:WikitextLC' ) local NoteTA = require( 'Module:NoteTA' ) local function makeTopText( frame, v ) lo…”的新页面)编辑。这可能和当前版本存在着巨大的差异。

(差异) ←上一修订 | 最后版本 (差异) | 下一修订→ (差异)
local z = {}
local WikitextLC = require( 'Module:WikitextLC' )
local NoteTA = require( 'Module:NoteTA' )

local function makeTopText( frame, v )
	local text = v.top
	if not v.preprocessed then
		text = frame:preprocess( text )
	end
	return mw.text.trim( text ) .. '\n'
end

local function makeText( frame, v )
	local text = v.text
	if not v.preprocessed then
		text = frame:preprocess( text )
	end
	return mw.text.trim( 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.show( frame )
	local data = require( 'Module:NoteTA/MediaWiki/code' )
	local text = '-{H|zh-hans:模块;zh-hant:模組}-<strong>以下是[[Wikipedia:字詞轉換處理/公共轉換組|公共转换组]]“' .. data.description .. '”。</strong>\n\n'
	for i, v in ipairs( data.content ) do
		if v.type == 'top' then
			text = text .. makeTopText( frame, v )
		elseif v.type == 'text' then
			text = text .. makeText( frame, v )
		elseif v.type == 'item' then
			text = text .. makeItem( frame, v )
		end
	end
	text = text .. '[[Category:公共转换组模块|sandbox]]' 
	return text
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