473
edits
(update from dev wiki) |
(Update package: OSW Core) |
||
Line 4: | Line 4: | ||
["py"] = "python", | ["py"] = "python", | ||
["json"] = "json", | ["json"] = "json", | ||
["md"] = "markdown" | ["md"] = "markdown", | ||
["yml"] = "yaml", | |||
["yaml"] = "yaml", | |||
} | } | ||
Line 10: | Line 12: | ||
local url = frame.args['url'] | local url = frame.args['url'] | ||
local lang = frame.args['lang'] | local lang = frame.args['lang'] | ||
if (lang == "") then lang = nil end | |||
local show_line_numbers = frame.args['show_line_numbers'] | local show_line_numbers = frame.args['show_line_numbers'] | ||
if (show_line_numbers == "" or show_line_numbers == "0" or show_line_numbers == "false") then show_line_numbers = | if (show_line_numbers == nil or show_line_numbers == "" or show_line_numbers == "0" or show_line_numbers == "false") then show_line_numbers = false | ||
else show_line_numbers = true end | |||
local highlight = frame.args['highlight'] | local highlight = frame.args['highlight'] | ||
local render_markdown = frame.args['render_markdown'] | local render_markdown = frame.args['render_markdown'] | ||
Line 23: | Line 27: | ||
local start_line = frame.args['start_line'] | local start_line = frame.args['start_line'] | ||
local end_line = frame.args['end_line'] | local end_line = frame.args['end_line'] | ||
if ((start_line == nil or start_line == "") and anchor ~= nil) then start_line = p.splitString(p.splitString(anchor, "-")[1], "L")[1] end | if ((start_line == nil or start_line == "") and anchor ~= nil) then start_line = p.splitString(p.splitString(p.splitString(anchor, "-")[1], "L")[1], "C")[1] end -- '#L65C1-L80C10' => 65 | ||
if ((end_line == nil or end_line == "") and anchor ~= nil) then | if ((end_line == nil or end_line == "") and anchor ~= nil) then | ||
end_line = p.splitString(anchor, "-")[2] | end_line = p.splitString(anchor, "-")[2] | ||
if (end_line ~= nil) then end_line = p.splitString(end_line, "L")[1] end | if (end_line ~= nil) then end_line = p.splitString(p.splitString(end_line, "L")[1], "C")[1] end -- '#L65C1-L80C10' => 10 | ||
end | end | ||
mw.logObject(start_line) | mw.logObject(start_line) | ||
Line 55: | Line 59: | ||
mw.logObject(res["__text"]) | mw.logObject(res["__text"]) | ||
lang = p.file_type_mapping[file_type] | if (lang == nil) then lang = p.file_type_mapping[file_type] end | ||
if (lang == nil) then lang = "text" end | if (lang == nil) then lang = "text" end | ||
Line 68: | Line 72: | ||
-- extract line numbers from url | -- extract line numbers from url | ||
if (start_line ~= nil and start_line ~= "") then hl_params["start"] = start_line end | if (start_line ~= nil and start_line ~= "") then hl_params["start"] = start_line end | ||
if (show_line_numbers | if (show_line_numbers) then hl_params["line"] = "1" end | ||
if (highlight ~= nil and highlight ~= "") then | if (highlight ~= nil and highlight ~= "") then | ||
if (start_line ~= nil and start_line ~= "") then | if (start_line ~= nil and start_line ~= "") then |
edits