跳转到内容

模块:沙盒/a2569875/Test1

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


引用错误:页面中存在<ref group="n">标签,但没有找到相应的<references group="n" />标签

  1. ^ 引用错误:没有为名为kaiko7000的参考文献提供内容
  2. ^ 引用错误:没有为名为ocean23_2_112的参考文献提供内容
  3. ^ sphere depth of the ocean – hydrology. Encyclopedia Britannica. [2015-04-12]. (原始内容存档于2014-11-29). 
  4. ^ Third rock from the Sun – restless Earth. NASA's Cosmos. [2015-04-12]. (原始内容存档于2015-11-06). 
  5. ^ Perlman, Howard. The World's Water. USGS Water-Science School. 2014-03-17 [2015-04-12]. (原始内容存档于2015-04-22). 
  6. ^ 引用错误:没有为名为kennish2001的参考文献提供内容
  7. ^ 引用错误:没有为名为mullen2002的参考文献提供内容
  8. ^ 引用错误:没有为名为natsci_oxy4的参考文献提供内容
  9. ^ 引用错误:没有为名为michon2006的参考文献提供内容
  10. ^ 引用错误:没有为名为sample2005的参考文献提供内容
  11. ^ 洋流与气候. 中国科普博览. 中国科学院. [2016-08-25]. (原始内容存档于2016-09-13). 
  12. ^ How does the oceans current affect the climate of the east coast?. UCSB ScienceLine. University of California. 2015 [2016-08-24]. (原始内容存档于2017-01-12). 
local p = {}

local lib_arg = {}

