Modul:Text: Unterschied zwischen den Versionen

868 Bytes hinzugefügt ,  vor 8 Jahren
2017-04-05
w>PerfektesChaos
(2017-03-25)
w>PerfektesChaos
(2017-04-05)
Zeile 1: Zeile 1:
local Text = { suite  = "Text",
local Text = { serial = "2017-04-05",
               serial = "2017-03-25" }
               suite  = "Text" }
--[=[
--[=[
Text utilities
Text utilities
Zeile 74: Zeile 74:
                   ["pt-br"] = "ldla",
                   ["pt-br"] = "ldla",
                   ["zh-tw"] = "x300C",
                   ["zh-tw"] = "x300C",
                   ["zh-zh"] = "ld" }
                   ["zh-cn"] = "ld" }
     QuoteType = { bd    = { { 8222, 8220 },  { 8218, 8217 } },
     QuoteType = { bd    = { { 8222, 8220 },  { 8218, 8217 } },
                   bdla  = { { 8222, 8220 },  {  171,  187 } },
                   bdla  = { { 8222, 8220 },  {  171,  187 } },
Zeile 353: Zeile 353:
     return mw.text.listToText( collect )
     return mw.text.listToText( collect )
end -- Text.listToText()
end -- Text.listToText()
Text.quote = function ( apply, alien, advance )
    -- Quote text
    -- Parameter:
    --    apply    -- string, with text
    --    alien    -- string, with language code, or nil
    --    advance  -- number, with level 1 or 2, or nil
    -- Returns: quoted string
    local mode, slang
    if type( alien ) == "string" then
        slang = mw.text.trim( alien ):lower()
    else
        slang = mw.title.getCurrentTitle().pageLanguage
        if not slang then
            -- TODO FIXME: Introduction expected 2017-04
            slang = mw.language.getContentLanguage():getCode()
        end
    end
    if advance == 2 then
        mode = 2
    else
        mode = 1
    end
    return fiatQuote( mw.text.trim( apply ), slang, mode )
end -- Text.quote()






Text.quoteUnquoted = function ( apply, alien, advance )
Text.quoteUnquoted = function ( apply, alien, advance )
     -- Quote text, if not yet quoted
     -- Quote text, if not yet quoted and not empty
     -- Parameter:
     -- Parameter:
     --    apply    -- string, with text
     --    apply    -- string, with text
Zeile 365: Zeile 392:
     local r = mw.text.trim( apply )
     local r = mw.text.trim( apply )
     local s = mw.ustring.sub( r, 1, 1 )
     local s = mw.ustring.sub( r, 1, 1 )
     if s ~= ""  and  not Text.isQuote( s ) then
     if s ~= ""  and  not Text.isQuote( s, advance ) then
         s = mw.ustring.sub( r, -1, 1 )
         s = mw.ustring.sub( r, -1, 1 )
         if not Text.isQuote( s ) then
         if not Text.isQuote( s ) then
          local mode, slang
            r = Text.quote( r, alien, advance )
          if type( alien ) == "string" then
              slang = mw.text.trim( alien ):lower()
          else
              slang = mw.language.getContentLanguage():getCode()
          end
          if advance == 2 then
              mode = 2
          else
              mode = 1
          end
          r = fiatQuote( r, slang, mode )
         end
         end
     end
     end
Zeile 708: Zeile 724:
     end
     end
     return Text.listToText( args, frame.args.format )
     return Text.listToText( args, frame.args.format )
end
function p.quote( frame )
    local slang = frame.args[2]
    if type( slang ) == "string" then
        slang = mw.text.trim( slang )
        if slang == "" then
            slang = false
        end
    end
    return Text.quote( frame.args[ 1 ] or "",
                      slang,
                      tonumber( frame.args[3] ) )
end
end


Zeile 716: Zeile 747:
     if type( slang ) == "string" then
     if type( slang ) == "string" then
         slang = mw.text.trim( slang )
         slang = mw.text.trim( slang )
        if slang == "" then
            slang = false
        end
     end
     end
     return Text.quoteUnquoted( frame.args[ 1 ] or "",
     return Text.quoteUnquoted( frame.args[ 1 ] or "",
Zeile 721: Zeile 755:
                               tonumber( frame.args[3] ) )
                               tonumber( frame.args[3] ) )
end
end


function p.removeDiacritics( frame )
function p.removeDiacritics( frame )
Anonymer Benutzer