41 'from' => [ self::PARAM_SOURCE =>
'path',
44 'format' => [ self::PARAM_SOURCE =>
'path',
47 'title' => [ self::PARAM_SOURCE =>
'path',
50 'revision' => [ self::PARAM_SOURCE =>
'path',
69 $ifMatch = $request->getHeaderLine(
'If-Match' );
72 $attribs[
'opts'][
'original'][
'etag'] = $ifMatch;
86 $from = $request->getPathParam(
'from' );
87 $format = $request->getPathParam(
'format' );
92 $validTransformations = $this->
getConfig()[
'transformations'] ?? ParsoidFormatHelper::VALID_TRANSFORM;
94 if ( !isset( $validTransformations[$from] ) || !in_array( $format,
95 $validTransformations[$from],
97 throw new HttpException(
"Invalid transform: {$from}/to/{$format}",
100 $attribs = &$this->getRequestAttributes();
101 if ( !$this->acceptable( $attribs ) ) {
105 if ( $from === ParsoidFormatHelper::FORMAT_WIKITEXT ) {
107 $wikitext = $attribs[
'opts'][
'wikitext'] ??
null;
108 if ( is_array( $wikitext ) ) {
109 $wikitext = $wikitext[
'body'];
111 if ( isset( $attribs[
'opts'][
'wikitext'][
'headers'][
'content-language'] ) ) {
112 $attribs[
'pagelanguage'] = $attribs[
'opts'][
'wikitext'][
'headers'][
'content-language'];
116 if ( $wikitext ===
null && isset( $attribs[
'opts'][
'original'][
'wikitext'] ) ) {
117 $wikitext = $attribs[
'opts'][
'original'][
'wikitext'][
'body'];
119 if ( isset( $attribs[
'opts'][
'original'][
'wikitext'][
'headers'][
'content-language'] ) ) {
120 $attribs[
'pagelanguage'] = $attribs[
'opts'][
'original'][
'wikitext'][
'headers'][
'content-language'];
124 if ( $wikitext ===
null && empty( $attribs[
'pageName'] ) ) {
125 throw new HttpException(
'No title or wikitext was provided.',
128 $pageConfig = $this->tryToCreatePageConfig( $attribs,
131 return $this->wt2html( $pageConfig,
134 } elseif ( $format === ParsoidFormatHelper::FORMAT_WIKITEXT ) {
135 $html = $attribs[
'opts'][
'html'] ??
null;
137 if ( is_array( $html ) ) {
138 $html = $html[
'body'];
140 if ( $html ===
null ) {
141 throw new HttpException(
'No html was supplied.',
147 $page = $this->tryToCreatePageIdentity( $attribs );
149 return $this->html2wt(
155 return $this->pb2pb( $attribs );