mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 00:30:44 +00:00
fc3bd58edd
* This is especially useful for running DOM -> wikitext tests. * Run npm install to install dependencies. * Add new specs in specs/ (see headings.spec.js for example). * Run all specs with "node specs.js" * With existing specs, this should fail one assertion. - The failing assertion is fixed in the bug-33089 branch. Change-Id: I084868206a48ba6b69e6e3e85d94d0207a166ae0
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;
|
|
}
|