Template:FormatName: Difference between revisions
mNo edit summary |
No edit summary |
||
Line 28: | Line 28: | ||
["sigma"] = "σ", | ["sigma"] = "σ", | ||
} | } | ||
name = stdin:match(".+") | |||
---SUPER/SUBSCRIPTS--- | |||
name = string.gsub( name, "(%a)_{([%d.,%a]+)}", "%1<sub>%2</sub>" ) | |||
name = string.gsub( name, "(%a)^{([%d.,%a]+)}", "%1<sup>%2</sup>" ) | |||
name = string.gsub( name, "(%a)_([%d.]+)", "%1<sub>%2</sub>" ) | |||
name = string.gsub( name, "(%a)^([%d.]+)", "%1<sup>%2</sup>" ) | |||
---GREEK LETTERS--- | ---GREEK LETTERS--- | ||
name = string.gsub (name, '([%a"]+)', | name = string.gsub (name, '([%a"]+)', | ||
function (str) | function (str) | ||
Line 35: | Line 41: | ||
end | end | ||
) | ) | ||
---SUPER | ---SUPER AND SUBSCRIPTS--- | ||
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"><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.]+) ", '<span style="position:relative"><sup>%1</sup><span style="font-size:x-small;position:absolute;left:0px;top:5px">%2</span></span>') | ||
print(name) | print(name) | ||
|{{{1|==Greek Letters== | |{{{1|==Greek Letters== | ||
Write "alpha", "beta", or "gamma" in lowercase. | Write "alpha", "beta", or "gamma" in lowercase. | ||
Line 62: | Line 67: | ||
* <nowiki>D_1</nowiki> → D_1 | * <nowiki>D_1</nowiki> → D_1 | ||
* <nowiki>D^2</nowiki> → D^2 | * <nowiki>D^2</nowiki> → D^2 | ||
* <nowiki>Delta^{12.13}</nowiki> → Delta^{12.13} | |||
}}}}} | }}}}} |
Revision as of 13:25, 1 February 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(".+")
---SUPER/SUBSCRIPTS---
name = string.gsub( name, "(%a)_{([%d.,%a]+)}", "%1%2" ) name = string.gsub( name, "(%a)^{([%d.,%a]+)}", "%1%2" ) name = string.gsub( name, "(%a)_([%d.]+)", "%1%2" ) name = string.gsub( name, "(%a)^([%d.]+)", "%1%2" )
---GREEK LETTERS---
name = string.gsub (name, '([%a"]+)', function (str) return replacements[str] or str end )
---SUPER AND SUBSCRIPTS---
name = string.gsub( name, "_([%d.]+)^([%d.]+) ", '%1%2') name = string.gsub( name, "%^([%d.]+)_([%d.]+) ", '%1%2') print(name)
|==Greek Letters== Write "alpha", "beta", or "gamma" in lowercase.
- Example.
- alpha → alpha
- beta → beta
- chi → chi
- delta → delta
- epsilon → epsilon
- gamma → gamma
- eta → eta
- and so on.
Super/subscripts
Use "_" for subscripts, "^" for superscripts. To show both, write the longer super/sub-script first. Some word must follow after a space when both ^ and _ are used.
- Example.
- D_10^20 (next word) → D_1^2 (next word)
- D_10000^1 (next word) → D_10000^1 (next word)
- D^10000_1 (next word) → D^10000_1 (next word)
- D^10_10000 (bad example) → D^10_10000 (bad example)
- D_1 → D_1
- D^2 → D^2
- Delta^{12.13} → Delta^{12.13}
}}