Newer
Older
XML / modules / generate-greek.php
<?php

// Quick and dirty,	but it does the job!

$char_data = array(
					//		Unicode name (lower case),		char,	U+xxxx,	LaTeX,			XSLT template match,			Unicode name (upper case),		char,	U+xxxx,	LaTeX,			XSLT template match,	
	"alpha"		=>	array( "GREEK SMALL LETTER ALPHA",		"α",	"03B1",	"\\alpha",		"greek-small-letter-alpha",		"GREEK CAPITAL LETTER ALPHA",	"Α",		"0391",	"A",			"greek-capital-letter-alpha" ),
	"beta"		=>	array( "GREEK SMALL LETTER BETA",		"β",	"03B2",	"\\beta",		"greek-small-letter-beta",		"GREEK CAPITAL LETTER BETA",	"Β",		"0392",	"B",			"greek-capital-letter-beta" ),
	"gamma"		=>	array( "GREEK SMALL LETTER GAMMA",		"γ",		"03B3",	"\\gamma",		"greek-small-letter-gamma",		"GREEK CAPITAL LETTER GAMMA",	"Γ",		"0393",	"\\Gamma",		"greek-capital-letter-gamma" ),
	"delta"		=>	array( "GREEK SMALL LETTER DELTA",		"δ",		"03B4",	"\\delta",		"greek-small-letter-delta",		"GREEK CAPITAL LETTER DELTA",	"Δ",		"0394",	"\\Delta",		"greek-capital-letter-delta" ),
	"epsilon"	=>	array( "GREEK SMALL LETTER EPSILON",	"ε",		"03B5",	"\\varepsilon",	"greek-small-letter-epsilon",	"GREEK CAPITAL LETTER EPSILON",	"Ε",		"0395",	"E",			"greek-capital-letter-epsilon" ),
	"zeta"		=>	array( "GREEK SMALL LETTER ZETA",		"ζ",	"03B6",	"\\zeta",		"greek-small-letter-zeta",		"GREEK CAPITAL LETTER ZETA",	"Ζ",		"0396",	"Z",			"greek-capital-letter-zeta" ),
	"eta"		=>	array( "GREEK SMALL LETTER ETA",		"η",	"03B7",	"\\eta",		"greek-small-letter-eta",		"GREEK CAPITAL LETTER ETA",		"Η",		"0397",	"H",			"greek-capital-letter-eta" ),
	"theta"		=>	array( "GREEK SMALL LETTER THETA",		"θ",	"03B8",	"\\theta",		"greek-small-letter-theta",		"GREEK CAPITAL LETTER THETA",	"Θ",		"0398",	"\\Theta",		"greek-capital-letter-theta" ),
	"iota"		=>	array( "GREEK SMALL LETTER IOTA",		"ι",		"03B9",	"\\iota",		"greek-small-letter-iota",		"GREEK CAPITAL LETTER IOTA",	"Ι",		"0399",	"I",			"greek-capital-letter-iota" ),
	"kappa"		=>	array( "GREEK SMALL LETTER KAPPA",		"κ",		"03BA",	"\\kappa",		"greek-small-letter-kappa",		"GREEK CAPITAL LETTER KAPPA",	"Κ",		"039A",	"K",			"greek-capital-letter-kappa" ),
	"lambda"	=>	array( "GREEK SMALL LETTER LAMBDA",		"λ",		"03BB",	"\\lambda",		"greek-small-letter-lambda",	"GREEK CAPITAL LETTER LAMBDA",	"Λ",		"039B",	"\\Lambda",		"greek-capital-letter-lambda" ),
	"mu"		=>	array( "GREEK SMALL LETTER MU",			"μ",	"03BC",	"\\mu",			"greek-small-letter-mu",		"GREEK CAPITAL LETTER MU",		"Μ",		"039C",	"M",			"greek-capital-letter-mu" ),
	"nu"		=>	array( "GREEK SMALL LETTER NU",			"ν",		"03BD",	"\\nu",			"greek-small-letter-nu",		"GREEK CAPITAL LETTER NU",		"Ν",		"039D",	"N",			"greek-capital-letter-nu" ),
	"xi"		=>	array( "GREEK SMALL LETTER XI",			"ξ",		"03BE",	"\\xi",			"greek-small-letter-xi",		"GREEK CAPITAL LETTER XI",		"Ξ",		"039E",	"\\Xi",			"greek-capital-letter-xi" ),
	"omicron"	=>	array( "GREEK SMALL LETTER OMICRON",	"ο",	"03BF",	"o",			"greek-small-letter-omicron",	"GREEK CAPITAL LETTER OMICRON",	"Ο",		"039F",	"O",			"greek-capital-letter-omicron" ),
	"pi"		=>	array( "GREEK SMALL LETTER PI",			"π",	"03C0",	"\\pi",			"greek-small-letter-pi",		"GREEK CAPITAL LETTER PI",		"Π",		"03A0",	"\\Pi",			"greek-capital-letter-pi" ),
	"rho"		=>	array( "GREEK SMALL LETTER RHO",		"ρ",	"03C1",	"\\rho",		"greek-small-letter-rho",		"GREEK CAPITAL LETTER RHO",		"Ρ",		"03A1",	"P",			"greek-capital-letter-rho" ),
	"sigma"		=>	array( "GREEK SMALL LETTER SIGMA",		"σ",	"03C2",	"\\sigma",		"greek-small-letter-sigma",		"GREEK CAPITAL LETTER SIGMA",	"Σ",		"03A3",	"\\Sigma",		"greek-capital-letter-sigma" ),
	"tau"		=>	array( "GREEK SMALL LETTER TAU",		"τ",		"03C4",	"\\tau",		"greek-small-letter-tau",		"GREEK CAPITAL LETTER TAU",		"Τ",		"03A4",	"T",			"greek-capital-letter-tau" ),
	"upsilon"	=>	array( "GREEK SMALL LETTER UPSILON",	"υ",	"03C5",	"\\upsilon",	"greek-small-letter-upsilon",	"GREEK CAPITAL LETTER UPSILON",	"Υ",		"03A5",	"\\Upsilon",	"greek-capital-letter-upsilon" ),
	"phi"		=>	array( "GREEK PHI SYMBOL",				"ϕ",	"03C6",	"\\phi",		"greek-phi-symbol",				"GREEK CAPITAL LETTER PHI",		"Φ",		"03A6",	"\\Phi",		"greek-capital-letter-phi" ),
	"chi"		=>	array( "GREEK SMALL LETTER CHI",		"χ",		"03C7",	"\\chi",		"greek-small-letter-chi",		"GREEK CAPITAL LETTER CHI",		"Χ",		"03A7",	"X",			"greek-capital-letter-chi" ),
	"psi"		=>	array( "GREEK SMALL LETTER PSI",		"ψ",	"03C8",	"\\psi",		"greek-small-letter-psi",		"GREEK CAPITAL LETTER PSI",		"Ψ",		"03A8",	"\\Psi",		"greek-capital-letter-psi" ),
	"omega"		=>	array( "GREEK SMALL LETTER OMEGA",		"ω",	"03C9",	"\\omega",		"greek-small-letter-omega",		"GREEK CAPITAL LETTER OMEGA",	"Ω",	"03A9",	"\\Omega",		"greek-capital-letter-omega" ),
);

