Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(492)

Side by Side Diff: samples/markdown/block_parser.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samples/logo/logo.dart ('k') | samples/markdown/markdown.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of markdown; 5 part of markdown;
6 6
7 /// The line contains only whitespace or is empty. 7 /// The line contains only whitespace or is empty.
8 final _RE_EMPTY = new RegExp(r'^([ \t]*)$'); 8 final _RE_EMPTY = new RegExp(r'^([ \t]*)$');
9 9
10 /// A series of `=` or `-` (on the next line) define setext-style headers. 10 /// A series of `=` or `-` (on the next line) define setext-style headers.
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 childLines.add(match[1]); 128 childLines.add(match[1]);
129 parser.advance(); 129 parser.advance();
130 } 130 }
131 131
132 return childLines; 132 return childLines;
133 } 133 }
134 134
135 /// Gets whether or not [parser]'s current line should end the previous block. 135 /// Gets whether or not [parser]'s current line should end the previous block.
136 static bool isAtBlockEnd(BlockParser parser) { 136 static bool isAtBlockEnd(BlockParser parser) {
137 if (parser.isDone) return true; 137 if (parser.isDone) return true;
138 return syntaxes.some((s) => s.canParse(parser) && s.canEndBlock); 138 return syntaxes.any((s) => s.canParse(parser) && s.canEndBlock);
139 } 139 }
140 } 140 }
141 141
142 class EmptyBlockSyntax extends BlockSyntax { 142 class EmptyBlockSyntax extends BlockSyntax {
143 RegExp get pattern => _RE_EMPTY; 143 RegExp get pattern => _RE_EMPTY;
144 144
145 Node parse(BlockParser parser) { 145 Node parse(BlockParser parser) {
146 parser.advance(); 146 parser.advance();
147 147
148 // Don't actually emit anything. 148 // Don't actually emit anything.
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 while (!BlockSyntax.isAtBlockEnd(parser)) { 429 while (!BlockSyntax.isAtBlockEnd(parser)) {
430 childLines.add(parser.current); 430 childLines.add(parser.current);
431 parser.advance(); 431 parser.advance();
432 } 432 }
433 433
434 final contents = parser.document.parseInline( 434 final contents = parser.document.parseInline(
435 Strings.join(childLines, '\n')); 435 Strings.join(childLines, '\n'));
436 return new Element('p', contents); 436 return new Element('p', contents);
437 } 437 }
438 } 438 }
OLDNEW
« no previous file with comments | « samples/logo/logo.dart ('k') | samples/markdown/markdown.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698