User talk:Omegatron/monobook.js

To do

 * use nbsp between number and unit?
 * en dash between digits with a unit or percent after?
 * 4-5dB &rarr; 4–5 dB
 * add a word boundary after unit in regexps so words like... um...  "5radians" don't get converted into "5 radians"?
 * and before numbers
 * periods aren't counted towards em dashes
 * add hz --> Hz
 * Make it stop converting "1970s" to "1970 s" -- \d?\d?\d0s
 * nevermind, skip plain s
 * fix things like "6,3 mm" &rarr; "6.3 mm", "1 000 m" &rarr; "1,000 m" as per MoS
 * Add unicode number entities to replacement lists:
 * commonly confused
 * Write something to fix heading format, as if it had been added with the + tab
 * (={2,})( |\t)*(.*?)( |\t)*(={2,})(\n)+ → $1 $3 $5$6$6
 * Write something to change "+/-" into ±
 * (\s|\d)\+\/(-|&minus;|-)(\s|\d) → $1±$3
 * Fix external links and see also sections
 * Press preview by default after clicking tab
 * everything should ignore the insides of math tags
 * extra newline remover should count lines with only whitespace too
 * Rewrite units thing without depending on clunky regexps
 * "12-mm" → "12 mm"
 * lowercase units when written out?
 * These aren't working correctly:
 * 1kHz)
 * 0dBu
 * ric" -- 3:1
 * 0x100 should not be 0×100, but 640x480 should be 640×480
 * 
 * missed uF Audio_crossover
 * link the first occurrence of each unit
 * Audio links script should replace "help" with "Audio help", "info" with "File info" or "File details"
 * some buttons for saving with specific edit summaries? Like "Formatting" "Spelling" etc for people like me who don't put edit summaries?
 * write your own shortened diff for the automatic edit summaries?!1? It could be done, probably.  Have javascript save the original textarea to a variable, and when you press submit, it does a comparison of the current textarea and the original and adds a summary of the diff.  i wish i knew js better.
 * http://ejohn.org/projects/javascript-diff-algorithm/
 * Quarl wrote one User:Quarl/auto_summary.js

SI regular expressions
Prefixes: Y Z E P T G M k h da d c m &mu; &micro; µ n p f a z y
 * ['Y', 'Z', 'E', 'P', 'T', 'G', 'M', 'k', 'h', 'da', 'd', 'c', 'm', 'µ', 'n', 'p', 'f', 'a', 'z', 'y']

Base units: g s m A K mol cd


 * ['g', 's', 'm', 'A', 'K', 'mol', 'cd']

Derived units: rad sr Hz N J W Pa lm lx C V &Omega; ohm Ω F Wb T H S Bq Gy Sv kat &deg;C °C M

Accepted units: L

Other units to treat the same way: B dB


 * 1) Convert all occurrences (in the presence of numbers and prefixes):
 * 2) * &amp;deg; &rarr; &deg;
 * 3) ** &amp;deg; &rarr; &deg;
 * 4) * &amp;Omega; or ohm or Ohm &rarr; Ω
 * 5) ** (\d)\s?(Y|Z|E|P|T|G|M|k|K|h|da|d|c|m|&micro;|&mu;|µ|n|p|f|a|z|y)?(&amp;Omega;|ohm|Ohm)s? &rarr; $1 $2Ω
 * 6) * &amp;mu; or &mu; or &amp;micro; &rarr; µ
 * 7) ** (\d)\s?(&amp;mu;|&mu;|&amp;micro;)(g|s|m|A|K|mol|cd|rad|sr|Hz|N|J|W|Pa|lm|lx|C|V|Ω|F|Wb|T|H|S|Bq|Gy|Sv|kat|°C|M) &rarr; $1 µ$3
 * 8) * K &rarr; k before units (will conflict with compound units that should be K&sdot;something)
 * 9) ** (\d)\s?K(g|s|m|A|K|mol|cd|rad|sr|Hz|N|J|W|Pa|lm|lx|C|V|Ω|F|Wb|T|H|S|Bq|Gy|Sv|kat|°C|M) &rarr; $1 k$3
 * 10) spaces between numbers and units
 * 11) * (\d)\s?(dB|B)\b → $1 $3
 * 12) * (\d)\s?(Y|Z|E|P|T|G|M|k|K|h|da|d|c|m|&micro;|n|p|f|a|z|y)?(g|s|m|A|K|mol|cd|rad|sr|Hz|N|J|W|Pa|lm|lx|C|V|Ω|F|Wb|T|H|S|Bq|Gy|Sv|kat|°C|M) &rarr; $1 $2$3

Digital units
 * 1) Decimal
 * 2) * kbits/s or kb/s or kbps or Kbps &rarr; kbit/s
 * 3) ** [KkMmGgTtPpEeYyZz](bps|bits?\/s|b\/s) &rarr; $1bit/s
 * 4) * kbytes/s or kbyte/s (or KB/s?) or kBps or KBps &rarr; kB/s
 * 5) ** [KkMmGgTtPpEeYyZz](Bps|bytes?\/s|B\/s) &rarr; $1B/s
 * 6) Binary
 * 7) * Kib or kib &rarr; Kibit
 * 8) ** [KkMmGgTtPpEeYyZz]ib &rarr; $1ibit
 * 9) * kiB &rarr; KiB
 * 10) ** [KkMmGgTtPpEeYyZz]iB &rarr; $1iB
 * 11) * Common error
 * 12) ** mibi(bit|byte) /i &rarr; mebi$1

kbit/s kB/s Kibit/s KiB/s

can the entire set of units be defined as a variable and included in regexps?

maybe match for the entire thing and say "these pieces are units", and then run each unit through separate rules that correct each part?

these don't handle capitalization yet. can you match on several things but only use some?

False positive on dates
Make it stop converting "1970s" to "1970 s"

Convert: 1000 s 1954 s

Don't convert: 1970s 70s 1800s 00s

-- \d?\d?\d0s

You know what? We're never going to see "1000 s". Just skip it.

Legacy JavaScript
Hello! This script has been detected as using deprecated parameters that need to be replaced with the updated version. Examples include  needs to be replaced with   or   (depending on use);  all wgGlobalVariables need to be properly gotten with  ; and   needs to be called with. Please see ResourceLoader/Legacy JavaScript for details. Thank you. —  21:53, 19 January 2015 (UTC)