r87284 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87283‎ | r87284 | r87285 >
Date:19:28, 2 May 2011
Author:thenub314
Status:resolved (Comments)
Tags:brion, math 
Comment:
This update fixes bug 27324 by loading the eurosym package to provide
the euro symbol. This requires the eurosym package be available in
the installed LaTeX distribution. Five new commands are now
recognized by texvc: \euro, \geneuro, \geneuronarrow, \geneurowide,
and \officialeuro. All provide varients of the euro symbol, and \euro
is simply short alias for \officialeuro. In addition some minor
changes have been introduced the html rendering of some math symbols.
The new choices provide html symbols that are higher degree of
similarity in comparison to the corresponding LaTeX symbols.
Modified paths:
  • /trunk/extensions/Math/math/texutil.ml (modified) (history)

Diff [purge]

Index: trunk/extensions/Math/math/texutil.ml
@@ -45,16 +45,19 @@
4646 let modules_nonascii = ref false
4747 let modules_encoding = ref UTF8
4848 let modules_color = ref false
 49+let modules_euro = ref false
4950
5051 (* wrappers to easily set / reset module properties *)
5152 let tex_use_ams () = modules_ams := true
5253 let tex_use_nonascii () = modules_nonascii := true
5354 let tex_use_color () = modules_color := true
 55+let tex_use_euro () = modules_euro := true
5456 let tex_mod_reset () = (
5557 modules_ams := false;
5658 modules_nonascii := false;
5759 modules_encoding := UTF8;
58 - modules_color := false
 60+ modules_color := false;
 61+ modules_euro := false;
5962 )
6063
6164 (* Return TeX fragment for one of the encodings in (UTF8,LATIN1,LATIN2) *)
@@ -68,6 +71,7 @@
6972 (if !modules_nonascii then get_encoding !modules_encoding else "") ^
7073 (if !modules_ams then "\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n" else "") ^
7174 (if !modules_color then "\\usepackage[dvips,usenames]{color}\n" else "") ^
 75+ (if !modules_euro then "\\usepackage{eurosym}\n" else "") ^
7276 "\\usepackage{cancel}\n\\pagestyle{empty}\n\\begin{document}\n$$\n"
7377
7478 (* TeX fragment appended after the content *)
@@ -97,7 +101,7 @@
98102 | "\\epsilon" -> LITERAL (TEX_ONLY "\\epsilon ")
99103 | "\\Epsilon" -> (tex_use_ams (); LITERAL (HTMLABLEC (FONT_UF,
100104 "\\mathrm{E}", "Ε")))
101 - | "\\varepsilon" -> LITERAL (TEX_ONLY "\\varepsilon ")
 105+ | "\\varepsilon" -> LITERAL (HTMLABLEC (FONT_UF, "\\varepsilon ", "ε"))
102106 | "\\zeta" -> LITERAL (HTMLABLEC (FONT_UF, "\\zeta ", "ζ"))
103107 | "\\Zeta" -> (tex_use_ams (); LITERAL (HTMLABLEC (FONT_UF,
104108 "\\mathrm{Z}", "Ζ")))
@@ -142,9 +146,9 @@
143147 "\\mathrm{T}", "Τ")))
144148 | "\\upsilon" -> LITERAL (HTMLABLEC (FONT_UF, "\\upsilon ", "υ"))
145149 | "\\Upsilon" -> LITERAL (HTMLABLEC (FONT_UF, "\\Upsilon ", "Υ"))
146 - | "\\phi" -> LITERAL (TEX_ONLY "\\phi ")
 150+ | "\\phi" -> LITERAL (HTMLABLEC (FONT_UF, "\\phi ", "ϕ"))
147151 | "\\Phi" -> LITERAL (HTMLABLEC (FONT_UF, "\\Phi ", "Φ"))
148 - | "\\varphi" -> LITERAL (TEX_ONLY "\\varphi ")
 152+ | "\\varphi" -> LITERAL (HTMLABLEC (FONT_UF, "\\varphi ", "φ"))
