From c85ce458ce59b0ef530881919154f333b64cbccb Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Tue, 24 Mar 2009 22:37:58 -0500 Subject: [PATCH] Update for itex2MML 1.38 Add support, in the LaTeX export, for blackboard bold digits and lowercase latin letters. If these are present, LaTeX will \usepackage{mathbbol} N.B.: this uses the stmaryrd font for blackboard bold letters, instead of the msbm font. Tests included. (Yes, you need to update itex2MML as well.) --- app/views/wiki/tex.rhtml | 3 +++ test/functional/wiki_controller_test.rb | 36 ++++++++++++++++++++----- test/unit/page_renderer_test.rb | 6 +++++ 3 files changed, 38 insertions(+), 7 deletions(-) diff --git a/app/views/wiki/tex.rhtml b/app/views/wiki/tex.rhtml index d1d6a733..c4b5563c 100644 --- a/app/views/wiki/tex.rhtml +++ b/app/views/wiki/tex.rhtml @@ -4,6 +4,9 @@ \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsthm} +<%- if @tex_content =~ /\\mathbb\{[^}]*[a-z0-9]+[^}]*\}/ -%> +\usepackage{mathbbol} +<% end -%> \usepackage{graphicx} \usepackage{color} \usepackage{ucs} diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 81a9d2a3..ffce37d5 100755 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -31,6 +31,7 @@ class WikiControllerTest < ActionController::TestCase @oak = pages(:oak) @elephant = pages(:elephant) @eternity = Regexp.new('author=.*; path=/; expires=' + Time.utc(2030).strftime("%a, %d-%b-%Y %H:%M:%S GMT")) + set_tex_header end def test_authenticate @@ -849,17 +850,15 @@ class WikiControllerTest < ActionController::TestCase assert_response :missing end - def test_tex - r = process('tex', 'web' => 'wiki1', 'id' => 'HomePage') - assert_response(:success) - - assert_equal %q!\documentclass[12pt,titlepage]{article} + def set_tex_header + @tex_header1 = %q!\documentclass[12pt,titlepage]{article} \usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsthm} -\usepackage{graphicx} +! + @tex_header2 = %q!\usepackage{graphicx} \usepackage{color} \usepackage{ucs} \usepackage[utf8x]{inputenc} @@ -1084,7 +1083,14 @@ class WikiControllerTest < ActionController::TestCase %------------------------------------------------------------------- -\section*{HomePage} +! + end + + def test_tex + r = process('tex', 'web' => 'wiki1', 'id' => 'HomePage') + assert_response(:success) + + assert_equal @tex_header1 + @tex_header2 + %q!\section*{HomePage} HisWay would be MyWay $\sin(x) \includegraphics[width=3em]{foo}$ in kinda ThatWay in HisWay though MyWay $\backslash$OverThere --{} see SmartEngine in that SmartEngineGUI @@ -1094,6 +1100,22 @@ HisWay would be MyWay $\sin(x) \includegraphics[width=3em]{foo}$ in kinda ThatWa !, r.body end + def test_tex_with_blackboard_digits + @wiki.write_page('wiki1', 'Page2', + "Page2 contents $\\mathbb{01234}$.\n", + Time.now, Author.new('AnotherAuthor', '127.0.0.2'), test_renderer) + r = process('tex', 'web' => 'wiki1', 'id' => 'Page2') + assert_response(:success) + + assert_equal @tex_header1 + "\\usepackage{mathbbol}\n" + @tex_header2 + %q!\section*{Page2} + +Page2 contents $\mathbb{01234}$. + + + +\end{document} +!, r.body + end def test_web_list another_wiki = @wiki.create_web('Another Wiki', 'another_wiki') diff --git a/test/unit/page_renderer_test.rb b/test/unit/page_renderer_test.rb index 4595fdee..d5791cea 100644 --- a/test/unit/page_renderer_test.rb +++ b/test/unit/page_renderer_test.rb @@ -213,6 +213,12 @@ END_THM %{display='inline' xmlns='http://www.w3.org/1998/Math/MathML'>} + %{A\342\205\213B

}, "equation $A \\invamp B$") + + assert_markup_parsed_as( + %{

blackboard digits: math} + + %{bb123

}, + "blackboard digits: $\mathbb{123}$") end def test_blahtex