Строка 48: |
Строка 48: |
| return P (quote) * ((any - quote + escape * quote) ^ 0 / function (str) | | return P (quote) * ((any - quote + escape * quote) ^ 0 / function (str) |
| local sanitised = gsub (str, '\\x([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]?[0-9a-fA-F]?)', function (code) | | local sanitised = gsub (str, '\\x([0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]?[0-9a-fA-F]?)', function (code) |
− | return string.char (tonumber ('0x' .. code)) | + | return char (tonumber ('0x' .. code)) |
| end) | | end) |
| sanitised = gsub (sanitised, '\\n', '\n') | | sanitised = gsub (sanitised, '\\n', '\n') |
Строка 64: |
Строка 64: |
| -- Generate two functions allowed in wikifier with pseudo-static variables (hidden upvalues): | | -- Generate two functions allowed in wikifier with pseudo-static variables (hidden upvalues): |
| local hide, restore = (function () | | local hide, restore = (function () |
| + | local open, close = char (0x01), char (0x02) |
| + | local function strip_marker (no) |
| + | return open .. tostring (no) .. close |
| + | end |
| local hidden = {} | | local hidden = {} |
| return function (string, pattern, flags) | | return function (string, pattern, flags) |
Строка 69: |
Строка 73: |
| local no = #hidden + 1 | | local no = #hidden + 1 |
| hidden [no] = found | | hidden [no] = found |
− | return '\x01' .. tostring (no) .. '\x02' | + | return strip_marker (no) |
| end) | | end) |
| end, function (text) | | end, function (text) |
| for i = #hidden, 1, -1 do | | for i = #hidden, 1, -1 do |
− | text = gsub (text, '\x01' .. tostring (i) .. '\x02', hidden [i]) | + | text = gsub (text, strip_marker (i), hidden [i]) |
| end | | end |
| hidden = {} | | hidden = {} |