149153 | "\\chi" -> LITERAL (HTMLABLEC (FONT_UF, "\\chi ", "χ"))
150154 | "\\Chi" -> (tex_use_ams (); LITERAL (HTMLABLEC (FONT_UF,
151155 "\\mathrm{X}", "Χ")))
@@ -387,6 +391,11 @@
388392 | "\\asymp" -> LITERAL (TEX_ONLY "\\asymp ")
389393 | "\\doteq" -> LITERAL (TEX_ONLY "\\doteq ")
390394 | "\\parallel" -> LITERAL (TEX_ONLY "\\parallel ")
 395+ | "\\euro" -> (tex_use_euro (); LITERAL (HTMLABLE (FONT_UF, "\\mbox{\\euro}", "€")))
 396+ | "\\geneuro" -> (tex_use_euro (); LITERAL (TEX_ONLY "\\mbox{\\geneuro}"))
 397+ | "\\geneuronarrow" -> (tex_use_euro (); LITERAL (TEX_ONLY "\\mbox{\\geneuronarrow}"))
 398+ | "\\geneurowide" -> (tex_use_euro (); LITERAL (TEX_ONLY "\\mbox{\\geneurowide}"))
 399+ | "\\officialeuro" -> (tex_use_euro (); LITERAL (TEX_ONLY "\\mbox{\\officialeuro}"))
391400 | "\\implies" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\implies ", "⇒")))
392401 | "\\mod" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mod ", "mod")))
393402 | "\\Diamond" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\Diamond ", "◊")))
@@ -395,16 +404,17 @@
396405 | "\\dotsi" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\dotsi ", "⋅⋅⋅")))
397406 | "\\dotsm" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\dotsm ", "⋅⋅⋅")))
398407 | "\\dotso" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\dotso ", "...")))
399 - | "\\reals" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "<b>R</b>")))
400 - | "\\Reals" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "<b>R</b>")))
401 - | "\\R" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "<b>R</b>")))
402 - | "\\C" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "<b>C</b>")))
403 - | "\\cnums" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "<b>C</b>")))
404 - | "\\Complex" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "<b>C</b>")))
405 - | "\\Z" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{Z}", "<b>Z</b>")))
406 - | "\\natnums" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{N}", "<b>N</b>")))
407 - | "\\N" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{N}", "<b>N</b>")))
408 - | "\\Q" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{Q}", "<b>Q</b>")))
 408+ | "\\reals" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "&#8477;")))
 409+ | "\\Reals" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "&#8477;")))
 410+ | "\\R" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "&#8477;")))
 411+ | "\\C" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "&#8450;")))
 412+ | "\\cnums" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "&#8450;")))
 413+ | "\\Complex" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "&#8450;")))
 414+ | "\\Z" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{Z}", "&#8484;")))
 415+ | "\\natnums" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{N}", "&#8469;")))
 416+ | "\\N" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{N}", "&#8469;")))
 417+ | "\\Q" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{Q}", "&#8474;")))
 418+ | "\\H" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{H}", "&#8461;")))
409419 | "\\lVert" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\lVert ", "||")))
410420 | "\\rVert" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\rVert ", "||")))
411421 | "\\nmid" -> (tex_use_ams (); LITERAL (TEX_ONLY "\\nmid "))

Sign-offs

UserFlagDate
Thelema314inspected14:06, 29 August 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r96990Revert changes to texvc that provide no test cases or examples of what they'r...brion19:00, 13 September 2011
r96993MFT r96990: provisional revert of texvc changes that don't come with any test...brion19:07, 13 September 2011
r97007* (bug 27324) \euro support for <math>...brion21:48, 13 September 2011

Comments

#Comment by Hashar (talk | contribs)   06:47, 26 August 2011

tagged 'scap-trap'. Live WMF cluster will require the 'eurosym' package.

#Comment by Reedy (talk | contribs)   10:23, 6 September 2011

rt ticket #1434 has been logged asking for the texlive-fonts-recommended [1] ubuntu package (includes eurosym) to the apaches for Math rendering


[1] http://packages.ubuntu.com/lucid/texlive-fonts-recommended

