diff --git a/ApiVisualEditor.php b/ApiVisualEditor.php index 0536e14528..154ae4cd99 100644 --- a/ApiVisualEditor.php +++ b/ApiVisualEditor.php @@ -161,6 +161,15 @@ class ApiVisualEditor extends ApiBase { ); } + protected function parseWikitextFragment( $title, $wikitext ) { + return $this->requestParsoid( 'POST', $title, + array( + 'wt' => $wikitext, + 'body' => 1, + ) + ); + } + protected function parseWikitext( $title ) { $apiParams = array( 'action' => 'parse', @@ -197,29 +206,6 @@ class ApiVisualEditor extends ApiBase { ); } - protected function parseWikitextFragment( $wikitext, $title = null ) { - $apiParams = array( - 'action' => 'parse', - 'title' => $title, - 'prop' => 'text', - 'disablepp' => true, - 'pst' => true, - 'text' => $wikitext - ); - $api = new ApiMain( - new DerivativeRequest( - $this->getRequest(), - $apiParams, - false // was posted? - ), - true // enable write? - ); - - $api->execute(); - $result = $api->getResultData(); - return isset( $result['parse']['text']['*'] ) ? $result['parse']['text']['*'] : false; - } - protected function diffWikitext( $title, $wikitext ) { $apiParams = array( 'action' => 'query', @@ -426,9 +412,9 @@ class ApiVisualEditor extends ApiBase { break; case 'parsefragment': - $content = $this->parseWikitextFragment( $params['wikitext'], $page->getText() ); + $content = $this->parseWikitextFragment( $page, $params['wikitext'] ); if ( $content === false ) { - $this->dieUsage( 'Error querying MediaWiki API', 'parsoidserver' ); + $this->dieUsage( 'Error contacting the Parsoid server', 'parsoidserver' ); } else { $result = array( 'result' => 'success',