Content deleted Content added
Re-implement tag processing with temporary pipe change stuff (turns out it works, just not in the way its set up right now with {{!}} - will be working on this) |
Temporary somewhat working fix for the advanced-look processing/linter errors by avoiding (some) pipe replacement. This also disables the expansion of templates, as it was causing issues and im not entirely sure why its used right now other than for the old sake of {{#tag: |
||
Line 52:
-- insert a switcher-label span just after the first pipe (which has already been escaped as {{!}} instead the | character)
sortedLines[i] = sortedLines[i]:gsub(
"
'
1)
mw.log("Workin with",sortedLines[i])
end
local galleryContent = table.concat(sortedLines, '\n')
Line 84 ⟶ 85:
function hasCaption(line)
local caption = mw.ustring.match(line, ".-{{!}}(.*)") or mw.ustring.match(line, ".-|(.*)")
-- require caption to exist with more than 5 characters (avoids sizes etc being mistaken for captions)
return caption and #caption>5 and true or false
Line 130 ⟶ 131:
file = mw.ustring.gsub(file, '|%s*%d*x?%d+%s*px%s*([|%]])', '%1')
-- expand templates
-- file = mw.ustring.gsub(file, '{%b{}}', expand)
-- remove loose closing braces which don't have matching opening braces
-- file = mw.ustring.gsub(file, '}}', '')
-- remove loose opening braces which don't have matching closing braces (and the subsequent content, which is probably just a template name)
-- file = mw.ustring.gsub(file, '{{.-([|%]])', '%1')
-- replace pipes and equals (which would otherwise break the {{#tag:}} syntax)
-- file = mw.ustring.gsub(file, '|%s*alt%s*=', '{{!}}alt=')
-- file = mw.ustring.gsub(file, '|', '{{!}}')
-- file = mw.ustring.gsub(file, '=', '{{=}}')
-- remove linebreaks
file = mw.ustring.gsub(file, '\n\n', '<br>')
Line 146 ⟶ 147:
file = mw.ustring.gsub(file, '%]%]$', '')
table.insert(files, file)
mw.log(file)
end
return files
|