Module:Command: Difference between revisions

mNo edit summary
mNo edit summary
 
(5 intermediate revisions by 4 users not shown)
Line 40: Line 40:
local startPos, endPos = params[1]:find( "'[^']-'" )
local startPos, endPos = params[1]:find( "'[^']-'" )
local startPosn, endPosn = params[1]:find('"[^"]-"')
local startPosn, endPosn = params[1]:find('"[^"]-"')
if startPos and startPos and startPosn < startPos then
if startPosn and startPos and startPosn < startPos then
startPos, endPos = startPosn, endPosn
startPos, endPos = startPosn, endPosn
end
end
Line 58: Line 58:
if startPos then
if startPos then
params[1] = params[1]:sub( 1, startPos - 1 ) ..
params[1] = params[1]:sub( 1, startPos - 1 ) ..
params[1]:sub( startPos, endPos ):gsub('%[','〈lsqb〉'):gsub('%]','〈rsqb〉'):gsub('{','&lcub;'):gsub('}','&rcub;'):gsub("'",'〈apos〉'):gsub('"','〈quot〉'):gsub( '%s', '〈space〉' ) ..
params[1]:sub( startPos, endPos ):gsub('%[','〈lsqb〉'):gsub('%]','〈rsqb〉'):gsub('{','&#123;'):gsub('}','&#125;'):gsub("'",'〈apos〉'):gsub('"','〈quot〉'):gsub( '%s', '〈space〉' ) ..
params[1]:sub( endPos + 1 )
params[1]:sub( endPos + 1 )
else
else
Line 175: Line 175:
local attr = ''
local attr = ''
if args.long then
if args.long then
attr = 'style="display: block; padding: 0.8em 1em; margin-bottom: 0.4em; word-warp: break-word;"'
attr = 'style="display: flex; padding: 0.8em 1em; margin-bottom: 0.4em; word-warp: break-word;"'
end
end
Line 183: Line 183:
result = result:gsub( '<', '&lt;' ):gsub( '&lt;(!%-%- Command %-%->)&lt;','<%1<'):gsub( '&lt;/code>&lt;(!%-%- /Command %-%->)','</code><%1')
result = result:gsub( '<', '&lt;' ):gsub( '&lt;(!%-%- Command %-%->)&lt;','<%1<'):gsub( '&lt;/code>&lt;(!%-%- /Command %-%->)','</code><%1')
end
end
return '<!-- Command --><code ' .. attr .. '>' .. slash .. result .. '</code><!-- /Command -->'
result = '<!-- Command --><code ' .. attr .. '><span>' .. slash .. result .. '</span></code><!-- /Command -->'
    if needFormat then
        result = result .. '[[Category:Pages using deprecated command module]]'
    end
    return result
end
end
return p
return p