Module:Documentation: Difference between revisions
Add classes |
Fix large docs disappearing |
||
| Line 98: | Line 98: | ||
-- Wrapper around the documentation on the main page | -- Wrapper around the documentation on the main page | ||
function p.page( f ) | function p.page( f ) | ||
-- mw.text.trim uses mw.ustring.gsub, which silently fails on large strings | |||
local function trim( s ) | |||
return string.gsub( s, '^[\t\r\n\f ]*(.-)[\t\r\n\f ]*$', '%1' ) | |||
end | |||
local args = require( 'Module:ProcessArgs' ).merge( true ) | local args = require( 'Module:ProcessArgs' ).merge( true ) | ||
local page = mw.title.getCurrentTitle() | local page = mw.title.getCurrentTitle() | ||
local namespace = page.nsText | local namespace = page.nsText | ||
local docText = | local docText = trim( args.content or '' ) | ||
if docText == '' then docText = nil end | if docText == '' then docText = nil end | ||
| Line 117: | Line 121: | ||
if not docText and not noDoc then | if not docText and not noDoc then | ||
f:callParserFunction( '#dplvar:set', '$doc noheader', '1' ) | f:callParserFunction( '#dplvar:set', '$doc noheader', '1' ) | ||
docText = | docText = trim( f:expandTemplate{ title = ':' .. docPage.fullText } ) | ||
if f:callParserFunction( '#dplvar', '$doc bad' ) == '1' then | if f:callParserFunction( '#dplvar', '$doc bad' ) == '1' then | ||
badDoc = 1 | badDoc = 1 | ||