aiyuyun2015 / wiki2latex

Automatically exported from code.google.com/p/wiki2latex
0 stars 0 forks source link

:<math></math> as displaymath #54

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
It would be great if w2l would parse indented math blocks as displaymath.

Example:

:<math>x</math>

becomes

\begin{displaymath}
x
\end{displaymath}

Original issue reported on code.google.com by cjia...@gmail.com on 4 Jan 2010 at 9:09

GoogleCodeExporter commented 8 years ago
I think, that this might not be possible. There are no means to check for nested
math-tags.

There might be a possibility though: It might be possible to add an attribute to
math, something like <math displaymath="yes">...</math> This way the 
w2l-function
would be able to set the proper math-environment.

But I don't know if that would lead to compatibility-issues on mediawiki's side.
This, however, should easily be testable.

Original comment by hansgeorg.kluge@gmail.com on 4 Jan 2010 at 10:22

GoogleCodeExporter commented 8 years ago
I used your idea to add an attribute to the math tag, but from within w2l.

This is a hacky way to do it, but it works for me:

1. in w2lParser.php, in parse(), just after the check to do initParsing:

add the line

$text = str_replace(":<math>", "<math style=\"display\">", $text);

2. in contrib/math.php, redefine the w2lMath function as

function w2lMath($input, $argv, &$parser, $mode = 'latex') {

                if ( $argv['style'] == 'display' ) {
                        $output  = "\n\begin{equation}\n";
                        $output .= trim($input)."\n";
                        $output .= "\end{equation}\n";
                } else {
                        $output  = "\n\begin{math}\n";
                        $output .= trim($input)."\n";
                        $output .= "\end{math}\n";
                }
                return $output;
        }

Hope you find this useful.

Original comment by cjia...@gmail.com on 10 Jan 2010 at 7:13

GoogleCodeExporter commented 8 years ago
I added this to math.php. The replace of :<math> takes place in a hook 
function, so there is no need to edit w2lParser.php :)

Thank you very much

Original comment by hansgeorg.kluge@gmail.com on 29 Aug 2010 at 9:44

GoogleCodeExporter commented 8 years ago

Original comment by hansgeorg.kluge@gmail.com on 29 Aug 2010 at 9:44

GoogleCodeExporter commented 8 years ago

Original comment by hansgeorg.kluge@gmail.com on 29 Aug 2010 at 10:22