kuenzign / WikiMarkdown

MediaWiki extension that allows for markdown syntax to be used on wiki pages
https://www.mediawiki.org/wiki/Extension:WikiMarkdown
MIT License
12 stars 9 forks source link

Call to undefined method mathTagHook() #6

Open Subilan opened 2 years ago

Subilan commented 2 years ago

With Math enabled, if I save the page with $$ section in <markdown>, the page will be like this:

[cc9dd1222bfb599d83029366] /index.php?title=%E6%96%87%E6%9C%AC%E6%A0%B7%E5%BC%8F%E7%A4%BA%E4%BE%8B&action=submit Error: Call to undefined method MediaWiki\Extension\Math\Hooks::mathTagHook()

Backtrace:

from /home/wwwroot/wiki/extensions/WikiMarkdown/includes/WikiMarkdown.php(155)
#0 [internal function]: WikiMarkdown::{closure}()
#1 /home/wwwroot/wiki/extensions/WikiMarkdown/includes/WikiMarkdown.php(157): preg_replace_callback()
#2 /home/wwwroot/wiki/includes/parser/Parser.php(3979): WikiMarkdown::parserHook()
#3 /home/wwwroot/wiki/includes/parser/PPFrame_Hash.php(353): Parser->extensionSubstitution()
#4 /home/wwwroot/wiki/includes/parser/Parser.php(2932): PPFrame_Hash->expand()
#5 /home/wwwroot/wiki/includes/parser/Parser.php(1579): Parser->replaceVariables()
#6 /home/wwwroot/wiki/includes/parser/Parser.php(697): Parser->internalParse()
#7 /home/wwwroot/wiki/includes/content/WikitextContentHandler.php(294): Parser->parse()
#8 /home/wwwroot/wiki/includes/content/ContentHandler.php(1705): WikitextContentHandler->fillParserOutput()
#9 /home/wwwroot/wiki/includes/content/Renderer/ContentRenderer.php(47): ContentHandler->getParserOutput()
#10 /home/wwwroot/wiki/includes/EditPage.php(4254): MediaWiki\Content\Renderer\ContentRenderer->getParserOutput()
#11 /home/wwwroot/wiki/includes/EditPage.php(4157): EditPage->doPreviewParse()
#12 /home/wwwroot/wiki/includes/EditPage.php(2926): EditPage->getPreviewText()
#13 /home/wwwroot/wiki/includes/EditPage.php(728): EditPage->showEditForm()
#14 /home/wwwroot/wiki/includes/actions/EditAction.php(71): EditPage->edit()
#15 /home/wwwroot/wiki/includes/actions/SubmitAction.php(38): EditAction->show()
#16 /home/wwwroot/wiki/includes/MediaWiki.php(543): SubmitAction->show()
#17 /home/wwwroot/wiki/includes/MediaWiki.php(321): MediaWiki->performAction()
#18 /home/wwwroot/wiki/includes/MediaWiki.php(912): MediaWiki->performRequest()
#19 /home/wwwroot/wiki/includes/MediaWiki.php(563): MediaWiki->main()
#20 /home/wwwroot/wiki/index.php(53): MediaWiki->run()
#21 /home/wwwroot/wiki/index.php(46): wfIndexMain()
#22 {main}

Is it caused by some version mismatch? I'm currently using

kuenzign commented 2 years ago

Can you confirm that using the Math extension normally (not within markdown) works properly?

kuenzign commented 2 years ago

Additionally, I've tested this extension with Math 3.0.0 (4e8cc52) on MediaWiki 1.35.8 (latest LTS release) and there is no issue. It looks like the Math extension has had some refactoring, which would make certain versions incompatible (much like what you are seeing). Please try using the 4e8cc52 version of Math and see if that works for you. Once the next LTS release of MediaWiki is stable (1.39), I'll look into making changes to support whatever version of Math comes with that version.

Subilan commented 2 years ago

I'll look into making changes to support whatever version of Math comes with that version.

OK, I get it.

Can you confirm that using the Math extension normally (not within markdown) works properly?

It works normally without markdown. I'll disable math section in markdown for a simple fix as this is actually not a big issue for me though XD

Thanks for your help!

kuenzign commented 2 years ago

You might also be able to apply a simple hack to your version of WikiMarkdown by changing lines 130, 138, 146, and 155 to have MediaWiki\Extension\Math\HookHandlers instead of MediaWiki\Extension\Math\Hooks. I won't make this change here yet since that will break 1.35 compatibility and I mainly support MediaWiki LTS releases, but I'll likely need to make that change when MediaWiki 1.39 is released.

Subilan commented 2 years ago

Pretty cool solution, I'll try it later. Thanks!

Podolyakofs commented 9 months ago

to fix https://github.com/kuenzign/WikiMarkdown/issues/6 in 1.41 construct function changes to

public function __construct(
--
   RendererFactory $rendererFactory,
   UserOptionsLookup $userOptionsLookup,
   HookContainer $hookContainer
   ) {
   $this->rendererFactory = $rendererFactory;
   $this->userOptionsLookup = $userOptionsLookup;
   $this->hookRunner = new HookRunner( $hookContainer );
   }

so need some fix to 3 arg in

    $hookHandler = new \MediaWiki\Extension\Math\HookHandlers\ParserHooksHandler(
                MediaWiki\MediaWikiServices::getInstance()->getService( 'Math.RendererFactory' ),
                MediaWiki\MediaWikiServices::getInstance()->getService( 'UserOptionsLookup' )
            );