mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 00:30:44 +00:00
dca609e3f9
In preparation for the big extraction of Parsoid out of VisualEditor, we'll start by moving the tests into the parsoid location. Change-Id: I4a926ee4aad1490d4f769d44e91af80842b881f0
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
var HTML5 = require('html5').HTML5;
|
|
|
|
// No instance properties
|
|
function Parsoid() {}
|
|
|
|
function initParsoid() {
|
|
var path = require('path');
|
|
var fileDependencies = [];
|
|
var basePath = path.join(path.dirname(path.dirname(process.cwd())), 'modules');
|
|
|
|
function _require(filename) {
|
|
var fullpath = path.join( basePath, filename );
|
|
fileDependencies.push( fullpath );
|
|
return require( fullpath );
|
|
}
|
|
|
|
function _import(filename, symbols) {
|
|
var module = _require(filename);
|
|
symbols.forEach(function(symbol) {
|
|
global[symbol] = module[symbol];
|
|
});
|
|
}
|
|
|
|
_import(path.join('parser', 'mediawiki.parser.environment.js'), ['MWParserEnvironment']);
|
|
_import(path.join('parser', 'mediawiki.parser.js'), ['ParserPipelineFactory']);
|
|
_import(path.join('parser', 'mediawiki.WikitextSerializer.js'), ['WikitextSerializer']);
|
|
|
|
var mwEnv = new MWParserEnvironment({
|
|
fetchTemplates: false,
|
|
debug: false,
|
|
trace: false,
|
|
wgUploadPath: 'http://example.com/images'
|
|
});
|
|
|
|
// "class" properties
|
|
Parsoid.html5 = new HTML5.Parser();
|
|
Parsoid.serializer = new WikitextSerializer({env: mwEnv});
|
|
}
|
|
|
|
initParsoid();
|
|
|
|
if (typeof module == "object") {
|
|
module.exports.Parsoid = Parsoid;
|
|
}
|