בדוקי עריכות אוטומטית, אינטערפעיס רעדאקטארן, אינטערפעיס אדמיניסטראַטאָרן, סיסאפן, מייבאים, מעדכנים, מייבא, אספקלריה רעדאקטארן
46,362
רעדאגירונגען
ק (1 רעוויזיע אימפארטירט: אימפארטירט פון די ענגלישע וויקיפעדיע, זע ביישטייערער ליסטע) |
(אפדעיט פון ענוויקי) |
||
| שורה 98: | שורה 98: | ||
--[[--------------------------< H Y P H E N _ T O _ D A S H >-------------------------------------------------- | --[[--------------------------< H Y P H E N _ T O _ D A S H >-------------------------------------------------- | ||
Converts a hyphen to | Converts a hyphen, endash, emdash to endash under certain conditions. The hyphen/en/em must separate | ||
like items; unlike items are returned unmodified. These forms are modified: | like items; unlike items are returned unmodified. These forms are modified: | ||
letter - letter (A - B) | letter - letter (A-B) | ||
digit - digit (4-5) | digit - digit (4-5) | ||
digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5) | digit separator digit - digit separator digit (4.1-4.5 or 4-1-4-5) | ||
letterdigit - letterdigit (A1-A5) (an optional separator between letter and | letterdigit - letterdigit (A1-A5) (an optional separator between letter and | ||
digit is supported – a.1-a.5 or a-1-a-5) | digit is supported – a.1-a.5 or a-1-a-5) | ||
digitletter - digitletter (5a - 5d) (an optional separator between letter and | digitletter - digitletter (5a-5d) (an optional separator between letter and | ||
digit is supported – 5.a-5.d or 5-a-5-d) | digit is supported – 5.a-5.d or 5-a-5-d) | ||
any other forms are returned unmodified. | any other forms are returned unmodified. | ||
str may be a comma- or semicolon-separated list | str may be a comma- or semicolon-separated list of page ranges with/without single pages | ||
]] | ]] | ||
| שורה 118: | שורה 118: | ||
return str; | return str; | ||
end | end | ||
str = str:gsub ("(%(%(.-%)%))", function(m) return m:gsub(",", ","):gsub(";", ";") end) -- replace commas and semicolons in accept-as-written markup with similar unicode characters so they'll be ignored during the split | str = str:gsub ("(%(%(.-%)%))", function(m) return m:gsub(",", ","):gsub(";", ";") end) -- replace commas and semicolons in accept-as-written markup with similar unicode characters so they'll be ignored during the split | ||
str = str:gsub ('&[nm]dash;', {['–'] = '–', ['—'] = '—'}); -- replace — and – entities with their characters; semicolon mucks up the text.split | str = str:gsub ('&[nm]dash;', {['–'] = '–', ['—'] = '—'}); -- replace — and – entities with their characters; semicolon mucks up the text.split | ||
str = str:gsub ('-', '-'); -- replace HTML numeric entity with hyphen character | str = str:gsub ('-', '-'); -- replace HTML numeric entity with hyphen character | ||
str = str:gsub (' ', ' '); -- replace entity with generic keyboard space character | str = str:gsub (' ', ' '); -- replace entity with generic keyboard space character | ||
local out = {}; | local out = {}; | ||
local list = mw.text.split (str, '%s*[,;]%s*'); -- split str at comma or semicolon separators if there are any | local list = mw.text.split (str, '%s*[,;]%s*'); -- split str at comma or semicolon separators if there are any | ||
local accept; -- boolean | |||
for _, item in ipairs (list) do -- for each item in the list | for _, item in ipairs (list) do -- for each item in the list | ||
item, accept = has_accept_as_written (item); -- remove accept-this-as-written markup when it wraps all of item | item, accept = has_accept_as_written (item); -- remove accept-this-as-written markup when it wraps all of item | ||
if not accept and mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[ | if not accept and mw.ustring.match (item, '^%w*[%.%-]?%w+%s*[—–-]%s*%w*[%.%-]?%w+$') then -- if a hyphenated range or has endash or emdash separators | ||
if | if mw.ustring.match (item, '^%a+[%.%-]?%d+%s*[—–-]%s*%a+[%.%-]?%d+$') or -- letterdigit hyphen letterdigit (optional separator between letter and digit) | ||
mw.ustring.match (item, '^%d+[%.%-]?%a+%s*[—–-]%s*%d+[%.%-]?%a+$') or -- digitletter hyphen digitletter (optional separator between digit and letter) | |||
mw.ustring.match (item, '^%d+[%.%-]%d+%s*[—–-]%s*%d+[%.%-]%d+$') then -- digit separator digit hyphen digit separator digit | |||
item = mw.ustring.gsub (item, '(%w*[%.%-]?%w+)%s*[—–-]%s*(%w*[%.%-]?%w+)', '<span class="nowrap">%1 –</span> <span class="nowrap">%2</span>'); -- replace hyphen/dash, with spaced endash | |||
item = | elseif mw.ustring.match (item, '^%d+%s*[—–-]%s*%d+$') or -- digit hyphen digit | ||
mw.ustring.match (item, '^%a+%s*[—–-]%s*%a+$') then -- letter hyphen letter | |||
item = mw.ustring.gsub (item, '(%w+)%s*[—–-]%s*(%w+)', '<span class="nowrap">%1–</span>%2'); -- replace hyphen/emdash with endash, remove extraneous space characters | |||
else | else | ||
-- item = mw.ustring.gsub (item, '%s*[—–-]%s*', '–'); -- disabled; here when 'unlike' items so return <item> as is | |||
end | end | ||
end | end | ||
| שורה 330: | שורה 333: | ||
local function add_prop_cat (key, arguments, key_modifier) | local function add_prop_cat (key, arguments, key_modifier) | ||
local key_modified = key .. ((key_modifier and key_modifier) or ''); -- modify <key> with <key_modifier> if present and not nil | local key_modified = key .. ((key_modifier and key_modifier) or ''); -- modify <key> with <key_modifier> if present and not nil | ||
רעדאגירונגען