Module:Citation/CS1/COinS: Difference between revisions

no edit summary
m>Trappist the monk
No edit summary
m>Trappist the monk
No edit summary
Line 110: Line 110:
This function gets the rendered form of an equation according to the editor's preference.  It then searches the
This function gets the rendered form of an equation according to the editor's preference.  It then searches the
rendering for the text equivalent of the rendered equation and replaces the rendering with that.
rendering for the text equivalent of the rendered equation and replaces the rendering with that.
When a replacement is made, this function returns true and the value with replacement


]=]
]=]
Line 119: Line 121:
if not rendering then -- when value doesn't have a math stripmarker, abandon this test
if not rendering then -- when value doesn't have a math stripmarker, abandon this test
-- return 'not rendering';
-- return 'not rendering';
return value;
return false, value;
end
end
Line 131: Line 133:
rendering = rendering:match ('<annotation[^>]+>(.+)</annotation>') -- extract just the math text
rendering = rendering:match ('<annotation[^>]+>(.+)</annotation>') -- extract just the math text
else
else
return value; -- had math stripmarker but not one of the three defined forms
return false, value; -- had math stripmarker but not one of the three defined forms
end
end
return value:gsub (stripmarker, rendering, 1);
return true, value:gsub (stripmarker, rendering, 1);
end
end


Line 149: Line 151:


local function coins_cleanup (value)
local function coins_cleanup (value)
value = coins_replace_math_stripmarker (value); -- replace math stripmarker with text representation of the equation
local replaced = true; -- default state to get the do loop running
while replaced do
replaced, value = coins_replace_math_stripmarker (value); -- replace math stripmarker with text representation of the equation
end
 
value = value:gsub ('\127UNIQ%-%-math%-[%a%d]+%-QINU\127', "MATH RENDER ERROR"); --  
value = value:gsub ('\127UNIQ%-%-math%-[%a%d]+%-QINU\127', "MATH RENDER ERROR"); --  
 
value = mw.text.unstripNoWiki (value); -- replace nowiki stripmarkers with their content
value = mw.text.unstripNoWiki (value); -- replace nowiki stripmarkers with their content
value = value:gsub ('<span class="nowrap" style="padding%-left:0%.1em;">&#39;s</span>', "'s"); -- replace {{'s}} template with simple apostrophe-s
value = value:gsub ('<span class="nowrap" style="padding%-left:0%.1em;">&#39;s</span>', "'s"); -- replace {{'s}} template with simple apostrophe-s
Anonymous user