#Comment by Reedy (talk | contribs)   11:51, 7 September 2011
+              (if !modules_euro then "\\usepackage{eurosym}\n" else "") ^

Will this fallback gracefully? ie If we don't have the package, will these things just not work?

#Comment by Thelema314 (talk | contribs)   12:07, 7 September 2011

That's entirely up to LaTeX and how it's called. I think there's a way to tell it to skip over the error of a package not being available, and also the errors related to the characters needing the eurosym package, although the results will more than likely be broken in some way.

#Comment by Reedy (talk | contribs)   12:08, 7 September 2011

Cheers, shouldn't end up being an issue... It's trivial enough to add another package (especially as it exists in the ubuntu repos etc) so that this will work

#Comment by Thelema314 (talk | contribs)   14:06, 29 August 2011

The euro tweaks are straightforward. I'm not certain about what browsers will do with "&#8477" if some extended font with something resembling \mathbb{R} isn't available. There might be a backwards compatibility issue here.

#Comment by Reedy (talk | contribs)   23:25, 8 September 2011

-scaptrap, already actually installed as part of the textlive-fonts-recommended [1]

reedy@srv193:~$ dpkg -l | grep texlive-fonts-recommended
ii  texlive-fonts-recommended             2007-13ubuntu0.1              TeX Live: Recommended fonts

Fonts

 avantgar -- the URW Avantgar fonts and support for the Adobe font set.
 bookman -- the URW Bookman fonts and support for the Adobe font set.
 charter -- Charter fonts.
 cmextra --
 courier -- Adobe Type 1 "free" copies of Courier.
 euro -- Provide Euro values for national currency amounts.
 euro-ce -- Euro and CE sign font.
 eurofont -- Provides a command that prints a euro symbol.
 eurosans -- Interface to Adobe's sans-serif Euro font.
 eurosym -- MetaFont and macros for Euro sign.
 fpl -- SC and OsF fonts for URW Palladio L
 helvetic -- the URW Helvetiva fonts and support for the Adobe font set.
 marvosym -- Martin Vogel's Symbols (marvosym) font.
 mathpazo -- Fonts to typeset mathematics to match Palatino.
 ncntrsbk -- the URW New Century Schoolbook fonts and support for the Adobe
  font set.
 palatino --
 pxfonts -- Palatino-like fonts in support of mathematics.
 rsfs -- Ralph Smith's Formal Script font.
 symbol --
 times -- Select Adobe Times Roman (or equivalent) as default font.
 timesnew -- the URW Times fonts and support for the Adobe font set.
 txfonts -- Times-like fonts in support of mathematics.
 utopia -- Adobe Utopia fonts.
 wasy -- The wasy fonts (Waldi symbol fonts).
 wasysym -- LaTeX support file to use the WASY2 fonts
 zapfchan -- the URW Zapf Chancery font and support for the Adobe font.
 zapfding -- the URW Zapf Dingbat font and support for the Adobe font.

[1] http://packages.ubuntu.com/natty/texlive-fonts-recommended

#Comment by Brion VIBBER (talk | contribs)   18:45, 13 September 2011

Added needs-parsertest keyword; an example should be added to parser tests to confirm use of \euro works without failing.

#Comment by Brion VIBBER (talk | contribs)   19:04, 13 September 2011

Provisionally reverted in r96990 pending test cases.

#Comment by Brion VIBBER (talk | contribs)   21:33, 13 September 2011

The bits above indicate that \euro should be renderable as HTML, but in my testing it forces PNG output on regular settings. Is this intended?

May need to switch it to HTMLABLEC to mark it as conservative.

Phi changes look ok... varepsilon I think is ok (not sure if there's a standard for the other epsilon form, so ok to leave that as tex-only I guess?). The set number symbols as numeric char entities render ok for me in Firefox / Ubuntu 11.04, but since they're not marked conservative most people probably won't see them rendered that way anyway, so I wouldn't worry too much about compat on those.

#Comment by Brion VIBBER (talk | contribs)   21:51, 13 September 2011

Reapplied in r97007 with parser test cases and a tweak to let \euro render through to HTML in more conservative modes.

Status & tagging log