プロジェクト

全般

プロフィール

Vote #63955

未完了

LaTEX support in Wiki, Forums and Issues

Admin Redmine さんがほぼ2年前に追加. ほぼ2年前に更新.

ステータス:
New
優先度:
通常
担当者:
-
カテゴリ:
Wiki_1
対象バージョン:
-
開始日:
2008/10/06
期日:
進捗率:

0%

予定工数:
category_id:
1
version_id:
0
issue_org_id:
1994
author_id:
2309
assigned_to_id:
0
comments:
41
status_id:
1
tracker_id:
2
plus1:
4
affected_version:
closed_on:
affected_version_id:
ステータス-->[New]

説明

Latex support could be included especially in Wiki pages, so that Latex expressions could be displayed as images in Wiki. Specifically, I want to use Redmine Wiki as means of documentation tool for mathematical methods that are used within a multi-precision library. I could not find a way to display equations in Wiki (Textile does not support mathematical expressions as far as I know)


journals

A new point for a redmine made of modules: since only few users could have need of LaTeX in redmine, it would be marvelous that redmine admins has choice between different plugin to act as wiki.
--------------------------------------------------------------------------------
That would work I think. Another option may be a plugin which enables LaTeX if such a thing is needed. (such as "TracMathPlugin":http://trac-hacks.org/wiki/TracMathPlugin)
--------------------------------------------------------------------------------
I am also interested in this functionality. For the implementation of mathematical models, it is essential to have Math/LaTeX support in Wiki.
--------------------------------------------------------------------------------
Luiz Carlos Junior wrote:
> For the implementation of mathematical models, it is essential to have Math/LaTeX support in Wiki.
I agree.

For one who will write the plugin please look at "jsMath":http://www.math.union.edu/~dpvc/jsMath/. It's fun and simple

--------------------------------------------------------------------------------
+1 for general use of Latex
+1 for choosability as a switch-on/switch-off plugin (but previous +1 is more important. hehe :)
--------------------------------------------------------------------------------
+1 for Latex.
--------------------------------------------------------------------------------
+1 to LaTeX support.

I'm new to Redmine and I really need this kind of feature. I cannot have Nisrael's redmine-wiki_latex_plugin to work.

Anyone knows if there's an important update in this sense?
--------------------------------------------------------------------------------
+1 for Latex.
--------------------------------------------------------------------------------
Anh Kỳ Huỳnh wrote:
> Luiz Carlos Junior wrote:
> > For the implementation of mathematical models, it is essential to have Math/LaTeX support in Wiki.
> I agree.
>
> For one who will write the plugin please look at "jsMath":http://www.math.union.edu/~dpvc/jsMath/. It's fun and simple

I also think that jsMath is way to go!
--------------------------------------------------------------------------------
There already seems to be a redmine plugin which implements this, see http://www.redmine.org/boards/3/topics/4987

I did not test it yet, but wanted to report it now in case I forget to do so after testing.
--------------------------------------------------------------------------------
Regarding note 10. I've developed a plugin using jsmath and mathjax see http://github.com/PeterLawrence/redmine_jsequation_macros
Even thought this renders equations well in wiki pages and issues, it does not function for preview, pdf or atom feeds. It's only really a solution for when you have problems installing the latex plugin, for example on a windows based system.
--------------------------------------------------------------------------------
I like Peter's plugin that uses MathJax (note-11). With MathJax, the displayed equations are beautiful and scalable. I also made changes regarding points raised in note-1 and note-2.

The new plugin (attached as a single file) defines a macro that enables the LaTeX math support via MathJax on a page-by-page basis. For example, <pre>
{{EnableLaTeXMath}}
This is a math equation: \[ x_{1,2} = \frac{-b \pm \sqrt{b^2-4ac}}{2a} \]
</pre> The first line enables math on the page; after that one is free to write LaTeX equations.

Compared to the suggestions in note-10 and note-11, I think this
* is simpler to use (no @{{latex(...)}}@ or @{{mathjax(...)}}@ every time an equation is needed),
* doesn't have problems with line breaks or curly brackets in the equations, and
* naturally supports both inline-style and display-style equations.

And I believe it works for preview too.
--------------------------------------------------------------------------------
I successfully used Ling Li's plugin. While it does correctly working during preview the first time, subsequent previews do not. This appears to be because MathJax's onload handler is only invoked during initial configuration. Subsequent previews are running within the same DOM, and MathJax does not reconfigure itself.

I was able to work around this by explicitly enqueuing a typeset operation from within the script to dynamically load MathJax. This operation will fail (silently) in the usual case that MathJax is being loaded for the first time. There may well be a more elegant way to handle this, but it seems to work.

<pre>
--- vendor/plugins/latex_math/init.rb 2011-04-11 00:48:43.000000000 -0700
+++ vendor/plugins/latex_math_preview_hack/init.rb 2011-04-11 00:48:29.000000000 -0700
@@ -48,6 +48,7 @@
else {script.text = config}

document.getElementsByTagName(\"head\")[0].appendChild(script);
+ try { MathJax.Hub.Queue([\"Typeset\",MathJax.Hub]); } catch (err) {};
})();
//]]>
</script>"
</pre>
--------------------------------------------------------------------------------
I tried Ling's plugin with Phil's patch and it works absolutely great, thanks! What about packaging it up, publishing it on http://www.redmine.org/plugins and closing this ticket?
--------------------------------------------------------------------------------
Btw, is it possible to enable MathJax by default in every page, i.e. without having to type @{{EnableLaTeXMath}}@ each time?
--------------------------------------------------------------------------------
I have created a simple plugin which enabled MathJax for all pages (without typing {{EnableLaTeXMath}}) and also works on previews.

https://github.com/process91/redmine_latex_mathjax

It is admittedly fairly crude in the way that it updates previews; essentially there is a jQuery function which watches the preview div for changes and makes a call to MathJax when it is changed. The inclusion of jQuery could be avoided, I'm only using it for this one purpose, but the bigger performance hit (though it's really theoretical, I don't notice any actual decrease in performance) is that jQuery has to poll repeatedly for changes to the preview box.

Notes about the plugin / things you can modify:
* I wanted the default LaTeX modifiers, so $ and $$ represent inline and display code respectively. You can change this, along with any other "configuration options":http://www.mathjax.org/docs/1.1/configuration.html by editing the file within the hooks/redmine_latex_mathjax/ folder.
* If you don't care about LaTeX in the previews and want to avoid loading jQuery and having the constant polling, simply remove the last three javascript tags from the file within the hooks/redmine_latex_mathjax/ folder.
--------------------------------------------------------------------------------
I forgot to mention, this plugin also styles text in the subject line of issues, comments of commits, basically any text on the whole site. The dollar signs are actually convenient for this, as they are not used frequently otherwise. If you do want to enter a dollar sign explicitly, you can always escape it by putting a backslash before it, but even this is not needed unless two dollar signs appear on the same line.

I really would like to remove the jQuery, however. If anyone knows of a hook that I am unaware of which allows you to modify the text which appears in the body of an issue, I would be able to strip out the jQuery and this plugin (for all uses I can think of anyway) would be complete.
--------------------------------------------------------------------------------
The code seems to work in the preview but not after saving a wiki page. For some reason backslashes get quoted using another backslash, so '\sum' is turned into '\\sum' when saving the page. Any hints on why that is or what needs to be changed in order to avoid it?
--------------------------------------------------------------------------------
Mauro - Was this using the code from my Git repo? What other plugins do you have installed, if any? As you can see below, it is working:

!http://en.zimagez.com/avatar/screenshot-12072011-080208am.png!
--------------------------------------------------------------------------------
Whoops, here's the screenshot:

!http://en.zimagez.com/miniature/screenshot-12072011-080208am.png!
--------------------------------------------------------------------------------
Michael - yes, the code used is a fresh clone from your git repo. Other plugins installed are:

* stuff_to_do_plugin
* timesheet_plugin
* redmine_tab

I uploaded a screenshot "here":https://mauro.just-fellas.org/pub/screenshot.png. The markup used for this is:

<pre>
$\sum x_i$
</pre>

In the preview it is show correctly but whenever I save it, it looks like on the screenshot. I suspect something to escape the '\' when clicking save since when editing the page again the markup saved seems to be

<pre>
$\\sum x_i$
</pre>

--------------------------------------------------------------------------------
That is interesting. When I get a chance, I will install those plugins and see if I get the same result. What version of Redmine are you using?

If you could also test some other things for me, I would appreciate it. Try writing the markup described here:

<pre>
$\int$
</pre>
<pre>
\sum x_i
</pre>
(on the second one I have intentionally not wrapped it in dollar signs)

As you can see "here":http://www.redmine.org/projects/redmine/wiki/Feature_1994, the wiki itself does not normally automatically escape backslashes, so I would be interested to see what your wiki does by default. If you could even uninstall my plugin and try writing @$\sum x_i$@ to see if the backslash is escaped, that would be most helpful.

As a workaround (though I would really like to fix this entirely) you can try wrapping the entire thing within < notextile >< /notextile > tags (without the spaces of course).
--------------------------------------------------------------------------------
Where should I look to see what these plugins do with respect to the formatting of the wiki/textile input? Here's what testing revealed:

* The markup <pre>$\int$</pre> is again saved as <pre>$\\int$</pre> even though it displays correctly in the preview.
* With <pre>\sum x_i</pre> (without the enclosing dollar sign) it also gets stored as <pre>\\sum x_i</pre>
* The same happens with the notextile tags

The version of redmine installed here is 1.2 stable as of this morning, i.e. r8108

It seems that for some reason my wiki really just puts a '\' in front of every '\\' while the normal wiki doesn't do so (as one can see here). I just wonder what causes this. google didn't reveal anything so far, so I'll try asking in IRC.
--------------------------------------------------------------------------------
Michael, after having been unsuccessful on IRC I continued playing around with the plugin and got it fixed. One reason for the phenomenon might have been that I used an old postgres-connector gem. I also uninstalled and reinstalled your plugin, now everything seems to work fine. Alas I can't tell whether it was the database connector or the reinstall but I suspect the database connector to have been the cuplrit.

Either way, for me things seem to work now. Thanks a lot for writing the plugin!
--------------------------------------------------------------------------------
Mauro, glad to hear that it works now. I also suspect the postgres-connector gem, especially since the backslash was escaped even outside the confines of the dollar signs, and escaping backslashes would not be out of the question with regard to a database connector. Good luck to you!
--------------------------------------------------------------------------------
Plugin installed and running perfectly.
Thanks for this very nice plugin, Michael Boratko.
--------------------------------------------------------------------------------
Have installed Michael Boratkos plugin. Worked fine, but hat to add a try-catch to line 52 to make preview work:

File: _view_layouts_base_html_head_hook.rb_
in _plugins/redmine_latex_mathjax/lib/redmine_latex_mathjax/hooks/_
<pre>
Line 52:
- $('#preview').contentChange(function() { MathJax.Hub.Typeset(); } );
+ $('#preview').contentChange(function() { try { MathJax.Hub.Typeset(); } catch (err) {}} );
</pre>

Now it works fine. Thanks for the plugin, Michael.
--------------------------------------------------------------------------------
Thanks for the updated code, Carsten. I have applied your changes to the repo.
--------------------------------------------------------------------------------
Michael Boratko wrote:
> Thanks for the updated code, Carsten. I have applied your changes to the repo.

Is this plugin working on 2.x?

--------------------------------------------------------------------------------
Billy T wrote:
>
> Is this plugin working on 2.x?

Unfortunately I don't have the time to test it out. I imagine it would be, but I don't have a 2.x setup right now. Perhaps you could try it and let us know?
--------------------------------------------------------------------------------
h2. Using MathJax

The most easy way to integrate Latex with Redmine is to integrate "MathJax":http://www.mathjax.org/

You just need to paste these two lines into the file @app/layouts/base.html.erb@
<pre>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});
</script>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
</pre>
and it works perfectly!

I am not familiar with Plugin development, but if its possible to extend the main layout this way, that it would be a very nice, simple and small plugin. :)