foreach ( $char_data as $name	=>	$data )
{
	// The upper case HTML entity names have the first character capitalised.
	$upper_name = ucfirst( $name );
	
	print <<<EOT
	<!-- Lower case {$name}. -->
	
	<template name="{$name}" match="{$name}|{$data[4]}">
		<common formats="/latex/xelatex/"><xsl:text>\\ensuremath{{$data[3]}}</xsl:text></common>
		<html><xsl:text disable-output-escaping="yes">&amp;{$name};</xsl:text></html>
		<!-- U+{$data[2]} {$data[0]} -->
		<xhtml><span class="unicode"><xsl:text>{$data[1]}</xsl:text></span></xhtml>
	</template>
	
	<template name="{$name}-strip" match="{$name}|{$data[4]}" mode="strip">
		<common formats="/html/xhtml/">
			<xsl:call-template name="{$name}" />
		</common>
	</template>
	
	<!-- Upper case {$name}. -->
	
	<template name="capital-{$name}" match="{$name}|{$data[9]}">
		<common formats="/latex/xelatex/"><xsl:text>\\ensuremath{{$data[8]}}</xsl:text></common>
		<html><xsl:text disable-output-escaping="yes">&amp;{$upper_name};</xsl:text></html>
		<!-- U+{$data[7]} {$data[5]} -->
		<xhtml><span class="unicode"><xsl:text>{$data[6]}</xsl:text></span></xhtml>
	</template>
	
	<template name="capital-{$name}-strip" match="{$name}|{$data[9]}" mode="strip">
		<common formats="/html/xhtml/">
			<xsl:call-template name="capital-{$name}" />
		</common>
	</template>
	
	

EOT;
}
?>