Module:Citation/CS1: திருத்தங்களுக்கு இடையிலான வேறுபாடு
உள்ளடக்கம் நீக்கப்பட்டது உள்ளடக்கம் சேர்க்கப்பட்டது
Disable strip_apostrophe_markup() and make_coins_title(); causing script errors; |
Synch from sandbox; script error fix in strip_apostrophe_markup(); |
||
வரிசை 696:
end
--[[--------------------------< E S C A P E _ L U A _ M A G I C _ C H A R S >----------------------------------
Returns a string where all of lua's magic characters have been escaped. This is important because functions like
string.gsub() treat their pattern and replace strings as patterns, not literal strings.
]]
function escape_lua_magic_chars (argument)
argument = argument:gsub("([%^%$%(%)%.%[%]%*%+%-%?])", "%%%1"); -- replace all other lua magic pattern characters
return argument;
end
--[[--------------------------< S T R I P _ A P O S T R O P H E _ M A R K U P >--------------------------------
Strip wiki italic and bold markup from argument so that it doesn't contaminate COinS metadata
This function strips common patterns of apostrophe markup. We presume that editors who have taken the time to
வரி 703 ⟶ 714:
]]
function strip_apostrophe_markup (argument)
local pattern,
if not is_set (argument) then return argument; end
while true do -- look for and remove all 5-apostrophe (bold and italic) markup
if argument:match ("%'%'%'%'%'") then
if argument:match ("%'%'%'%'%'.*%'%'%'%'%'") then
pattern,
elseif argument:match ("%'%'%'%'%'.*%'%'%'.*%'%'") then -- bold italic followed by italic (5, 3, 2)
pattern,
elseif argument:match ("%'%'%'%'%'.*%'%'.*%'%'%'") then -- bold italic followed by bold (5, 2, 3)
pattern,
elseif argument:match ("%'%'%'.*%'%'.*%'%'%'%'%'") then -- bold italic followed by italic (3, 2, 5)
pattern,
elseif argument:match ("%'%'.*%'%'%'.*%'%'%'%'%'") then -- italic followed by bold (2, 3, 5)
pattern,
end
cap2 = escape_lua_magic_chars (cap2); -- replace lua magic characters
▲ argument=argument:gsub(pattern, c1..c2); -- remove the markup
pattern = escape_lua_magic_chars (pattern); -- replace lua magic characters
argument=argument:gsub(pattern, cap..cap2); -- remove the markup
else
break; -- none or no more 5-apostrophe matches
வரி 728 ⟶ 741:
while true do -- look for and remove all 3-apostrophe (bold) markup
if argument:match ("%'%'%'.*%'%'%'") then -- is there an instance of bold?
pattern,
argument=argument:gsub(pattern, cap); -- remove the markup
else
break; -- none or no more 3 matches
வரி 737 ⟶ 751:
while true do -- look for and remove all 2-apostrophe (italic) markup
if argument:match ("%'%'.*%'%'") then -- is there an instance of italic?
pattern,
argument=argument:gsub(pattern, cap); -- remove the markup
else
break; -- none or no more 2 matches
வரி 773 ⟶ 788:
end
--[[--------------------------< G E T _ C O I N S _ P A G E S >------------------------------------------------
-- Extract page numbers from external wikilinks in any of the |page=, |pages=, or |at= parameters for use in COinS.▼
▲
]]
function get_coins_pages (pages)
local pattern;
if not is_set (pages) then return pages; end -- if no page numbers then we're done
while true do
pattern = pages:match("%[(%w*:?//[^ ]+%s+)[%w%d].*%]"); -- pattern is the opening bracket, the url and following space(s): "[url "
if nil == pattern then break; end -- no more urls
pattern = escape_lua_magic_chars (pattern
pages = pages:gsub(pattern, ""); -- remove as many instances of pattern as possible
end
pages = pages:gsub("[%[%]]", ""); -- remove the brackets
pages = pages:gsub("–", "-" ); -- replace endashes with hyphens
pages = pages:gsub("&%w+;", "-" ); -- and replace html entities (– etc.) with hyphens; do we need to replace numerical entities like   and the like?
வரி 1,720 ⟶ 1,739:
local OCinSoutput = COinS{
['Periodical'] = Periodical,
['Chapter'] =
['Title'] =
['PublicationPlace'] = PublicationPlace,
['Date'] = first_set(COinS_date, Date), -- COinS_date has correctly formatted date if Date is valid; any reason to keep Date here? Should we be including invalid dates in metadata?
வரி 1,727 ⟶ 1,746:
['Volume'] = Volume,
['Issue'] = Issue,
['Pages'] = get_coins_pages (first_set(Page, Pages, At)), -- pages stripped of external links
['Edition'] = Edition,
['PublisherName'] = PublisherName,
வரி 1,932 ⟶ 1,951:
Title = script_concatenate (Title, ScriptTitle); -- <bdi> tags, lang atribute, categorization, etc; must be done after title is wrapped
TransTitle = wrap( 'trans-quoted-title', TransTitle );
-- Chapter = ''; -- chapter not allowed - disabled because doing this here doesn't display error msg and promoted url is lost
else
Title = wrap( 'italic-title', Title );
வரி 1,959 ⟶ 1,978:
end
end
if is_set(Place) then
Place = " " .. wrap( 'written', Place, use_lowercase ) .. sepc .. " ";
| |||