From 616f365587b58139fcff91ccd3b7cfe1b0229966 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Sun, 29 Jun 2014 23:14:17 -0700 Subject: [PATCH] Working test. --- grammars/mediawiki.js | 8 +++++++- test.js | 27 ++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/grammars/mediawiki.js b/grammars/mediawiki.js index d3e4140..b15aa7e 100644 --- a/grammars/mediawiki.js +++ b/grammars/mediawiki.js @@ -260,7 +260,13 @@ var mediawiki = { rr.SingleLineText()), - 'wikidoc': rr.Node('wikidoc', rr.Sequence( + 'paragraph': rr.Node('p', rr.Sequence( rr.ZeroOrMore(rr.Ref('multiline-wikichunk')), + rr.Or( + rr.Sequence(rr.EndOfLine(), rr.Literal('\n')), + rr.EndOfText()))), + + 'wikidoc': rr.Node('wikidoc', rr.Sequence( + rr.ZeroOrMore(rr.Ref('paragraph')), rr.EndOfText())) }; diff --git a/test.js b/test.js index 82f95c8..e5023b9 100644 --- a/test.js +++ b/test.js @@ -7,7 +7,7 @@ QUnit.test('Base', function(assert) { "is '''bold'''; this is '''''both'''''. This is underline as is ", "this. This is '''''underlined, bold and italic'''''. ", 'This is strikethrough, as is this. Source ', - 'code looks like this. Fixed width text looks like', + 'code looks like this. Fixed width text looks like ', 'this.
This sentence is inline pre-formatted, which stops ',
     "'''''this from being bold and italic.'''''
We can also ", 'stop this from being underlined, or just try ', @@ -35,8 +35,29 @@ QUnit.test('Base', function(assert) { ':: Even larger ones', '::::: And really huge ones' ].join('\n'); + + var expected = [ + '

This is a paragraph with many text styles. This is italic and ', + 'this \nis bold; this is both. This is underline ', + 'as is \nthis. This is underlined, bold and italic', + '. \nThis is strikethrough, as is this. Source ', + '\ncode looks like this. Fixed width text looks like \n', + 'this.

This sentence is inline pre-formatted, which stops \n',
+    "'''''this from being bold and italic.'''''
We can also \nstop ", + '<u>this from being underlined</u>, or just try \n', + '<pre>interrupting cow style.</pre>This is a ', + "comment and \nshouldn't be visible
This is a ", + "blockquote

Header 2

Header 3 ''with ", + "italics''

Header 4

Header 5
Header 6

", + 'Item 1aItem 1bItem 2', + 'Item 3Item 1cItem 1aItem 1b', + 'Item 2Item 3Item 1c', + "I don't really understand what a definition is
", + 'But blockquotes are easy
Even larger ones', + 'And really huge ones

' + ].join(''); + var context = new rr.Context(mediawiki, content); var iterable = context.rules['wikidoc'].match(context); - assert.equal(iterable.next().value.nodes[0].innerHTML, - ''); + assert.equal(iterable.next().value.nodes[0].innerHTML, expected); });