newcommand strange behaviour
Closed, ResolvedPublic

Description

wrong newcommand preparsing:

the directive

\newcommand{\ol}{\overline}

transforms

$\ol{D(z_0,r)}$

into

<math>\overline</math>

but the correct output should be

<math>\overline{D(z_0,r)}</math>

In LaTeX it properly works.

Edit: changing the aforementioned latex directive into

\newcommand{\ol}[1]{\overline{#1}}

texla properly wokrs and returns

<math>\overline{ D(z_0,r) }</math>

If we have to manually change the \def directive into \newcommand we can see how the command is used and adapt the \newcommand definition, but we may encounter someone who uses the \newcommand directive in the concise way, and that would break mediawiki. We have to adapt how newcommand is preparsed, and it will be a bit tough

I have to check if the presence of the number of arguments [n] is necessary.

ruphy edited projects, added Restricted Project; removed Restricted Project.Jan 10 2017, 2:15 PM
ruphy edited projects, added WikiToLearn: TeXLa; removed Restricted Project.Jan 10 2017, 2:31 PM
davidev added a comment.EditedJan 17 2017, 11:31 PM

The problem here is that the MacroParser always searches for arguments when it reads the newcommand command. With

\newcommand{\ol}{\overline}

it doesn't see arguments.
When the MacroParser then replaced the macro the argument of \ol{x,y,} are not read because it thinks that \ol doesn't need arguments.

I have to understand how to handle this case... that is a simple replace.
It is difficult to insert it in the actual workflow

davidev raised the priority of this task from Normal to High.Mar 2 2017, 4:32 PM

Now the macros without parameters are considered differently by the preparser. They are simply replaced.