Module:Text: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content added Content deleted
(fix several bugs in getPlain) |
(factor out delimiter remover) |
||
Line 246: | Line 246: | ||
end -- Text.containsCJK() |
end -- Text.containsCJK() |
||
Text.removeDelimited = function (s, prefix, suffix) |
|||
-- Remove all text in s delimited by prefix and suffix (inclusive) |
|||
-- Arguments: |
|||
-- s = string to process |
|||
-- prefix = initial delimiter |
|||
-- suffix = ending delimiter |
|||
-- Returns: stripped string |
|||
local prefixLen = mw.ustring.len(prefix) |
|||
local suffixLen = mw.ustring.len(suffix) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
else |
|||
⚫ | |||
end |
|||
i = r:find(prefix, 1, true) |
|||
end |
|||
return r |
|||
end |
|||
Text.getPlain = function ( adjust ) |
Text.getPlain = function ( adjust ) |
||
Line 253: | Line 275: | ||
-- adjust -- string |
-- adjust -- string |
||
-- Returns: string |
-- Returns: string |
||
local |
local r = Text.removeDelimited(adjust,"<!--","-->") |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
else |
|||
⚫ | |||
end |
|||
⚫ | |||
end -- "<!--" |
|||
r = r:gsub( "(</?%l[^>]*>)", "" ) |
r = r:gsub( "(</?%l[^>]*>)", "" ) |
||
:gsub( "'''", "" ) |
:gsub( "'''", "" ) |