| OLD | NEW |
| 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 class CodeBlockSyntax extends BlockSyntax { | 201 class CodeBlockSyntax extends BlockSyntax { |
| 202 RegExp get pattern => _RE_INDENT; | 202 RegExp get pattern => _RE_INDENT; |
| 203 | 203 |
| 204 Node parse(BlockParser parser) { | 204 Node parse(BlockParser parser) { |
| 205 final childLines = parseChildLines(parser); | 205 final childLines = parseChildLines(parser); |
| 206 | 206 |
| 207 // The Markdown tests expect a trailing newline. | 207 // The Markdown tests expect a trailing newline. |
| 208 childLines.add(''); | 208 childLines.add(''); |
| 209 | 209 |
| 210 // Escape the code. | 210 // Escape the code. |
| 211 final escaped = escapeHtml(Strings.join(childLines, '\n')); | 211 final escaped = escapeHtml(childLines.join('\n')); |
| 212 | 212 |
| 213 return new Element('pre', [new Element.text('code', escaped)]); | 213 return new Element('pre', [new Element.text('code', escaped)]); |
| 214 } | 214 } |
| 215 } | 215 } |
| 216 | 216 |
| 217 /// Parses horizontal rules like `---`, `_ _ _`, `* * *`, etc. | 217 /// Parses horizontal rules like `---`, `_ _ _`, `* * *`, etc. |
| 218 class HorizontalRuleSyntax extends BlockSyntax { | 218 class HorizontalRuleSyntax extends BlockSyntax { |
| 219 RegExp get pattern => _RE_HR; | 219 RegExp get pattern => _RE_HR; |
| 220 | 220 |
| 221 Node parse(BlockParser parser) { | 221 Node parse(BlockParser parser) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 242 | 242 |
| 243 Node parse(BlockParser parser) { | 243 Node parse(BlockParser parser) { |
| 244 final childLines = []; | 244 final childLines = []; |
| 245 | 245 |
| 246 // Eat until we hit a blank line. | 246 // Eat until we hit a blank line. |
| 247 while (!parser.isDone && !parser.matches(_RE_EMPTY)) { | 247 while (!parser.isDone && !parser.matches(_RE_EMPTY)) { |
| 248 childLines.add(parser.current); | 248 childLines.add(parser.current); |
| 249 parser.advance(); | 249 parser.advance(); |
| 250 } | 250 } |
| 251 | 251 |
| 252 return new Text(Strings.join(childLines, '\n')); | 252 return new Text(childLines.join('\n')); |
| 253 } | 253 } |
| 254 } | 254 } |
| 255 | 255 |
| 256 class ListItem { | 256 class ListItem { |
| 257 bool forceBlock = false; | 257 bool forceBlock = false; |
| 258 final List<String> lines; | 258 final List<String> lines; |
| 259 | 259 |
| 260 ListItem(this.lines); | 260 ListItem(this.lines); |
| 261 } | 261 } |
| 262 | 262 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 | 424 |
| 425 Node parse(BlockParser parser) { | 425 Node parse(BlockParser parser) { |
| 426 final childLines = []; | 426 final childLines = []; |
| 427 | 427 |
| 428 // Eat until we hit something that ends a paragraph. | 428 // Eat until we hit something that ends a paragraph. |
| 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(childLines.join('\n')); |
| 435 Strings.join(childLines, '\n')); | |
| 436 return new Element('p', contents); | 435 return new Element('p', contents); |
| 437 } | 436 } |
| 438 } | 437 } |
| OLD | NEW |