Changes

Jump to: navigation, search

Module:Ruby

292 bytes added, 4 years ago
m
Protected "Module:Ruby": High traffic page ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))
-- <pre>
local p = {}
function p.split( frame )
-- -- implements {{Ruby/split}} -- local args if frame == mw.getCurrentFrame() then args = frame:getParent().args else args = frame end if not args[1] then return -- nothing was passed to the module end
local args [1] = frame:getParentmw.text.trim().args if not args[1] then return end)
args[1] = if not mw.textustring.trimfind( args[1] , '<ruby' )then return args[1] -- if there's no Ruby markup in the input, just return it end
if not args[2] = args[2] and ( mw.ustringtext.findtrim( args[12], ) == '<rubybase' ) then return and '' or mw.text.trim( args[12] end) ) or ''
args[2] local first, parts, match first = mw.ustring.match( args[21] and , '^( .-)<ruby' ) or '' -- grab anything before the first <ruby> tag since otherwise it'll be lost parts = mw.text.trimsplit( args[1], '<ruby' ) match = args[2] ) == 'base' and '<rb[^>]*>(.-)</rb>' or mw.text.trim( args'<rt[2^>] *>(.-) ) or '</rt>'
local first for i = 1, #parts, matchdo first parts[i] = ( mw.ustring.match( argsparts[1i], '^([^<]*)' match ) or '') parts = .. ( mw.textustring.splitmatch( argsparts[1i], '</ruby>(.*)$' ) match = args[2] == or '' and '<rb>([^<]*)-- grab anything between </rbruby>' or 'and the next <rtruby>([^<]*or the end of the string, if this is the last part)</rt>' end
for i=1, #parts do parts[i] = ( mw.ustring.match( parts[i], match ) or '' ) .. ( mw.ustring.match( parts[i], '</ruby>(.*)$' ) or '' ) end  return first, table.concat( parts, '' )
end
return p
-- </pre>

Navigation menu