Hide comments.
This commit is contained in:
@@ -121,7 +121,7 @@ var mediawiki = {
|
|||||||
rr.Literal('<code>'),
|
rr.Literal('<code>'),
|
||||||
rr.Ref('multiline-wikichunk'),
|
rr.Ref('multiline-wikichunk'),
|
||||||
rr.Literal('</code>'))),
|
rr.Literal('</code>'))),
|
||||||
'multiline-comment': rr.Node('comment', rr.Sequence(
|
'multiline-comment': rr.Hidden(rr.Sequence(
|
||||||
rr.Literal('<!-- '),
|
rr.Literal('<!-- '),
|
||||||
rr.MultiLineText(),
|
rr.MultiLineText(),
|
||||||
rr.Literal(' -->'))),
|
rr.Literal(' -->'))),
|
||||||
@@ -185,7 +185,7 @@ var mediawiki = {
|
|||||||
rr.Literal('<code>'),
|
rr.Literal('<code>'),
|
||||||
rr.Ref('singleline-wikichunk'),
|
rr.Ref('singleline-wikichunk'),
|
||||||
rr.Literal('</code>'))),
|
rr.Literal('</code>'))),
|
||||||
'singleline-comment': rr.Node('comment', rr.Sequence(
|
'singleline-comment': rr.Hidden(rr.Sequence(
|
||||||
rr.Literal('<!-- '),
|
rr.Literal('<!-- '),
|
||||||
rr.SingleLineText(),
|
rr.SingleLineText(),
|
||||||
rr.Literal(' -->'))),
|
rr.Literal(' -->'))),
|
||||||
@@ -287,8 +287,8 @@ var mediawiki = {
|
|||||||
'paragraph': rr.Node('p', rr.Sequence(
|
'paragraph': rr.Node('p', rr.Sequence(
|
||||||
rr.Ref('multiline-wikichunk'),
|
rr.Ref('multiline-wikichunk'),
|
||||||
rr.Or(
|
rr.Or(
|
||||||
rr.Sequence(rr.EndOfLine(), rr.Literal('\n')),
|
rr.Sequence(rr.EndOfLine(), rr.Literal('\n')),
|
||||||
rr.EndOfText()))),
|
rr.EndOfText()))),
|
||||||
|
|
||||||
'wikidoc': rr.Node('wikidoc', rr.Sequence(
|
'wikidoc': rr.Node('wikidoc', rr.Sequence(
|
||||||
rr.ZeroOrMore(rr.Ref('paragraph')),
|
rr.ZeroOrMore(rr.Ref('paragraph')),
|
||||||
|
|||||||
@@ -180,6 +180,7 @@ rr.EndOfText = function() {
|
|||||||
/**
|
/**
|
||||||
* @type {rr.EndOfText_}
|
* @type {rr.EndOfText_}
|
||||||
* @const
|
* @const
|
||||||
|
* @private
|
||||||
*/
|
*/
|
||||||
rr.EndOfText.cache_ = new rr.EndOfText_();
|
rr.EndOfText.cache_ = new rr.EndOfText_();
|
||||||
}
|
}
|
||||||
@@ -188,6 +189,51 @@ rr.EndOfText = function() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
*
|
||||||
|
* @param {rr.typeMatcher} child
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
rr.Hidden_ = function(child) {
|
||||||
|
this.child_ = child;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {rr.Context} context
|
||||||
|
* @return {rr.typeIterator}
|
||||||
|
*/
|
||||||
|
rr.Hidden_.prototype.match = function(context) {
|
||||||
|
var iterator = this.child_.match(context);
|
||||||
|
return {
|
||||||
|
'next': function() {
|
||||||
|
var next = iterator.next();
|
||||||
|
if (next['done']) {
|
||||||
|
return { 'done': true };
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
'done': false,
|
||||||
|
'value': {
|
||||||
|
'context': next['value']['context'],
|
||||||
|
'nodes': []
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}.bind(this)
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {rr.typeMatcher} child
|
||||||
|
* @return {rr.Hidden_}
|
||||||
|
*/
|
||||||
|
rr.Hidden = function(child) {
|
||||||
|
return new rr.Hidden_(child);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
*
|
*
|
||||||
|
|||||||
3
test.js
3
test.js
@@ -46,8 +46,7 @@ QUnit.test('Base', function(assert) {
|
|||||||
'<tt>this</tt>. <pre>This sentence is inline pre-formatted, which stops \n',
|
'<tt>this</tt>. <pre>This sentence is inline pre-formatted, which stops \n',
|
||||||
"'''''this from being bold and italic.'''''</pre> We can also \nstop ",
|
"'''''this from being bold and italic.'''''</pre> We can also \nstop ",
|
||||||
'<u>this from being underlined</u>, or just try \n',
|
'<u>this from being underlined</u>, or just try \n',
|
||||||
'<pre>interrupting cow style.</pre><comment>This is a ',
|
'<pre>interrupting cow style.</pre><blockquote>This is a ',
|
||||||
"comment and \nshouldn't be visible</comment><blockquote>This is a ",
|
|
||||||
'blockquote</blockquote></p><p><h2>Header 2</h2><h3>Header 3 <i>with ',
|
'blockquote</blockquote></p><p><h2>Header 2</h2><h3>Header 3 <i>with ',
|
||||||
'italics</i></h3><h4>Header 4</h4><h5>Header 5</h5><h6>Header 6</h6><hr>',
|
'italics</i></h3><h4>Header 4</h4><h5>Header 5</h5><h6>Header 6</h6><hr>',
|
||||||
'<ulli1>Item 1a</ulli1><ulli1>Item 1b</ulli1><ulli2>Item 2</ulli2><ulli3>',
|
'<ulli1>Item 1a</ulli1><ulli1>Item 1b</ulli1><ulli2>Item 2</ulli2><ulli3>',
|
||||||
|
|||||||
Reference in New Issue
Block a user