local eleconflists = {
	["元素"] = {  },
	["零號元素"] = { EC={} },
	["氫"] = { EC={{1}} },
	["氦"] = { EC={{2}} },
	["鋰"] = { EC={{2},{1},cen="He"} },
	["鈹"] = { EC={{2},{2},cen="He"} },
	["硼"] = { EC={{2},{2,1},cen="He"} },
	["碳"] = { EC={{2},{2,2},cen="He"} },
	["氮"] = { EC={{2},{2,3},cen="He"} },
	["氧"] = { EC={{2},{2,4},cen="He"} },
	["氟"] = { EC={{2},{2,5},cen="He"} },
	["氖"] = { EC={{2},{2,{{6,''}}},cen="He"} },
	["鈉"] = { EC={{2},{2,6},{1},cen="Ne"} },
	["鎂"] = { EC={{2},{2,6},{2},cen="Ne"} },
	["鋁"] = { EC={{2},{2,6},{2,1},cen="Ne"} },
	["矽"] = { EC={{2},{2,6},{2,2},cen="Ne"} },
	["磷"] = { EC={{2},{2,6},{2,3},cen="Ne"} },
	["硫"] = { EC={{2},{2,6},{2,4},cen="Ne"} },
	["氯"] = { EC={{2},{2,6},{2,5},cen="Ne"} },
	["氬"] = { EC={{2},{2,6},{2,6},cen="Ne"} },
	["鉀"] = { EC={{2},{2,6},{2,6},{1},cen="Ar"} },
	["鈣"] = { EC={{2},{2,6},{2,6},{2},cen="Ar"} },
	["鈧"] = { EC={{2},{2,6},{2,6,1},{2},cen="Ar"} },
	["鈦"] = { EC={{2},{2,6},{2,6,2},{2},cen="Ar"} },
	["釩"] = { EC={{2},{2,6},{2,6,3},{2},cen="Ar"} },
	["鉻"] = { EC={{2},{2,6},{2,6,5},{1},cen="Ar"} },
	["錳"] = { EC={{2},{2,6},{2,6,5},{2},cen="Ar"} },
	["鐵"] = { EC={{2},{2,6},{2,6,6},{2},cen="Ar"} },
	["鈷"] = { EC={{2},{2,6},{2,6,7},{2},cen="Ar"} },
	["鎳"] = { EC={{2},{2,6},{2,6,8},{2},cen="Ar"} },
	["銅"] = { EC={{2},{2,6},{2,6,10},{1},cen="Ar"} },
	["鋅"] = { EC={{2},{2,6},{2,6,10},{2},cen="Ar"} },
	["鎵"] = { EC={{2},{2,6},{2,6,10},{2,1},cen="Ar"} },
	["鍺"] = { EC={{2},{2,6},{2,6,10},{2,2},cen="Ar"} },
	["砷"] = { EC={{2},{2,6},{2,6,10},{2,3},cen="Ar"} },
	["硒"] = { EC={{2},{2,6},{2,6,10},{2,4},cen="Ar"} },
	["溴"] = { EC={{2},{2,6},{2,6,10},{2,5},cen="Ar"} },
	["氪"] = { EC={{2},{2,6},{2,6,10},{2,6},cen="Ar"} },
	["銣"] = { EC={{2},{2,6},{2,6,10},{2,6},{1},cen="Kr"} },
	["鍶"] = { EC={{2},{2,6},{2,6,10},{2,6},{2},cen="Kr"} },
	["釔"] = { EC={{2},{2,6},{2,6,10},{2,6,1},{2},cen="Kr"} },
	["鋯"] = { EC={{2},{2,6},{2,6,10},{2,6,2},{2},cen="Kr"} },
	["鈮"] = { EC={{2},{2,6},{2,6,10},{2,6,4},{1},cen="Kr"} },
	["鉬"] = { EC={{2},{2,6},{2,6,10},{2,6,5},{1},cen="Kr"} },
	["鎝"] = { EC={{2},{2,6},{2,6,10},{2,6,5},{2},cen="Kr"} },
	["釕"] = { EC={{2},{2,6},{2,6,10},{2,6,7},{1},cen="Kr"} },
	["銠"] = { EC={{2},{2,6},{2,6,10},{2,6,8},{2},cen="Kr"} },
	["鈀"] = { EC={{2},{2,6},{2,6,10},{2,6,10},cen="Kr"} },
	["銀"] = { EC={{2},{2,6},{2,6,10},{2,6,10},{1},cen="Kr"} },
	["鎘"] = { EC={{2},{2,6},{2,6,10},{2,6,10},{2},cen="Kr"} },
	["銦"] = { EC={{2},{2,6},{2,6,10},{2,6,10},{2,1},cen="Kr"} },
	["錫"] = { EC={{2},{2,6},{2,6,10},{2,6,10},{2,2},cen="Kr"} },
	["銻"] = { EC={{2},{2,6},{2,6,10},{2,6,10},{2,3},cen="Kr"} },
	["碲"] = { EC={{2},{2,6},{2,6,10},{2,6,10},{2,4},cen="Kr"} },
	["碘"] = { EC={{2},{2,6},{2,6,10},{2,6,10},{2,5},cen="Kr"} },
	["氙"] = { EC={{2},{2,6},{2,6,10},{2,6,10},{2,6},cen="Kr"} },
	["銫"] = { EC={{2},{2,6},{2,6,10},{2,6,10},{2,6},{1},cen="Xe"} },
	["鋇"] = { EC={{2},{2,6},{2,6,10},{2,6,10},{2,6},{2},cen="Xe"} },
	["鑭"] = { EC={{2},{2,6},{2,6,10},{2,6,10},{2,6,1},{2},cen="Xe"} },
	["鈰"] = { EC={{2},{2,6},{2,6,10},{2,6,10,1},{2,6,1},{2},cen="Xe"} },
	["鐠"] = { EC={{2},{2,6},{2,6,10},{2,6,10,3},{2,6},{2},cen="Xe"} },
	["釹"] = { EC={{2},{2,6},{2,6,10},{2,6,10,4},{2,6},{2},cen="Xe"} },
	["鉕"] = { EC={{2},{2,6},{2,6,10},{2,6,10,5},{2,6},{2},cen="Xe"} },
	["釤"] = { EC={{2},{2,6},{2,6,10},{2,6,10,6},{2,6},{2},cen="Xe"} },
	["銪"] = { EC={{2},{2,6},{2,6,10},{2,6,10,7},{2,6},{2},cen="Xe"} },
	["釓"] = { EC={{2},{2,6},{2,6,10},{2,6,10,7},{2,6,1},{2},cen="Xe"} },
	["鋱"] = { EC={{2},{2,6},{2,6,10},{2,6,10,9},{2,6},{2},cen="Xe"} },
	["鏑"] = { EC={{2},{2,6},{2,6,10},{2,6,10,10},{2,6},{2},cen="Xe"} },
	["鈥"] = { EC={{2},{2,6},{2,6,10},{2,6,10,11},{2,6},{2},cen="Xe"} },
	["鉺"] = { EC={{2},{2,6},{2,6,10},{2,6,10,12},{2,6},{2},cen="Xe"} },
	["銩"] = { EC={{2},{2,6},{2,6,10},{2,6,10,13},{2,6},{2},cen="Xe"} },
	["鐿"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6},{2},cen="Xe"} },
	["鎦"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,1},{2},cen="Xe"} },
	["鉿"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,2},{2},cen="Xe"} },
	["鉭"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,3},{2},cen="Xe"} },
	["鎢"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,4},{2},cen="Xe"} },
	["錸"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,5},{2},cen="Xe"} },
	["鋨"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,6},{2},cen="Xe"} },
	["銥"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,7},{2},cen="Xe"} },
	["鉑"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,9},{1},cen="Xe"} },
	["金"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10},{1},cen="Xe"} },
	["汞"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10},{2},cen="Xe"} },
	["鉈"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10},{2,1},cen="Xe"} },
	["鉛"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10},{2,2},cen="Xe"} },
	["鉍"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10},{2,3},cen="Xe"} },
	["釙"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10},{2,4},cen="Xe"} },
	["砈"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10},{2,5},cen="Xe"} },
	["氡"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10},{2,6},cen="Xe"} },
	["鍅"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10},{2,6},{1},cen="Rn"} },
	["鐳"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10},{2,6},{2},cen="Rn"} },
	["錒"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10},{2,6,1},{2},cen="Rn"} },
	["釷"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10},{2,6,2},{2},cen="Rn"} },
	["鏷"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,2},{2,6,1},{2},cen="Rn"} },
	["鈾"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,3},{2,6,1},{2},cen="Rn"} },
	["錼"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,4},{2,6,1},{2},cen="Rn"} },
	["鈽"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,6},{2,6},{2},cen="Rn"} },
	["鋂"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,7},{2,6},{2},cen="Rn"} },
	["鋦"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,7},{2,6,1},{2},cen="Rn"} },
	["鉳"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,9},{2,6},{2},cen="Rn"} },
	["鉲"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,10},{2,6},{2},cen="Rn"} },
	["鑀"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,11},{2,6},{2},cen="Rn"} },
	["鐨"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,12},{2,6},{2},cen="Rn"} },
	["鍆"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,13},{2,6},{2},cen="Rn"} },
	["鍩"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14},{2,6},{2},cen="Rn"} },
	["鐒"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14},{2,6},{2,1},cen="Rn"} },
	["鑪"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14},{2,6,2},{2},cen="Rn"} },
	["𨧀"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14},{2,6,3},{2},cen="Rn"} },
	["𨭎"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14},{2,6,4},{2},cen="Rn"} },
	["𨨏"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14},{2,6,5},{2},cen="Rn"} },
	["𨭆"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14},{2,6,6},{2},cen="Rn"} },
	["䥑"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14},{2,6.7},{2},cen="Rn"} },
	["鐽"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14},{2,6,8},{2},cen="Rn"} },
	["錀"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14},{2,6,9},{2},cen="Rn"} },
	["鎶"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14},{2,6,10},{2},cen="Rn"} },
	["鉨"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14},{2,6,10},{2,1},cen="Rn"} },
	["鈇"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14},{2,6,10},{2,2},cen="Rn"} },
	["鏌"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14},{2,6,10},{2,3},cen="Rn"} },
	["鉝"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14},{2,6,10},{2,4},cen="Rn"} },
	["鿬"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14},{2,6,10},{2,5},cen="Rn"} },
	["鿫"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14},{2,6,10},{2,6},cen="Rn"} },
	["Uue"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14},{2,6,10},{2,6},cen="Og"} },
	["Ubn"] = {  },
	["Ubu"] = {  },
	["Ubb"] = {  },
	["Ubt"] = {  },
	["Ubq"] = {  },
	["Ubp"] = {  },
	["Ubh"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14,2},{2,6,10,2},{2,6,1},{2,1},cen="Og"} },
	["Ubs"] = {  },
	["Ubo"] = {  },
	["Ube"] = {  },
	["Uts"] = {  },
	["Usb"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14,18},{2,6,10,14},{2,6,10},{2,{{2,'1/2'},{4,'2/3'}}},{2,{{2,'1/2'}}},cen="Og"} },
	["Ust"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14,18},{2,6,10,14,1},{2,6,10},{2,{{2,'1/2'},{4,'2/3'}}},{2,{{2,'1/2'}}},cen="Usb"}  },
	["Uoq"] = { EC={{2},{2,6},{2,6,10},{2,6,10,14},{2,6,10,14,18},{2,6,10,14,5},{2,6,10,4},{2,{{2,'1/2'},{4,'2/3'}},3},{2,{{2,'1/2'}}},cen="Usb"}  },
	["電子偶素"] = {  },
	["緲子偶素"] = {  },
}

