FANDOM


(Another attempt at this)
Line 2: Line 2:
   
 
function p.replace(frame)
 
function p.replace(frame)
-- Simple find-and-replace so that there's less of a need for instances of nearly identical text.
+
-- Simple find-and-replace so that there's less of a need for instances of
  +
-- nearly identical text.
 
-- Usage: {{#invoke:replace|replace|text|pattern to remove|pattern to insert}}
 
-- Usage: {{#invoke:replace|replace|text|pattern to remove|pattern to insert}}
 
text = frame.args[1]
 
text = frame.args[1]
Line 10: Line 10:
   
 
function p.convertEvidence(frame)
 
function p.convertEvidence(frame)
-- Replaces instances of dots with line breaks. Meant to be used on Template:CaseData.
+
-- Replaces instances of dots with line breaks. Meant to be used on
newFrame = frame:getParent()
+
-- Template:CaseData.
newFrame.args[2] = "·"
+
parent = frame:getParent()
newFrame.args[3] = "<br>"
+
text = parent.args[1]
  +
new_text, _ = string.gsub(text, "&middot;", "<br>")
 
return p.replace(newFrame)
 
return p.replace(newFrame)
 
end
 
end

Revision as of 04:13, February 2, 2020

local p = {}
 
function p.replace(frame)
    -- Simple find-and-replace so that there's less of a need for instances of
    -- nearly identical text.
    -- Usage: {{#invoke:replace|replace|text|pattern to remove|pattern to insert}}
    text = frame.args[1]
    new_text, _ = string.gsub(text, frame.args[2], frame.args[3])
    return new_text
end
 
function p.convertEvidence(frame)
    -- Replaces instances of dots with line breaks. Meant to be used on
    -- Template:CaseData.
    parent = frame:getParent()
    text = parent.args[1]
    new_text, _ = string.gsub(text, "&middot;", "<br>")
    return p.replace(newFrame)
end
 
return p
 
--[[Category:Modules]]
Community content is available under CC-BY-SA unless otherwise noted.