Module:Step vis: Difference between revisions
ArrowHead294 (talk | contribs) mNo edit summary |
ArrowHead294 (talk | contribs) mNo edit summary |
||
| Line 5: | Line 5: | ||
-- Helper function | -- Helper function | ||
-- Create a step visualization that's based on the table on the diasem page | -- Create a step visualization that's based on the table on the diasem page | ||
function p.step_pattern_to_visualization(step_pattern | function p.step_pattern_to_visualization(step_pattern) | ||
local step_pattern = step_pattern or { 5, 2, 5, 0, 5, 2, 0 } | local step_pattern = step_pattern or { 5, 2, 5, 0, 5, 2, 0 } | ||
local left_border = | local left_border = "├" -- U+251C ├ | ||
local right_border = | local right_border = "┤" -- U+2524 ┤ | ||
local no_border = | local no_border = "─" -- U+2500 ─ | ||
local double_border = | local double_border = "╫" -- U+256B ╫ | ||
local double_border_left = | local double_border_left = "╟" -- U+255F ╟ | ||
local double_border_right = | local double_border_right = "╢" -- U+2562 ╢ | ||
local single_border = | local single_border = "┼" -- U+253C ┼ | ||
local step_visualization = "" | local step_visualization = "" | ||
| Line 45: | Line 45: | ||
- In debugging mode, the HTML entities themselves are displayed, so the index is -13 instead of -9 | - In debugging mode, the HTML entities themselves are displayed, so the index is -13 instead of -9 | ||
]]-- | ]]-- | ||
step_visualization = string.sub(step_visualization, 1, | step_visualization = string.sub(step_visualization, 1, -9) | ||
end | end | ||
current_step_vis = double_border_right | current_step_vis = double_border_right | ||
| Line 80: | Line 80: | ||
local step_pattern = tip.parse_numeric_entries(frame.args["Step Pattern"], " ") | local step_pattern = tip.parse_numeric_entries(frame.args["Step Pattern"], " ") | ||
local debugg = yesno(frame.args["debug"]) | local debugg = yesno(frame.args["debug"]) | ||
local result = p.step_pattern_to_visualization(step_pattern) | |||
return frame:preprocess(debugg == true and "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" or result) | |||
end | end | ||
return p | return p | ||