mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
0d30a5528e
tests/parser/parserTests.js. * Removed var from es in es.js to allow node.js to access it as global. Only alternative solution appears to be a node-specific 'exports' construct: http://nodejs.org/docs/v0.3.1/api/modules.html * Added es.Document.js and es.Document.Serializer.js in es/bases. Not sure if this is the desired location. * Changed es.extend to es.extendClass in the serializers * Modified the first parser test to include the WikiDom modules and call the new HTML serializer
88 lines
1.3 KiB
JavaScript
88 lines
1.3 KiB
JavaScript
var pageDatabase = {
|
|
'Boring': 'Just some text and [[a link]].',
|
|
'Template:Parens': '({{{1}}})',
|
|
'ParenCaller': '{{Parens|bizbax}}'
|
|
}
|
|
var domDatabase = {
|
|
'Boring': {
|
|
type: 'root',
|
|
contents: [
|
|
'Just some text and ',
|
|
{
|
|
type: 'link',
|
|
target: 'a link'
|
|
},
|
|
'.'
|
|
]
|
|
},
|
|
'Template:Parens': {
|
|
type: 'root',
|
|
contents: [
|
|
'(',
|
|
{
|
|
type: 'tplarg',
|
|
/*
|
|
contents: [
|
|
'1'
|
|
]*/
|
|
name: '1'
|
|
},
|
|
')'
|
|
]
|
|
},
|
|
'ParenCaller': {
|
|
type: 'root',
|
|
contents: [
|
|
{
|
|
type: 'template',
|
|
/*
|
|
contents: [
|
|
{
|
|
type: 'title',
|
|
contents: [
|
|
'Parens'
|
|
]
|
|
},
|
|
{
|
|
type: 'part',
|
|
contents: [
|
|
{
|
|
type: 'name',
|
|
index: 1
|
|
},
|
|
{
|
|
type: 'value',
|
|
contents: [
|
|
'bizbax'
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]*/
|
|
name: 'Parens',
|
|
params: {
|
|
1: 'bizbax'
|
|
}
|
|
}
|
|
]
|
|
}
|
|
};
|
|
|
|
$(function() {
|
|
var env = new MWParserEnvironment({
|
|
'pageCache': pageDatabase,
|
|
'domCache': domDatabase
|
|
});
|
|
env.debug = true;
|
|
var frame = new PPFrame(env);
|
|
//var victim = 'Boring';
|
|
var victim = 'ParenCaller';
|
|
frame.expand(domDatabase[victim], 0, function(node, err) {
|
|
if (err) {
|
|
console.log('error', err);
|
|
} else {
|
|
console.log(node);
|
|
}
|
|
});
|
|
})
|