Template:Lead/SplitNumber

From Biowikifarm Metawiki
Jump to: navigation, search

The first parameter of the Lead template may be a combination of different things and needs to be split into two columns (0 and 1). Cases:

  • Simple number: Return input + empty string
  • Number plus number in parentheses, e.g. "12 (2)": Return 12 + (2), where 2 is formatted as a link (the backlink; this href of this must be without ()!)
  • Number plus certain characters (used to distinguish multiple leads in a couplet, like "2, 2*, 2**"): Return 2 + *, etc.
  • Number plus hyphen, like "2, 2-): Returns NOTHING + -, i.e. here the number is suppressed!
  • Number plus certain letter (for couplets with MANY leads), like "2 a, 2 b, 2 c"): Return 2 + a, etc.
    Note: in this case, a blank must be present between the number and the letter. "1b" will not work at present!

The subprocedure has three parameters: First parameter is the string to be split, second parameter 0 to return first, 1 to return second element. The third parameter "noformatting=1" suppresses actions like swap the 2nd and 1st part, (like "2-" returning "-" + ""). It currently works only in combination with the 2nd parameter set to "0" and enforces to always return the lead number.

NOTE: This has a major problem with *; presently only the case of one * is fixed, 2** will appear still broken. Hoping for bugfix in mediawiki.

USAGE examples

123: actual = "123 + "; expected = "123 +"

123 (2): actual = "123 +  (2)"; expected = "123 + (2)" (where "(2)" is a link)

123*: actual = "123 + *"; expected = "123 + *"

123**: actual = "123 + **"; expected = "123 + **"

123-: actual = "– + "; expected = "– + (EMPTY)"

123': actual = "123 + ’"; expected = "123 + ’ "

123’’: actual = "123 + ’’"; expected = "123 + ’’ "

123 a: actual = "123 + a"; expected = "123 + a "

123a: actual = "123a + "; expected = "123a + (EMPTY)" -- It is known that this does not work without a blank!