| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 return childLines; | 227 return childLines; |
| 228 } | 228 } |
| 229 | 229 |
| 230 Node parse(BlockParser parser) { | 230 Node parse(BlockParser parser) { |
| 231 final childLines = parseChildLines(parser); | 231 final childLines = parseChildLines(parser); |
| 232 | 232 |
| 233 // The Markdown tests expect a trailing newline. | 233 // The Markdown tests expect a trailing newline. |
| 234 childLines.add(''); | 234 childLines.add(''); |
| 235 | 235 |
| 236 // Escape the code. | 236 // Escape the code. |
| 237 final escaped = classifySource(Strings.join(childLines, '\n')); | 237 final escaped = classifySource(childLines.join('\n')); |
| 238 | 238 |
| 239 return new Element.text('pre', escaped); | 239 return new Element.text('pre', escaped); |
| 240 } | 240 } |
| 241 } | 241 } |
| 242 | 242 |
| 243 /// Parses horizontal rules like `---`, `_ _ _`, `* * *`, etc. | 243 /// Parses horizontal rules like `---`, `_ _ _`, `* * *`, etc. |
| 244 class HorizontalRuleSyntax extends BlockSyntax { | 244 class HorizontalRuleSyntax extends BlockSyntax { |
| 245 RegExp get pattern => _RE_HR; | 245 RegExp get pattern => _RE_HR; |
| 246 | 246 |
| 247 Node parse(BlockParser parser) { | 247 Node parse(BlockParser parser) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 268 | 268 |
| 269 Node parse(BlockParser parser) { | 269 Node parse(BlockParser parser) { |
| 270 final childLines = []; | 270 final childLines = []; |
| 271 | 271 |
| 272 // Eat until we hit a blank line. | 272 // Eat until we hit a blank line. |
| 273 while (!parser.isDone && !parser.matches(_RE_EMPTY)) { | 273 while (!parser.isDone && !parser.matches(_RE_EMPTY)) { |
| 274 childLines.add(parser.current); | 274 childLines.add(parser.current); |
| 275 parser.advance(); | 275 parser.advance(); |
| 276 } | 276 } |
| 277 | 277 |
| 278 return new Text(Strings.join(childLines, '\n')); | 278 return new Text(childLines.join('\n')); |
| 279 } | 279 } |
| 280 } | 280 } |
| 281 | 281 |
| 282 class ListItem { | 282 class ListItem { |
| 283 bool forceBlock = false; | 283 bool forceBlock = false; |
| 284 final List<String> lines; | 284 final List<String> lines; |
| 285 | 285 |
| 286 ListItem(this.lines); | 286 ListItem(this.lines); |
| 287 } | 287 } |
| 288 | 288 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 | 450 |
| 451 Node parse(BlockParser parser) { | 451 Node parse(BlockParser parser) { |
| 452 final childLines = []; | 452 final childLines = []; |
| 453 | 453 |
| 454 // Eat until we hit something that ends a paragraph. | 454 // Eat until we hit something that ends a paragraph. |
| 455 while (!BlockSyntax.isAtBlockEnd(parser)) { | 455 while (!BlockSyntax.isAtBlockEnd(parser)) { |
| 456 childLines.add(parser.current); | 456 childLines.add(parser.current); |
| 457 parser.advance(); | 457 parser.advance(); |
| 458 } | 458 } |
| 459 | 459 |
| 460 final contents = parser.document.parseInline( | 460 final contents = parser.document.parseInline(childLines.join('\n')); |
| 461 Strings.join(childLines, '\n')); | |
| 462 return new Element('p', contents); | 461 return new Element('p', contents); |
| 463 } | 462 } |
| 464 } | 463 } |
| OLD | NEW |