FANDOM


--<pre>
--| Creates a simple transcript or dialogue 
--| Ref https://www.w3.org/TR/html5/common-idioms.html#conversations
-- Syntax : 
--  {{#invoke:transcript|main|John|I'm rich|Mary|Me too}}
--  {{#invoke:transcript|main|John:I'm rich|Mary:Me too|#separator=:}}
local p = {}
local strfind = string.find
local strsub = string.sub
 
--% Main function for users for invoke, entry point
--@ frame (table) A frame object containing the dialogue in the appropriate format
--: (string) Text containing the dialogue 
function p.main(frame)
    local args = require("Dev:Arguments").getArgs(frame)
    local separator = args["#separator"]
 
    return dialogue(args, separator)
end
--% Creates dialogue using template arguments
--@ args (table) A table containing template arguments with dialogue
--@ separator (string) A separator for each quote
--: (string) Text containing the dialogue 
function dialogue(args, separator)
    local htmlTranscript = mw.html.create("dl")
    local text,pos,author, quote = "","","",""
    local count  = 1
 
    htmlTranscript:addClass("transcript_dialogue")
 
    if separator then
        for id,dialogue in ipairs(args) do
            if dialogue and dialogue:len() > 0 then
                pos = strfind(dialogue, separator)
                author = strsub (dialogue, 1, pos-1)
                quote = strsub (dialogue, pos+1)
                htmlTranscript:tag("dt")
                    :addClass("transcript_author")
                    :wikitext(author)
                htmlTranscript:tag("dd")
                    :addClass("transcript_quote")
                    :wikitext(quote)
            end
        end
    else
        while args[count] do
            text = args[count]
 
            if count % 2 == 0 then
                htmlTranscript:tag("dd")
                    :addClass("transcript_quote")
                    :wikitext(text)
            else         
                htmlTranscript:tag("dt")
                    :addClass("transcript_author")
                    :wikitext(text)
            end
 
            count = count + 1
        end
    end
 
    return htmlTranscript
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.