--------------------------------------------------------------------------------
Billy T wrote:
> Is this plugin working on 2.x?

It now works on 2.x https://github.com/holidayworking/redmine_latex_mathjax
--------------------------------------------------------------------------------
Michael Boratko wrote:
> Billy T wrote:
> > Is this plugin working on 2.x?
>
> It now works on 2.x https://github.com/holidayworking/redmine_latex_mathjax

No, it doesn't. The original source is still https://github.com/process91/redmine_latex_mathjax , but it was not updated to 2.x. It only needs

<pre><code class="diff">
(09:52:38) [tibirnao@walter]:redmine_latex_mathjax> git diff
diff --git a/init.rb b/init.rb
index d19303c..f3d5be1 100644
--- a/init.rb
+++ b/init.rb
@@ -1,5 +1,5 @@
require 'redmine'
-RAILS_DEFAULT_LOGGER.info 'Redmine LaTeX MathJax'
+::Rails.logger.info 'Redmine LaTeX MathJax'

Redmine::Plugin.register :redmine_latex_mathjax do
name 'Redmine Latex MathJax'

</code></pre>

I sent a pull request.
--------------------------------------------------------------------------------
Thank you, merged.
--------------------------------------------------------------------------------
And all of a sudden, MathJax stopped working on Redmine 2.3.1.

