Open Grahack opened 9 years ago
I'm afraid I'm not familiar enough with the dokuwiki internals either, and I'm not sure what's going on there. Your understanding matches mine, but clearly we're missing something. You could try to change the return value of getType
in the mathjax plugin from protected
to disabled
, and let me know if that helps. Unfortunately, I don't see any other issue given my limited understanding of dokuwiki's parsing.
Same happened for me. In my case, changing return value of getType
to 'formatting'
magically solved the issue (changing to disabled
didn't help).
First, this problem happens only if I use two or more underscores in math in a bulleted line. I guess this problem is caused by both italic style (surrounded by underscores) and unordered list (lines starting with a *
).
For example, * $x_0$
is okay, but * $x_0, y_0$
has the problem.
Another speculation of mine is that the meaning of getType
's return value is that, in which types of parser modes this plugin should be accepted, rather than which types of modes this plugin wants to accept.
So, this is probably what's happening:
ulists
syntax plugin finds a line of text beginning with an asterisk *
.ulists
enters the mode plugin_markdowku_ulists
which do not accept protected
modes. (see /plugins/markdowku/syntax/ulists.php)syntax_plugin_mathjax_protecttex.getType()
returns protected
, MathJax protection is not invoked.italicunderline
syntax is invoked, which destroys the LaTex markups.The return value of getSort
doesn't matter because unordered list container (between *
and \n
) is larger than the math, so the unordered list is always processed first.
The problem is that markdowku overrides both underscores and unordered lists, which makes the situation complicated and hard to debug.
Considering the true purpose, I think syntax_plugin_mathjax_protecttex.getType()
should return formatting
, but I'm not sure if it has any negative side-effects. I love both plugins (I use lots of maths in my DokuWiki), so I wish this issue to have been fixed.
The formatting
trick did it for me too. Thanks.
I leave this issue open until the code is updated and/or the trick tripled checked.
Cheers.
Thanks for digging into this and figuring it out. From the syntax plugin documentation and its base code, it looks to me like getType()
should return the parser mode that the plugin is. And of the types available, protected
seems the most appropriate for this plugin. Isn't the proper fix then for markdowku's ulists
module to add protected
to its list of allowed types?
Protected blocks (like <file>
) can be placed in list items in plain Dokuwiki syntax, anyway, so I don't see a problem with allowing the protected type in ulists
. If I understand correctly, markdowku doesn't allow for <file>
blocks, etc. to be placed in unordered lists -- while Dokuwiki itself does -- which would also seem to be an issue.
I see no negative side-effects of your fix myself, but I want to find the most appropriate fix for this. I think that fix is to add 'protected' to the allowed types in markdowku's ulists
. Does that sound right to you? If so, we can report it to markdowku's author.
Yes, adding protected
to the return value of syntax_plugin_markdowku_ulists
's getAllowedTypes
method like below also fixed the problem.
function getAllowedTypes() {
return array('formatting', 'substition', 'paragraphs', 'baseonly', 'container', 'protected');
}
I also checked the source of standard DokuWiki syntax for unordered lists. Like you said, the standard syntax accepts protected
, although I have no idea what #XXX new
means in the source comment.
dokuwiki/inc/parser/parser.php (462):
class Doku_Parser_Mode_listblock extends Doku_Parser_Mode {
function Doku_Parser_Mode_listblock() {
global $PARSER_MODES;
$this->allowedModes = array_merge (
$PARSER_MODES['formatting'],
$PARSER_MODES['substition'],
$PARSER_MODES['disabled'],
$PARSER_MODES['protected'] #XXX new
);
// $this->allowedModes[] = 'footnote';
}
I'm still not sure which plugin should be fixed. I agree that MathJax markup should not include any other DokuWiki syntax, but it's determined solely by MathJax plugin's getAllowedTypes
(which returns empty array, derived from DokuWiki_Syntax_Plugin class), not by the return value of getType
. getType
affects only the other syntaxes which may contain a MathJax markup. I mean, it feels more like a formatting syntax from other plugins' perspective.
That said, I'm inclined to fixing markdowku side, because it's at least not consistent with standard syntax.
Hi, I use this markdown plugin on my DW instance and wanted to try your MathJax plugin. There seem to be a problem with underscores. I do not claim that this is a bug in your plugin, but ask for some help!
I already tried to tweak the
getSort
value with no luck. I'm not strong enough in DW internals to fully understand the problem. The markdown plugin has 20+ files with differentgetSort
values, ranging from 8 to 219. If I understand correctly,getType
returningprotected
should prevent this very problem.You can try yourself to tweak a page where both are installed: http://galerie.microalg.info/profgra:tests:mathjax