匿名
未登录
中文(中国大陆)
登录
「荏苒之境」
搜索
查看“︁模块:Dictionary-Vocabulary.lua”︁的源代码
来自「荏苒之境」
命名空间
模块
讨论
更多
更多
页面操作
阅读
查看源代码
历史
清除缓存
←
模块:Dictionary-Vocabulary.lua
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local csv = require("Module:Csv.lua") local dict_utils = require("Module:Dictionary-Utils.lua") local dict_views = require("Module:Dictionary-Views.lua") local html = mw.html local cargo = mw.ext.cargo local DICT_TABLE = dict_views.TABLE local vocabulary = {} local function format_conflict(prev_value, curr_value) return (prev_value or "").."<br/><i style=\"color: grey\">"..(curr_value or "").."</i>" end local function store_row(language, priority, row, extra_count) local r = cargo.query(DICT_TABLE, "Spelling,Definition,Extra", { where = string.format( [[Language="%s" AND Spelling="%s" AND Priority>=%d]], language, row[1], tonumber(priority)) })[1] if r and r.Priority > priority then local conflicting local prev_row = dict_utils.expand_row(r, extra_count) for i = 1, extra_count and extra_count + 2 or math.max(#row, #prev_row) do if prev_row[i] ~= row[i] then prev_row[i] = format_conflict(prev_row[i], row[i]) conflicting = true end end return conflicting and prev_row or nil end local extra = {} for i = 1, extra_count do extra[i] = row[i+2] end cargo.store(DICT_TABLE, { Language = language, Spelling = row.Spelling, Definition = row.Definition, Extra = csv.format_row(extra), Priority = priority }) end vocabulary.show = function(frame) local args = frame.args local language = args.language local format = args.format local priority = args.priority local content = args.content local rows if format == "csv" then rows = csv.parse(content, true) else mw.addWarning("无效的词典格式:"..tostring(format)) return end local headers = rows.headers local extra_count = #headers - 2 local conflicting_headers = store_row(language, -math.huge, headers) if conflicting_headers then return html.create("pre") :css("color", "red") :tag("p") :wikitext("检测到该词汇表的标题行(灰色文本)与之前储存的标题行冲突,请修复:") :done() :node(dict_views.vocabulary { conflicting_headers }) end local conflicting_rows = {} for i = 2, #rows do local conflicting_row = store_row(language, priority, rows[i], extra_count) if conflicting_row then conflicting_rows[i-1] = conflicting_row end end local view = html.create("div") if #conflicting_rows ~= 0 then view:tag("pre") :css("color", "red") :tag("p") :wikitext("检测到旧词汇与新词汇(灰色文本)内容冲突的情况,且二者具有相同优先级,请统一词汇信息:") :done() :node(dict_views.vocabulary(conflicting_rows)) end if frame.args.show_view == "true" then view:node(dict_views.vocabulary(rows)) end return view end return vocabulary
该页面使用的模板:
模块:Dictionary-Vocabulary.lua/doc
(
查看源代码
)
返回
模块:Dictionary-Vocabulary.lua
。
导航
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
wiki工具
wiki工具
Cargo数据
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志