Template:FormatName: Difference between revisions

No edit summary
mNo edit summary
Line 1: Line 1:
{{#lua:
{{#lua:
  replacements = {
  ["alpha"] = "α",
  ["beta"] = "β",
  ["chi"]  = "χ",
  ["delta"] = "δ",
  ["Delta"] = "Δ",
  ["epsilon"] = "ε",
  ["zeta"] = "ζ",
  ["phi"] = "φ",
  ["gamma"] = "γ",
  ["Gamma"] = "Γ",
  ["eta"] = "η",
  ["kappa"] = "κ",
  ["lambda"] = "λ",
  ["mu"] = "μ",
  ["nu"] = "ν",
  ["pi"] = "π",
  ["Pi"] = "Π",
  ["theta"] = "θ",
  ["tau"] = "τ",
  ["upsilon"] = "υ",
  ["Upsilon"] = "Υ",
  ["phi"] = "φ",
  ["psi"] = "ψ",
  ["xi"] = "ξ",
  ["omega"] = "ω",
  ["sigma"] = "σ",
  }
   name = stdin:match("[^&]+")
   name = stdin:match("[^&]+")
   name = string.gsub( name, " alpha%-", " α-" )
   name = string.gsub (name, "%a+",  
   name = string.gsub( name, " beta%-", " β-" )
  function (str)
  name = string.gsub( name, " gamma%-", " γ-" )
    return replacements [str] or str
   name = string.gsub( name, " delta%-", " δ-" )
  end
  name = string.gsub( name, " Delta%-", " Δ-" )
  )
 
   name = string.gsub( name, "_([%d.]+)^([%d.]+) ", '<span style="position:relative"><sub>%1</sub><span style="font-size:x-small;position:absolute;left:0px;top:-4px">%2</span></span>')
   name = string.gsub( name, "^([%d.]+)_([%d.]+) ", '<span style="position:relative"><sup>%1</sup><span style="font-size:x-small;position:absolute;left:0px;top:5px">%2</span></span>')
   name = string.gsub( name, "_(%d%d?) ", "<sub>%1</sub> " )
   name = string.gsub( name, "_(%d%d?) ", "<sub>%1</sub> " )
   name = string.gsub( name, "^(%d%d?]) ", "<sup>%1</sup> " )
   name = string.gsub( name, "^(%d%d?) ", "<sup>%1</sup> " )
   print(name)
   print(name)
|{{{1|foo Delta-foo_21 fdol}}}}}
|{{{1|==Greek Letters==
Write Alpha, Beta, or Gamma in lowercase.<br/>
;Example. (in lowercase)
* Alpha --> alpha <br/>
* Beta --> beta <br/>
* Gamma --> gamma <br/>
* Delta --> Delta<br/>
*
*
}}}}}
 
 
 
m m
n n
p p
P P
q q
t t
u u
U U
w w
x x
y y
z z

Revision as of 16:35, 19 January 2010

{{#lua:

 replacements = {
 ["alpha"] = "α",
 ["beta"] = "β",
 ["chi"]  = "χ",
 ["delta"] = "δ",
 ["Delta"] = "Δ",
 ["epsilon"] = "ε",
 ["zeta"] = "ζ",
 ["phi"] = "φ",
 ["gamma"] = "γ",
 ["Gamma"] = "Γ",
 ["eta"] = "η",
 ["kappa"] = "κ",
 ["lambda"] = "λ", 
 ["mu"] = "μ", 
 ["nu"] = "ν", 
 ["pi"] = "π",
 ["Pi"] = "Π",
 ["theta"] = "θ",
 ["tau"] = "τ",
 ["upsilon"] = "υ",
 ["Upsilon"] = "Υ",
 ["phi"] = "φ",
 ["psi"] = "ψ",
 ["xi"] = "ξ",
 ["omega"] = "ω",
 ["sigma"] = "σ",
 }
 name = stdin:match("[^&]+")
 name = string.gsub (name, "%a+", 
 function (str)
   return replacements [str] or str
 end
 )
 name = string.gsub( name, "_([%d.]+)^([%d.]+) ", '%1%2')
 name = string.gsub( name, "^([%d.]+)_([%d.]+) ", '%1%2')
 name = string.gsub( name, "_(%d%d?) ", "%1 " )
 name = string.gsub( name, "^(%d%d?) ", "%1 " )
 print(name)

|==Greek Letters== Write Alpha, Beta, or Gamma in lowercase.

Example. (in lowercase)
  • Alpha --> alpha
  • Beta --> beta
  • Gamma --> gamma
  • Delta --> Delta

}}


m m n n p p P P q q t t u u U U w w x x y y z z