Open main menu
Home
Random
Donate
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Decimal-align
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
--Align numbers in table cells on the decimal point local p = {} function p.main(frame) local input_string_raw = frame.args[1] string = frame:preprocess( input_string_raw ) local left_percent_default = tonumber(frame.args['left']) local left_percents = {} left_percents[1] = tonumber(frame.args['left1']) left_percents[2] = tonumber(frame.args['left2']) left_percents[3] = tonumber(frame.args['left3']) left_percents[4] = tonumber(frame.args['left4']) left_percents[5] = tonumber(frame.args['left5']) left_percents[6] = tonumber(frame.args['left6']) left_percents[7] = tonumber(frame.args['left7']) left_percents[8] = tonumber(frame.args['left8']) left_percents[9] = tonumber(frame.args['left9']) left_percents[10] = tonumber(frame.args['left10']) local column = 1 for number in mw.ustring.gmatch( string, '%|[%d%.,]+' ) do local left_percent = left_percents[column] or left_percent_default or 50 local right_percent = 100 - left_percent column = column + 1 left_string = mw.ustring.sub(mw.ustring.match(number, '^%|[%d, ]*'),2) right_string = mw.ustring.match(number, '%.[%d ]*$') if left_string == '' then left_string = '0' end formatted_number = '%|<span style=\"float: left; text-align: right; width: ' .. tostring(left_percent) .. '%;\">' .. left_string .. '</span>' if right_string then formatted_number = formatted_number .. '<span style=\"float: right; text-align: left; width: ' .. tostring(right_percent) .. '%;\">' .. right_string .. '</span>' end string = mw.ustring.gsub( string, number, formatted_number ) end return string end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Tl
(
edit
)
Module:Decimal-align/doc
(
edit
)