- Modularised Greek characters.
- Added PHP script for generating Greek character templates.
1 parent b0fefd3 commit 67e2807965011367fdc48223a4e5df6aa50ec0e9
nstanger authored on 29 Aug 2011
Showing 3 changed files
View
134
format-master.xml
<common formats="/html/xhtml/">
<xsl:call-template name="right-curly-bracket" />
</common>
</template>
 
<!-- I think the pi symbol is only available in LaTeX in math mode, but if we're already in math mode, the extra $ signs will mess things up... -->
<!-- Use \ensuremath to resolve the problem. -->
<template name="epsilon" match="epsilon|greek-small-letter-epsilon">
<common formats="/latex/xelatex/">\ensuremath{\epsilon}</common>
<html><xsl:text disable-output-escaping="yes">&amp;epsilon;</xsl:text></html>
<!-- U+03B5 GREEK SMALL LETTER EPSILON -->
<xhtml><span class="unicode"><xsl:text>ε</xsl:text></span></xhtml>
</template>
 
<template name="epsilon-strip" match="epsilon|greek-small-letter-epsilon" mode="strip">
<common formats="/html/xhtml/">
<xsl:call-template name="epsilon" />
</common>
</template>
 
<template name="pi" match="pi|greek-small-letter-pi">
<common formats="/latex/xelatex/">\ensuremath{\pi}</common>
<html><xsl:text disable-output-escaping="yes">&amp;pi;</xsl:text></html>
<!-- U+03C0 GREEK SMALL LETTER PI -->
<xhtml><span class="unicode"><xsl:text>π</xsl:text></span></xhtml>
</template>
 
<template name="pi-strip" match="pi|greek-small-letter-pi" mode="strip">
<common formats="/html/xhtml/">
<xsl:call-template name="pi" />
</common>
</template>
 
<template name="rho" match="rho|greek-small-letter-rho">
<common formats="/latex/xelatex/">\ensuremath{\rho}</common>
<html><xsl:text disable-output-escaping="yes">&amp;rho;</xsl:text></html>
<!-- U+03C1 GREEK SMALL LETTER RHO -->
<xhtml><span class="unicode"><xsl:text>ρ</xsl:text></span></xhtml>
</template>
 
<template name="rho-strip" match="rho|greek-small-letter-rho" mode="strip">
<common formats="/html/xhtml/">
<xsl:call-template name="rho" />
</common>
</template>
 
<template name="sigma" match="sigma|greek-small-letter-sigma">
<common formats="/latex/xelatex/">\ensuremath{\sigma}</common>
<html><xsl:text disable-output-escaping="yes">&amp;sigma;</xsl:text></html>
<!-- U+03C3 GREEK SMALL LETTER SIGMA -->
<xhtml><span class="unicode"><xsl:text>σ</xsl:text></span></xhtml>
</template>
 
<template name="sigma-strip" match="sigma|greek-small-letter-sigma" mode="strip">
<common formats="/html/xhtml/">
<xsl:call-template name="sigma" />
</common>
</template>
 
<template name="capital-phi" match="Phi|greek-capital-letter-phi">
<common formats="/latex/xelatex/">\ensuremath{\Phi}</common>
<html><xsl:text disable-output-escaping="yes">&amp;Phi;</xsl:text></html>
<!-- U+03A6 GREEK CAPITAL LETTER PHI -->
<xhtml><span class="unicode"><xsl:text>Φ</xsl:text></span></xhtml>
</template>
<template name="capital-phi-strip" match="Phi|greek-capital-letter-phi" mode="strip">
<common formats="/html/xhtml/">
<xsl:call-template name="capital-phi" />
</common>
</template>
<!-- Greek characters. -->
<include href="modules/greek-characters.xml" />
 
<template name="empty-set-sign" match="empty-set-sign|empty-set|null">
<common formats="/latex/xelatex/">\ensuremath{\emptyset}</common>
<html><xsl:text disable-output-escaping="yes">&amp;empty;</xsl:text></html>
View
74
modules/generate-greek.php 0 → 100755
<?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/">\\ensuremath{{$data[3]}}</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/">\\ensuremath{{$data[8]}}</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;
}
?>
View
modules/greek-characters.xml 0 → 100755