local eleconfdata = {'s','p','d','f','g','h','i','k','l'}
local element_main_data = mw.loadData("Module:Element/data")
local element_lib = require("Module:Element")
local TlParLib = require("Module:TemplateParameters")
local DelcatLib = require("Module:Delcat")
function p.newInclude(frame)
    local args, working_frame
    if frame == mw.getCurrentFrame() then
        -- We're being called via #invoke. The args are passed through to the module
        -- from the template page, so use the args that were passed into the template.
        args = frame.args
        working_frame = frame
    else
        -- We're being called from another module or from the debug console, so assume
        -- the args are passed in directly.
        args = frame
        working_frame = mw.getCurrentFrame()
        if type(args) ~= type({}) then args = {frame} end
    end
    local keep_title
    local pagename
    for arg_name, arg_value in pairs( args ) do
		if arg_name == 1 or arg_name == '1' then
			pagename = arg_value
		elseif arg_name == "keep" or arg_name == "keep_title" or arg_name == "keep title" then
			keep_title = mw.ustring.lower(arg_value)
		end
	end
    
    local show_t = true
	if keep_title ~= nil then
		if yesno == nil then yesno = require('Module:Yesno') end
		if keep_title == "hide" then show_t = false end
		keep_t = yesno(keep_title)
	else
		keep_t = false
	end

    local chaptername = ''
    local mark_pos,_  = mw.ustring.find(pagename, '%#')
    if mark_pos then 
    	chaptername = mw.ustring.sub(pagename,mark_pos+1,#pagename) 
    	pagename = mw.ustring.sub(pagename,1,mark_pos-1) 
    end
    local chapterfullname = tostring(chaptername)
    local chapterid = 1
    mark_pos = mw.ustring.find(chapterfullname, "%_%d+$")
    if mark_pos then 
    	chaptername = mw.ustring.sub(chapterfullname,1,mark_pos-1) 
    	chapterid = tonumber(mw.ustring.sub(chapterfullname,mark_pos+1,#chapterfullname)) or 1
    end
    local body = ''
    local input_str = working_frame:preprocess( "{{msgnw:" .. pagename .. "}}" ) --析出頁面原碼
    input_str = '\n\n' .. mw.text.decode(input_str) .. '\n\n'
    
    	local htagstrip_table = {}
		local htagstrip_matcher = "\127\'\"`UNIQ%-%-h%-.-QINU`\"\'\127%s-[^\n]-%s-=+%s-\n"
		local htagstrip_start, htagstrip_end = mw.ustring.find(input_str, htagstrip_matcher, 1)
		
		while htagstrip_start do
			local temp_htagstrip = mw.ustring.sub(input_str, htagstrip_start, htagstrip_end)
			local htagstrip_str = mw.ustring.match(temp_htagstrip, "\127\'\"`UNIQ%-%-h%-.-QINU`\"\'\127")
			local htag_tail = mw.ustring.gsub(temp_htagstrip, "\127\'\"`UNIQ%-%-h%-.-QINU`\"\'\127", "")
			local begin_, end_ = mw.ustring.find(htag_tail, "=+", 1)
			local htag_name = mw.text.trim(mw.ustring.gsub(htag_tail, '=', ''))
		    htagstrip_table[#htagstrip_table+1] = {
		    	name=mw.text.trim(htag_name),
		    	level=end_ - begin_ + 1,
		    	htagstrip=htagstrip_str
		    }
			htagstrip_start, htagstrip_end = mw.ustring.find(input_str, htagstrip_matcher, htagstrip_end+1)
		end
		mw.logObject(htagstrip_table)

    input_str =  mw.text.killMarkers( input_str ) --去除擴展標籤
    
    input_str = '\n\n' .. input_str .. '\n\n'
    local chapterfullname_regex_pattern = TlParLib._getEscapeString(chapterfullname)
    local chaptername_regex_pattern = TlParLib._getEscapeString(chaptername)
	local is_htag = false
    local function htag_regex(chname) return "\n=+%s-" .. chname .. "%s-=+%s-\n" end
    local function spantag_regex(chname) return "%<%s-span[^%>]+id=[%\"%\']" .. chname .. "[%\"%\']" end
    local function anchortag_regex(chname) return "%{%{[Aa][Nn][Cc][Hh][Oo][Rr][^%}]-%|%s-" .. chname .. "%s-[%|%}]" end
    local function find_chtag(chname, alltext)
    	is_htag = true
    	local finded_title_begin, finded_title_end = mw.ustring.find(input_str, htag_regex(chname), 1)
    	if finded_title_begin then return finded_title_begin, finded_title_end end
    	is_htag = false
    	finded_title_begin, finded_title_end = mw.ustring.find(input_str, spantag_regex(chname), 1)
    	if finded_title_begin then return finded_title_begin, finded_title_end end
    	finded_title_begin, finded_title_end = mw.ustring.find(input_str, anchortag_regex(chname), 1)
    	if finded_title_begin then return finded_title_begin, finded_title_end end
    end

    local finded_title_begin, finded_title_end = find_chtag(chapterfullname_regex_pattern, input_str)
    local next_title_begin, next_title_end = #input_str, nil; next_title_end = next_title_begin
    if finded_title_begin then --匹配全名
    else --從非全名尋找
    	finded_title_begin, finded_title_end =find_chtag(chaptername_regex_pattern, input_str)
    end
    
    local finded_title_string = mw.ustring.sub(input_str, finded_title_begin, finded_title_end)
	if chapterfullname == "__FIRST_SECTION__" then finded_title_begin = -1 end
    local htag_level
    if finded_title_begin then --找到了
    	if title == "__FIRST_SECTION__" then
			finded_title_string = ''
			htag_level = 9007199254740991 --lua max int
			finded_title_end = 1
		else
		    if is_htag == false then --分析章節標題
		    	local re_find = mw.ustring.sub(input_str, 1, finded_title_begin)
		    	re_find = re_find:reverse()
		    	local temp_title_begin, temp_title_end = mw.ustring.find(re_find, htag_regex("[^\n]-"), 1)
		    	if temp_title_begin then finded_title_string = mw.ustring.sub(re_find, temp_title_begin, temp_title_end) end
		    	finded_title_string = finded_title_string:reverse()
		    end
		    --獲得章節標題的級數
			local begin_, end_ = mw.ustring.find(finded_title_string, "=+", 1)
			htag_level = end_ - begin_ + 1
		end
		local next_title_matcher = htag_regex("[^\n]-")
		local next_title_find_begin, next_title_find_end = mw.ustring.find(input_str, next_title_matcher, finded_title_end + 1)
		local flag = true while next_title_find_begin and flag do
			local next_title_find = mw.ustring.sub(input_str, next_title_find_begin, next_title_find_end)
			local find_begin_, find_end_ = mw.ustring.find(next_title_find, "=+", 1)
			local find_count = find_end_ - find_begin_ + 1
			if find_count <= htag_level then 
				next_title_begin = next_title_find_begin
				next_title_end = next_title_find_end
				flag = nil
			end
			next_title_find_begin, next_title_find_end = mw.ustring.find(input_str, next_title_matcher, next_title_find_end + 1)
		end
		if next_title_begin == nil then next_title_begin = 0 end
		
		local ch_start = finded_title_end + 1
		if is_htag == false then ch_start = finded_title_begin end
		body = mw.ustring.sub(input_str, ch_start, next_title_begin - 1)
		
		local i = 1 j = 1 while mw.ustring.find(body, "\n=+ *[^\n]* *=+ *\n") and j do if i>=10 then j = nil end
			body = mw.ustring.gsub(body, "\n=+ *[^\n]* *=+ *\n", DelcatLib.deltitle)
			i = i + 1
		end

		if show_t then if keep_title then body = finded_title_string .. body else body = DelcatLib.deltitle(finded_title_string) .. body end end
		
		body = working_frame:preprocess( body )
		
		local back_title_start, back_title_end = mw.ustring.find(body, next_title_matcher, 1)
		while back_title_start do
			local check_title=mw.ustring.sub(body, back_title_start, back_title_end)
			check_title=mw.text.trim(mw.ustring.gsub(check_title, '=', ''))
			check_title=mw.text.trim(check_title)
			check_title=mw.text.killMarkers(check_title)
			local check_title_matcher=TlParLib._getEscapeString(check_title)
			
			local htagstrip_table_item
			for ik, iv in ipairs(htagstrip_table) do
				if iv.name == check_title_matcher then
					htagstrip_table_item = iv
					break
				end
			end
			
			mw.log(mw.ustring.gsub(body, "(=+)(.-)(" .. check_title_matcher .. "%s-=+)", "%1" .. htagstrip_table_item.htagstrip .. "%3"))
			back_title_start, back_title_end = mw.ustring.find(body, next_title_matcher, back_title_end+1)
		end
		
    end


    
    return body
end

function p.dataTest(frame)
    local args

    if frame == mw.getCurrentFrame() then
        -- We're being called via #invoke. The args are passed through to the module
        -- from the template page, so use the args that were passed into the template.
        args = frame.args

    else
        -- We're being called from another module or from the debug console, so assume
        -- the args are passed in directly.
        args = frame
        if type(args) ~= type({}) then args = {frame} end
        
    end
    local css = args.css or ""
    local tag = args.tag or "ref"
    local deltemplate = args.deltemplate or "noteTA"
    local match_str = "<%s*" .. tag .. ".-" .. css ..".-<%s*%/" .. tag .. "%s*>"
	local str = args[1] or args['1']
	local working_frame=mw.getCurrentFrame()

    if args["delnowiki"] then
    	if type(yesno) ~= type(tonumber) then yesno = require('Module:Yesno') end
    	if yesno(args["delnowiki"] or 'no') then local delnowiki=require('Module:Delcat').delnowiki --備用
			str = mw.text.unstripNoWiki( str )
		end
	end

	str = mw.ustring.gsub(str,"([^%{]%{%{)([^%#%|%{%}]+)","%1msgnw:%2")
	if deltemplate ~= '' then str = mw.ustring.gsub(str,"(%{%{)(" .. deltemplate .. ")","%1void%2") end
	
	str = working_frame:preprocess( str ) --析出頁面原碼
    str =  mw.text.killMarkers( mw.text.decode(str) ) --去除擴展標籤
	
	
	
	local head, tail = mw.ustring.find(str, match_str)
	
	local i = 0
	
	while head do
		local check_head, check_tail = head, tail
		while check_head do
			head, tail = check_head, check_tail
			check_head, check_tail = mw.ustring.find(str, match_str, check_head+1)
			--mw.log(check_head)
		end
		str = mw.ustring.sub(str, 1, head-1) .. mw.ustring.sub(str, tail+1, #str)
		--mw.log(str)
		i=i+1
		if i> 100 then break end
		head, tail = mw.ustring.find(str, match_str)
	end
	--mw.log(str)
	return str
end

function p.ElectronConfiguration(frame)
	-- For calling from #invoke.
    local args
    if frame == mw.getCurrentFrame() then
        -- We're being called via #invoke. The args are passed through to the module
        -- from the template page, so use the args that were passed into the template.
        if lib_arg.getArgs == nil then lib_arg = require('Module:Arguments') end
        args = lib_arg.getArgs(frame) --frame.args
    else
        -- We're being called from another module or from the debug console, so assume
        -- the args are passed in directly.
        if type(frame) ~= type({}) then args = {frame}
        else args = frame end
    end
	return p._ElectronConfiguration(args)
end

local yesno = nil

function p._ElectronConfiguration(args)
	--去除模板引用時可能產生的空格
	eleString='' if (args[1] and args[1] ~= '') then eleString = string.gsub(args[1] , "%s$", "") else return '' end
	eleid = element_lib.getListID(eleString)
	ele1 = p.copytable(element_main_data[eleid])
	if (eleid==-1) then
		return ''
	end
	if (ele1.correct and ele1.correct  ~= '') then
		return ''
	end
	local display_all = false
	if args["displayAll"] then
    	if type(yesno) ~= type(tonumber) then yesno = require('Module:Yesno') end
		display_all = yesno(args["displayAll"] or 'no')
	end
	if (ele1.Z and ele1.Z ~= '') then
		local extEledata = p.copytable(eleconflists[ele1.name])
		for k,v in pairs(extEledata) do
			ele1[k] = v
		end
		return p.testeleconf(ele1.EC, display_all)
	end
	return ''
end

function p.copytable(input_table)
	local output_table
	if type(input_table) == type({}) then
		output_table = {}
		for k,v in pairs(input_table) do
			local temp
			if type(input_table) == type({}) then
				temp = mw.clone(p.copytable(v))
			elseif type(input_table) == type(tonumber) then
			else
				temp = mw.copy(v)
			end
			output_table[k]=temp
		end
	elseif type(input_table) == type(tonumber) then
		--do nothing
	else
		output_table = mw.clone(input_table)
	end
	return output_table
end
function p.testeleconf(eleconf, showall)
	local cen = eleconf.cen or ''
	local ceneledata
	if cen ~= '' then
		for i=2,140 do
			if mw.ustring.lower(element_main_data[i].Symbol) == mw.ustring.lower(cen) then
				ceneledata = p.copytable(element_main_data[i])
				break
			end
		end
	end
	if not ceneledata then ceneledata = p.copytable(element_main_data[2]) end
	local extEledata = eleconflists[ceneledata.name]
	for k,v in pairs(extEledata) do
		ceneledata[k] = v
	end
	local elecdis = ''

	for period, eles in ipairs(eleconf) do
		local elecstr = ''
		for shell, elecount in ipairs(eles) do
			if type(elecount) == type({}) then--亞軌域
				for shell_id, shell_ent in ipairs(elecount) do
					local shellstr = ''
					local shell_name = shell_ent[2]
					local shell_elecount = shell_ent[1]
					local valence = shell_elecount
					local censhell_ent = ((ceneledata.EC[period] or {})[shell] or {{0,''}})[shell_id]
					--尋找同名亞軌域
					local shell_ent_check = (ceneledata.EC[period] or {})[shell]
					if type(shell_ent_check) == type({}) then
						for subshell_id, subshell_ent in ipairs(shell_ent_check) do
							if subshell_ent[2] == shell_name then censhell_ent = {subshell_ent[1],subshell_ent[2]} break end
						end
					else
						censhell_ent = {shell_ent_check,''}
					end
					if not(showall == true) then 
						valence = valence - ((censhell_ent or {})[1] or 0)
					end
					if valence > 0 then
						local frame = mw.getCurrentFrame()
						
						--{{su|p=2|b=1/2}}
						shellstr = tostring(period) .. eleconfdata[shell] .. frame:expandTemplate{ title = 'su', args = { p=tostring(valence), b=tostring(shell_name) } }
						elecstr = elecstr .. shellstr
					end
				end
			else
				local shellstr = ''
				local valence = elecount
				if not(showall == true) then 
					local subshell_name = ''
					local shell_ent = (ceneledata.EC[period] or {})[shell]
					if type(shell_ent) == type({}) then--亞軌域
						for subshell_id, subshell_ent in ipairs(shell_ent) do
							if subshell_ent[2] == subshell_name then shell_ent = subshell_ent[1] break end
						end
					end
					valence = valence - (shell_ent or 0) 
				end
				if valence > 0 then
					shellstr = tostring(period) .. eleconfdata[shell] .. '<sup>' .. tostring(valence) .. '</sup>'
					elecstr = elecstr .. shellstr
				end
			end
		end
		elecdis = elecdis .. elecstr
	end
	if cen ~= '' and not(showall == true) then
		elecdis = '[' .. cen .. ']' .. elecdis
	end
	return elecdis
end

function p.test1(frame)
	-- For calling from #invoke.
    local args
    if frame == mw.getCurrentFrame() then
        -- We're being called via #invoke. The args are passed through to the module
        -- from the template page, so use the args that were passed into the template.
        args = frame.args
    else
        -- We're being called from another module or from the debug console, so assume
        -- the args are passed in directly.
        args = frame
        if type(args) ~= type({}) then args = {frame} end
    end
    local text = args['1'] or args[1] or '{{{2}}}{{{3}}}'
    local working_frame = frame:newChild{ title = frame:getTitle(), args = {['2']="你好",['3']="喵"} }
    local body = working_frame:preprocess( text )
    working_frame.args['2'] = "早安"
    working_frame.args['3'] = "汪"
    body = body .. working_frame:preprocess( text )
	return body
end

p.createExp=function(val)
	local num = {text=''..val}
	setmetatable(num,{
		__add = function (op1, op2) 
			return p.createExp('('..tostring(op1)..').add('..tostring(op2)..')')
		end,
		__sub = function (op1, op2) 
			return p.createExp('('..tostring(op1)..').sub('..tostring(op2)..')')
		end,
		__mul = function (op1, op2) 
			return p.createExp('('..tostring(op1)..').mul('..tostring(op2)..')')
		end,
		__div = function (op1, op2) 
			return p.createExp('('..tostring(op1)..').div('..tostring(op2)..')')
		end,
		__mod = function (op1, op2) 
			return p.createExp('('..tostring(op1)..').mod('..tostring(op2)..')')
		end,
		__tostring = function (this) 
			return this.text
		end,
		__unm = function (this)
			return p.createExp(tostring(this)..'.neg()')
		end,
		__eq = function (op1, op2)
			return tostring(op1)==tostring(op2)
		end,
	})
	return num
end

return p