Pandoc converter extension for mediawiki which imports not only text, but also images
MIT License
PandocUltimateConverter is a Pandoc converter extension for MediaWiki which converts files and webpages and imports not only text, but also images.
MediaWiki page: https://www.mediawiki.org/wiki/Extension:PandocUltimateConverter
Tested on MediaWiki 1.39, 1.40, 1.41, 1.42
Requires pandoc to be installed.
Tested on Windows and Linux (Ubuntu).
Installation is just a bit more complicated than usual:
wfLoadExtension( 'PandocUltimateConverter' );
$wgPandocUltimateConverter_PandocExecutablePath = 'C:\Program Files\Pandoc\pandoc.exe';
. It will work without this param if pandoc is in the PATH env. variable$wgPandocUltimateConverter_TempFolderPath = 'D:\_TMP';
. IT will try to use default temp folder if not specified.$wgFileExtensions[] = 'docx';
$wgFileExtensions[] = 'odt';
// You can specify other requried extensions as well
TL;DR:
$wgEnableUploads = true;
$wgFileExtensions[] = 'docx';
$wgFileExtensions[] = 'odt';
$wgPandocUltimateConverter_PandocExecutablePath = '/your/path/to/pandoc'; # For example, 'C:\Program Files\Pandoc\pandoc.exe'
wfLoadExtension( 'PandocUltimateConverter' );
Follow these steps:
Go to Special:PandocUltimateConverter
page.
Choose what to convert: file or webpage (URL).
Specify file (or URL) to convert and target page name.
After the file conversion is finished, you will be redirected to the target page
Pandocultimateconverter-{guid}-{imageOriginalNameAndExtension}
Theoretically it supports everything Pandoc supports. On practice, I've tested for docx and odt only. PDF is not supported as input format of pandoc.
Webpages can be imported as well. Pandoc does not work very well with webpages, but it might be helpful if the webpage contains a lot of images and other files.
Simple gif to show how it works for files:
And another gif to show demo for importing a webpage:
There are additional configs:
$wgPandocUltimateConverter_MediaFileExtensionsToSkip = [ 'emf' ];
-- You can specify array of extensions which should not be uploaded to MediaWiki as a file. For example, emf images are not supported in web, and you there is no reason to upload them. The config is case insensitive.$wgPandocExecutablePath
and $wgPandocTmpFolderPath
are still working but we recommend to switch to confiuration parameteres $wgPandocUltimateConverter_PandocExecutablePath
and $wgPandocUltimateConverter_TempFolderPath
.$wgPandocUltimateConverter_PandocCustomUserRight
where you can specify the required permission. For example: $wgPandocUltimateConverter_PandocCustomUserRight = 'nominornewtalk';
should prohibit access for non-bots:In case you face any issues with the extension, please add these lines to the LocalSettings.php:
error_reporting( -1 );
$wgDebugLogFile = "/var/log/mediawiki/main.log";
$wgDebugLogPrefix = date( '[Y-m-d H:i:s] ' );
$wgShowExceptionDetails = true;
$wgShowDBErrorBacktrace = true;
error_reporting( E_ALL ); ini_set( 'display_errors', 1 );
$wgDebugLogGroups['DBQuery'] =
$wgDebugLogGroups['DBReplication'] =
$wgDebugLogGroups['DBConnection'] =
$wgDebugLogGroups['runJobs'] =
$wgDebugLogGroups['Parsoid'] =
$wgDebugLogGroups['rdbms'] = "/var/log/mediawiki/misc.log";
Confirm the issue once more and provide the content of /var/log/mediawiki/main.log. You may want to specify different path, especially if you are using Windows OS.