[LON-CAPA-cvs] cvs: loncom /interface entities.pm
foxr
lon-capa-cvs-allow@mail.lon-capa.org
Wed, 09 Apr 2008 10:24:33 -0000
foxr Wed Apr 9 06:24:33 2008 EDT
Modified files:
/loncom/interface entities.pm
Log:
Got the table finished...coding the translation subs.
Index: loncom/interface/entities.pm
diff -u loncom/interface/entities.pm:1.4 loncom/interface/entities.pm:1.5
--- loncom/interface/entities.pm:1.4 Tue Apr 1 06:45:44 2008
+++ loncom/interface/entities.pm Wed Apr 9 06:24:32 2008
@@ -837,10 +837,90 @@
8863 => '\\ensuremath\{\\boxminus\}',
8864 => '\\ensuremath\{\\boxtimes\}',
8865 => '\\ensuremath\{\\boxdot\}',
-
-
-
-
+ 'vdash' => '\\ensuremath\{\\vdash\}',
+ 8866 => '\\ensuremath\{\\vdash\}',
+ 'dashv' => '\\ensuremath\{\\dashv\}',
+ 8867 => '\\ensuremath\{\\dashv\}',
+ 'perp' => '\\ensuremath\{\\perp\}',
+ 8869 => '\\ensuremath\{\\perp\}',
+ 8871 => '\\ensuremath\{\\models\}',
+ 8872 => '\\ensuremath\{\\vDash\}',
+ 8873 => '\\ensuremath\{\\Vdash\}',
+ 8874 => '\\ensuremath\{\\Vvdash\}',
+ 8876 => '\\ensuremath\{\\nvdash\}',
+ 8877 => '\\ensuremath\{\\nvDash\}',
+ 8878 => '\\ensuremath\{\\nVdash\}',
+ 8880 => '\\ensuremath\{\\prec\}',
+ 8881 => '\\ensuremath\{\\succ\}',
+ 8882 => '\\ensuremath\{\\vartriangleleft\}',
+ 8883 => '\\ensuremath\{\\vartriangleright\}',
+ 8884 => '\\ensuremath\{\\trianglelefteq\}',
+ 8885 => '\\ensuremath\{\\trianglerighteq\}',
+ 8891 => '\\ensuremath\{\\veebar\}',
+ 8896 => '\\ensuremath\{\\land\}',
+ 8897 => '\\ensuremath\{\\lor\}',
+ 8898 => '\\ensuremath\{\\cap\}',
+ 8899 => '\\ensuremath\{\\cup\}',
+ 8900 => '\\ensuremath\{\\diamond\}',
+ 'sdot' => '\\ensuremath\{\\cdot\}',
+ 8901 => '\\ensuremath\{\\cdot\}',
+ 8902 => '\\ensuremath\{\\star\}',
+ 8903 => '\\ensuremath\{\\divideontimes\}',
+ 8904 => '\\ensuremath\{\\bowtie\}',
+ 8905 => '\\ensuremath\{\\ltimes\}',
+ 8906 => '\\ensuremath\{\\rtimes\}',
+ 8907 => '\\ensuremath\{\\leftthreetimes\}',
+ 8908 => '\\ensuremath\{\\rightthreetimes\}',
+ 8909 => '\\ensuremath\{\\simeq\}',
+ 8910 => '\\ensuremath\{\\curlyvee\}',
+ 8911 => '\\ensuremath\{\\curlywedge\}',
+ 8912 => '\\ensuremath\{\\Subset\}',
+ 8913 => '\\ensuremath\{\\Supset\}',
+ 8914 => '\\ensuremath\{\\Cap\}',
+ 8915 => '\\ensuremath\{\\Cup\}',
+ 8916 => '\\ensuremath\{\\pitchfork\}',
+ 8918 => '\\ensuremath\{\\lessdot\}',
+ 8919 => '\\ensuremath\{\\gtrdot\}',
+ 8920 => '\\ensuremath\{\\lll\}',
+ 8921 => '\\ensuremath\{\\ggg\}',
+ 8922 => '\\ensuremath\{\\gtreqless\}',
+ 8923 => '\\ensuremath\{\\lesseqgtr\}',
+ 8924 => '\\ensuremath\{\\eqslantless\}',
+ 8925 => '\\ensuremath\{\\eqslantgtr\}',
+ 8926 => '\\ensuremath\{\\curlyeqprec\}',
+ 8927 => '\\ensuremath\{\\curlyeqsucc\}',
+ 8928 => '\\ensuremath\{\\not\\preccurlyeq\}',
+ 8929 => '\\ensuremath\{\\not\\succurlyeq\}',
+ 8930 => '\\ensuremath\{\\not\\sqsupseteq\}',
+ 8931 => '\\ensuremath\{\\not\\sqsubseteq\}',
+ 8938 => '\\ensuremath\{\\not\\vartriangleleft\}',
+ 8939 => '\\ensuremath\{\\not\vartriangleright\}',
+ 8940 => '\\ensuremath\{\\not\trianglelefteq\}',
+ 8941 => '\\ensuremath\{\\not\trianglerighteq\}',
+ 8942 => '\\ensuremath\{\\vdots\}',
+ 8960 => '\\ensuremath\{\\varnothing\}',
+ 'lceil' => '\\ensuremath\{\\lceil\}',
+ 8968 => '\\ensuremath\{\\lceil\}',
+ 'rceil' => '\\ensuremath\{\\rceil\}',
+ 8969 => '\\ensuremath\{\\rceil\}',
+ 'lfloor' => '\\ensuremath\{\\lfloor\}',
+ 8970 => '\\ensuremath\{\\lfloor\}',
+ 'rfloor' => '\\ensuremath\{\\rfloor}',
+ 8971 => '\\ensuremath\{\\rfloor}',
+ 'lang' => '\\ensuremath\{\\langle\}',
+ 9001 => '\\ensuremath\{\\langle\}',
+ 'rang' => '\\ensuremath\{\\rangle\}',
+ 9002 => '\\ensuremath\{\\rangle\}',
+ 'loz' => '\\ensuremath\{\\lozenge\}',
+ 9674 => '\\ensuremath\{\\lozenge\}',
+ 'spades' => '\\ensuremath\{\\spadesuit\}',
+ 9824 => '\\ensuremath\{\\spadesuit\}',
+ 9825 => '\\ensuremath\{\\heartsuit\}',
+ 9826 => '\\ensuremath\{\\diamondsuit\}',
+ 'clubs' => '\\ensuremath\{\\clubsuit\}',
+ 9827 => '\\ensuremath\{\\clubsuit\}',
+ 'diams' => '\\ensuremath\{\\blacklozenge\}',
+ 9830 => '\\ensuremath\{\\blacklozenge\}'
};
@@ -850,7 +930,16 @@
# This allows us to support, to some extent, any entity for which
# dvipdf can find a gylph (given that LaTeX is now UTF-8 clean).
#
+# Parameters:
+# unicode - The unicode for the character. This is assumed to
+# be a decimal value
+# Returns:
+# The UTF-8 equiavalent of the value.
+#
sub entity_to_utf8 {
+ my ($unicode) = @_;
+
+ return pack("U", $unicode);
}
@@ -861,6 +950,52 @@
# to UTF-8 which should display as long as dvipdf can find the
# appropriate glyph.
#
+# The entity is assumed to have already had the
+# &# ; or & ; removed
+#
+# Parameters:
+# entity - Name of entity to convert.
+# Returns:
+# One of the following:
+# - Latex string that produces the entity.
+# - UTF-8 equivalent of a numeric entity for which we don't have a latex string.
+# - ' ' for text entities for which there's no latex equivalent.
+#
sub entity_to_latex {
+ my ($entity) = @_;
+
+ # Try to look up the entity (text or numeric) in the hash:
+
+ my $latex = $entities{$entity};
+ if ($latex) {
+ return $latex;
+ }
+ # If the text is purely numeric we can do the UTF-8 conversion:
+
+ if ($entity =~ /^\d$/) {
+ return &entity_to_utf8($entity);
+ }
+ # Can't do the conversion ...
+
+ return " ";
+}
+
+#
+# Convert all the entities in a string.
+# We locate all the entities, pass them into entity_to_latex and
+# and replace occurences in the input string.
+# The assumption is that there are few entities in any string/document
+# so this looping is not too bad. The advantage of looping vs. regexping is
+# that we now can use lookup tables for the translation in entity_to_latex above.
+#
+# Parameters:
+# input - Input string/document
+# Returns
+# input with entities replaced by latexable stuff (UTF-8 encodings or
+# latex control strings to produce the entity.
+#
+#
+sub replace_entities {
+ my ($input) = @_;
}