public function richTextPreview() { if (\Airship\all_keys_exist(['format', 'body'], $_POST)) { switch ($_POST['format']) { case 'HTML': case 'Rich Text': \Airship\json_response(['status' => 'OK', 'body' => \Airship\LensFunctions\get_purified($_POST['body'] ?? '')]); break; case 'Markdown': \Airship\json_response(['status' => 'OK', 'body' => \Airship\LensFunctions\render_purified_markdown($_POST['body'] ?? '', true)]); break; case 'RST': \Airship\json_response(['status' => 'OK', 'body' => \Airship\LensFunctions\get_purified(\Airship\LensFunctions\render_rst($_POST['body'] ?? '', true))]); break; default: \Airship\json_response(['status' => 'ERROR', 'message' => 'Unknown format: ' . $_POST['format']]); } } \Airship\json_response(['status' => 'ERROR', 'message' => \__('Incomplete request')]); }