Other versions: Ruby 1.8.7, Rails 3.2.13, redmine_latex_mathjax 0.1.0.

I didn't notice immediately that it doesn't work anymore. It might be due to one of the updates in the last 7 months. There is no error in the redmine log, nor anywhere else I could look at.

Does anybody use MathJax successfully with Redmine 2.3.1?
--------------------------------------------------------------------------------
And all of a sudden, MathJax stopped working on Redmine 2.3.1.

Other versions: Ruby 1.8.7, Rails 3.2.13, redmine_latex_mathjax 0.1.0.

I didn't notice immediately that it doesn't work anymore. It might be due to one of the updates in the last 7 months. There is no error in the redmine log, nor anywhere else I could look at.

Does anybody use MathJax successfully with Redmine 2.3.1?
--------------------------------------------------------------------------------
MathJax also stopped working on our Redmine 1.4.4 (approx two weeks ago).

So it might be related to MathJax itself?
--------------------------------------------------------------------------------
I believe this is fixed now. The problem was that I had used an unofficial link for the MathJax javascript (I'm not sure why I had done that). In any event, it seems this unofficial source no longer hosts MathJax. A user "crax" on GitHub had pointed this out and corrected the link to use the official CDN, and I just merged his changes so things should now be working. Please update the plugin and let me know if there is still an issue. Sorry for the latency in my reply.
--------------------------------------------------------------------------------
For the record, and as reported on "Github":https://github.com/process91/redmine_latex_mathjax/issues/6, there seems to be an issue (?) with redmine 2.4.2. Anyone has it working with 2.4.2?
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

Admin Redmine さんがほぼ2年前に更新

  • カテゴリWiki_1 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0