Module:Convert/text: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(update from sandbox per Template talk:Convert#Module version 8) |
(update from sandbox per Template talk:Convert#Module version 9) |
||
Line 102: | Line 102: | ||
["sqbr-sp"] = { " [" , "]" }, |
["sqbr-sp"] = { " [" , "]" }, |
||
["sqbr-nbsp"] = { " [" , "]" }, |
["sqbr-nbsp"] = { " [" , "]" }, |
||
["comma"] = { ", " , "" }, |
["comma"] = { ", " , "" , ", " }, |
||
["slash-sp"] = { " / " , "" , wantname = true }, |
["slash-sp"] = { " / " , "" , wantname = true }, |
||
["slash-nbsp"] = { " / ", "" , wantname = true }, |
["slash-nbsp"] = { " / ", "" , wantname = true }, |
||
["slash-nosp"] = { "/" , "" , wantname = true }, |
["slash-nosp"] = { "/" , "" , wantname = true }, |
||
["b"] = { " (" , ")" }, |
["b"] = { " (" , ")" }, |
||
["(or)"] = { " (" , ")", |
["(or)"] = { " (" , ")", " or " }, |
||
["br"] = { "<br />" , "" , wantname = true }, |
["br"] = { "<br />" , "" , wantname = true }, |
||
["br()"] = { "<br />(" , ")", wantname = true }, |
["br()"] = { "<br />(" , ")", wantname = true }, |
||
Line 114: | Line 114: | ||
-- Text to separate values in a range. |
-- Text to separate values in a range. |
||
local range_types = { |
local range_types = { |
||
-- Specifying a table requires |
-- Specifying a table requires either: |
||
-- * "off" and "on" values (for "abbr=off" and "abbr=on"), or |
|||
-- * "input" and "output" values (for LHS and RHS); |
|||
-- other fields are optional. |
-- other fields are optional. |
||
-- When "adj=on|abbr=off" applies, spaces in range text are replaced with hyphens. |
-- When "adj=on|abbr=off" applies, spaces in range text are replaced with hyphens. |
||
Line 127: | Line 129: | ||
["to about"] = " to about ", |
["to about"] = " to about ", |
||
["and"] = { off = " and ", on = " and ", exception = true }, |
["and"] = { off = " and ", on = " and ", exception = true }, |
||
["and(-)"] = { |
["and(-)"] = { input = " and ", output = "–" }, |
||
["or"] = { off = " or " , on = " or " , exception = true }, |
["or"] = { off = " or " , on = " or " , exception = true }, |
||
["to"] = { off = " to " , on = " to " , exception = true }, |
["to"] = { off = " to " , on = " to " , exception = true }, |
||
["to(-)"] = { |
["to(-)"] = { input = " to ", output = "–" }, |
||
["+/-"] = { off = " ± ", on = " ± ", adj = " ± ", is_range_change = true }, |
["+/-"] = { off = " ± ", on = " ± ", adj = " ± ", is_range_change = true }, |
||
["x"] = { off = " by ", on = " × ", is_range_x = true }, |
["x"] = { off = " by ", on = " × ", is_range_x = true }, |
||
Line 149: | Line 151: | ||
} |
} |
||
-- |
-- Convert accepts range text delimited with whitespace, for example, {{convert|1 to 2|ft}}. |
||
-- |
-- In addition, the following "words" are accepted without spaces, for example, {{convert|1-2|ft}}. |
||
-- Words must be in correct order for searching, for example, 'x' after 'xx'. |
|||
-- Put '-' last so can have a simple range with negative values as in {{convert|-5 to -1|C}}. |
|||
local range_words = { ' |
local range_words = { '-', '–', 'xx', 'x', '*' } |
||
local ranges = { |
local ranges = { |