Modul:Text: Unterschied zwischen den Versionen
2015-06-20
w>PerfektesChaos (2015-05-22) |
w>PerfektesChaos (2015-06-20) |
||
| Zeile 1: | Zeile 1: | ||
--[=[ | local Text = { suite = "Text", | ||
serial = "2015-06-20" }; | |||
--[=[ | |||
Text utilities | Text utilities | ||
]=] | ]=] | ||
| Zeile 5: | Zeile 7: | ||
local | -- local globals | ||
local PatternCJK = false | local PatternCJK = false | ||
local PatternCombined = false | local PatternCombined = false | ||
| Zeile 172: | Zeile 174: | ||
return r | return r | ||
end -- Text.containsCJK() | end -- Text.containsCJK() | ||
Text.getPlain = function ( adjust ) | |||
-- Remove wikisyntax from string, except templates | |||
-- Parameter: | |||
-- adjust -- string | |||
-- Returns: string | |||
local i = adjust:find( "<!--", 1, true ) | |||
local r = adjust | |||
local j | |||
while i do | |||
j = r:find( "-->", i + 3, true ) | |||
if j then | |||
r = r:sub( 1, i ) .. r:sub( j + 3 ) | |||
else | |||
r = r:sub( 1, i ) | |||
end | |||
i = r:find( "<!--", i, true ) | |||
end -- "<!--" | |||
r = r:gsub( "(</?%l[^>]*>)", "" ) | |||
:gsub( "'''(.+)'''", "%1" ) | |||
:gsub( "''(.+)''", "%1" ) | |||
return r | |||
end -- Text.getPlain() | |||
| Zeile 519: | Zeile 546: | ||
function p.containsCJK( frame ) | function p.containsCJK( frame ) | ||
return Text.containsCJK( frame.args[ 1 ] or "" ) and "1" or "" | return Text.containsCJK( frame.args[ 1 ] or "" ) and "1" or "" | ||
end | |||
function p.getPlain( frame ) | |||
return Text.getPlain( frame.args[ 1 ] or "" ) | |||
end | end | ||
function p.isLatinRange( frame ) | function p.isLatinRange( frame ) | ||
return Text.isLatinRange( frame.args[1] or "" ) and "1" or "" | return Text.isLatinRange( frame.args[ 1 ] or "" ) and "1" or "" | ||
end | end | ||
function p.isQuote( frame ) | function p.isQuote( frame ) | ||
return Text.isQuote( frame.args[1] or "" ) and "1" or "" | return Text.isQuote( frame.args[ 1 ] or "" ) and "1" or "" | ||
end | end | ||
| Zeile 549: | Zeile 580: | ||
slang = mw.text.trim( slang ) | slang = mw.text.trim( slang ) | ||
end | end | ||
return Text.quoteUnquoted( frame.args[1] or "", | return Text.quoteUnquoted( frame.args[ 1 ] or "", | ||
slang, | slang, | ||
tonumber( frame.args[3] ) ) | tonumber( frame.args[3] ) ) | ||
| Zeile 555: | Zeile 586: | ||
function p.removeDiacritics( frame ) | function p.removeDiacritics( frame ) | ||
return Text.removeDiacritics( frame.args[1] or "" ) | return Text.removeDiacritics( frame.args[ 1 ] or "" ) | ||
end | end | ||