| 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 /// Maintains the internal state needed to parse inline span elements in | 5 /// Maintains the internal state needed to parse inline span elements in |
| 6 /// markdown. | 6 /// markdown. |
| 7 class InlineParser { | 7 class InlineParser { |
| 8 static List<InlineSyntax> get syntaxes() { | 8 static List<InlineSyntax> get syntaxes() { |
| 9 // Lazy initialize. | 9 // Lazy initialize. |
| 10 if (_syntaxes == null) { | 10 if (_syntaxes == null) { |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 url = url.substring(1, url.length - 1); | 281 url = url.substring(1, url.length - 1); |
| 282 } | 282 } |
| 283 } else { | 283 } else { |
| 284 // Reference link like [foo] [bar]. | 284 // Reference link like [foo] [bar]. |
| 285 var id = match[2]; | 285 var id = match[2]; |
| 286 if (id == '') { | 286 if (id == '') { |
| 287 // The id is empty ("[]") so infer it from the contents. | 287 // The id is empty ("[]") so infer it from the contents. |
| 288 id = parser.source.substring(state.startPos + 1, parser.pos); | 288 id = parser.source.substring(state.startPos + 1, parser.pos); |
| 289 } | 289 } |
| 290 | 290 |
| 291 // References are case-insensitive. |
| 292 id = id.toLowerCase(); |
| 293 |
| 291 // Look up the link. | 294 // Look up the link. |
| 292 final link = parser.document.refLinks[id]; | 295 final link = parser.document.refLinks[id]; |
| 293 // If it's an unknown link just emit plaintext. | 296 // If it's an unknown link just emit plaintext. |
| 294 if (link == null) return false; | 297 if (link == null) return false; |
| 295 | 298 |
| 296 url = link.url; | 299 url = link.url; |
| 297 title = link.title; | 300 title = link.title; |
| 298 } | 301 } |
| 299 | 302 |
| 300 final anchor = new Element('a', state.children); | 303 final anchor = new Element('a', state.children); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 parser.consume(endMatch[0].length); | 389 parser.consume(endMatch[0].length); |
| 387 } else { | 390 } else { |
| 388 // Didn't close correctly so revert to text. | 391 // Didn't close correctly so revert to text. |
| 389 parser.start = startPos; | 392 parser.start = startPos; |
| 390 parser.advanceBy(endMatch[0].length); | 393 parser.advanceBy(endMatch[0].length); |
| 391 } | 394 } |
| 392 | 395 |
| 393 return null; | 396 return null; |
| 394 } | 397 } |
| 395 } | 398 } |
| OLD | NEW |