r97007 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97006‎ | r97007 | r97008 >
Date:21:48, 13 September 2011
Author:brion
Status:ok
Tags:
Comment:
* (bug 27324) \euro support for <math>

Reapplied r87284 with a tweak to allow \euro through to conservative HTML output.
Parser test case added to confirm that \euro is HTMLable and the other euro variants are renderable to images.

This commit also includes tweaks to HTMLification of \phi, \varphi, and \varepsilon (conservative HTML) and changes the non-conservative HTMLification of number sets from plain letters to the dedicated Unicode chars for their symbols. These changes are not included in tests, but don't alter what input is supported.
Modified paths:
  • /trunk/extensions/Math/math/texutil.ml (modified) (history)
  • /trunk/extensions/Math/mathParserTests.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/Math/mathParserTests.txt
@@ -50,3 +50,19 @@
5151 </p>
5252 !! end
5353
 54+!! test
 55+BUG 27324: Euro symbol for math
 56+!! input
 57+<math>\euro 200</math>
 58+<math>\geneuro</math>
 59+<math>\geneuronarrow</math>
 60+<math>\geneurowide</math>
 61+<math>\officialeuro</math>
 62+!! result
 63+<p><span class="texhtml" dir="ltr">&#8364;200</span>
 64+<img class="tex" alt="\geneuro" src="/images/math/9/8/b/98b63c235ee187a38267e0e170b10e9d.png" />
 65+<img class="tex" alt="\geneuronarrow" src="/images/math/a/a/4/aa4a1ed370f4ee705c6930384bf89502.png" />
 66+<img class="tex" alt="\geneurowide" src="/images/math/4/4/0/4404468e6187fb04e4f7e1f15e550825.png" />
 67+<img class="tex" alt="\officialeuro" src="/images/math/d/7/0/d708de0eed23dbd6f02b99ea9073547b.png" />
 68+</p>
 69+!! end
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}", "&Epsilon;")))
101 - | "\\varepsilon" -> LITERAL (TEX_ONLY "\\varepsilon ")
 105+ | "\\varepsilon" -> LITERAL (HTMLABLEC (FONT_UF, "\\varepsilon ", "&epsilon;"))
102106 | "\\zeta" -> LITERAL (HTMLABLEC (FONT_UF, "\\zeta ", "&zeta;"))
103107 | "\\Zeta" -> (tex_use_ams (); LITERAL (HTMLABLEC (FONT_UF,
104108 "\\mathrm{Z}", "&Zeta;")))
@@ -142,9 +146,9 @@
143147 "\\mathrm{T}", "&Tau;")))
144148 | "\\upsilon" -> LITERAL (HTMLABLEC (FONT_UF, "\\upsilon ", "&upsilon;"))
145149 | "\\Upsilon" -> LITERAL (HTMLABLEC (FONT_UF, "\\Upsilon ", "&Upsilon;"))
146 - | "\\phi" -> LITERAL (TEX_ONLY "\\phi ")
 150+ | "\\phi" -> LITERAL (HTMLABLEC (FONT_UF, "\\phi ", "&#981;"))
147151 | "\\Phi" -> LITERAL (HTMLABLEC (FONT_UF, "\\Phi ", "&Phi;"))
148 - | "\\varphi" -> LITERAL (TEX_ONLY "\\varphi ")
 152+ | "\\varphi" -> LITERAL (HTMLABLEC (FONT_UF, "\\varphi ", "&phi;"))
149153 | "\\chi" -> LITERAL (HTMLABLEC (FONT_UF, "\\chi ", "&chi;"))
150154 | "\\Chi" -> (tex_use_ams (); LITERAL (HTMLABLEC (FONT_UF,
151155 "\\mathrm{X}", "&Chi;")))
@@ -419,6 +423,11 @@
420424 | "\\asymp" -> LITERAL (TEX_ONLY "\\asymp ")
421425 | "\\doteq" -> LITERAL (TEX_ONLY "\\doteq ")
422426 | "\\parallel" -> LITERAL (TEX_ONLY "\\parallel ")
 427+ | "\\euro" -> (tex_use_euro (); LITERAL (HTMLABLEC (FONT_UF, "\\mbox{\\euro}", "&euro;")))
 428+ | "\\geneuro" -> (tex_use_euro (); LITERAL (TEX_ONLY "\\mbox{\\geneuro}"))
 429+ | "\\geneuronarrow" -> (tex_use_euro (); LITERAL (TEX_ONLY "\\mbox{\\geneuronarrow}"))
 430+ | "\\geneurowide" -> (tex_use_euro (); LITERAL (TEX_ONLY "\\mbox{\\geneurowide}"))
 431+ | "\\officialeuro" -> (tex_use_euro (); LITERAL (TEX_ONLY "\\mbox{\\officialeuro}"))
423432 | "\\implies" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\implies ", "&rArr;")))
424433 | "\\mod" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mod ", "mod")))
425434 | "\\Diamond" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\Diamond ", "&loz;")))
@@ -427,16 +436,17 @@
428437 | "\\dotsi" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\dotsi ", "&sdot;&sdot;&sdot;")))
429438 | "\\dotsm" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\dotsm ", "&sdot;&sdot;&sdot;")))
430439 | "\\dotso" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\dotso ", "...")))
431 - | "\\reals" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "<b>R</b>")))
432 - | "\\Reals" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "<b>R</b>")))
433 - | "\\R" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "<b>R</b>")))
434 - | "\\C" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "<b>C</b>")))
435 - | "\\cnums" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "<b>C</b>")))
436 - | "\\Complex" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "<b>C</b>")))
437 - | "\\Z" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{Z}", "<b>Z</b>")))
438 - | "\\natnums" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{N}", "<b>N</b>")))
439 - | "\\N" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{N}", "<b>N</b>")))
440 - | "\\Q" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{Q}", "<b>Q</b>")))
 440+ | "\\reals" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "&#8477;")))
 441+ | "\\Reals" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "&#8477;")))
 442+ | "\\R" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "&#8477;")))
 443+ | "\\C" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "&#8450;")))
 444+ | "\\cnums" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "&#8450;")))
 445+ | "\\Complex" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "&#8450;")))
 446+ | "\\Z" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{Z}", "&#8484;")))
 447+ | "\\natnums" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{N}", "&#8469;")))
 448+ | "\\N" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{N}", "&#8469;")))
 449+ | "\\Q" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{Q}", "&#8474;")))
 450+ | "\\H" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{H}", "&#8461;")))
441451 | "\\lVert" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\lVert ", "||")))
442452 | "\\rVert" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\rVert ", "||")))
443453 | "\\nmid" -> (tex_use_ams (); LITERAL (TEX_ONLY "\\nmid "))

Follow-up revisions

RevisionCommit summaryAuthorDate
r97259REL1_18 MFT r97001, r97002, r97007, r97014, r97018, r97034reedy13:06, 16 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r87284This update fixes bug 27324 by loading the eurosym package to provide...thenub31419:28, 2 May 2011
r96990Revert changes to texvc that provide no test cases or examples of what they'r...brion19:00, 13 September 2011

Status & tagging log