| 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 library markdown.inline_parser; |
| 6 |
| 7 import 'ast.dart'; |
| 8 import 'document.dart'; |
| 9 import 'util.dart'; |
| 6 | 10 |
| 7 /// Maintains the internal state needed to parse inline span elements in | 11 /// Maintains the internal state needed to parse inline span elements in |
| 8 /// markdown. | 12 /// markdown. |
| 9 class InlineParser { | 13 class InlineParser { |
| 10 static List<InlineSyntax> defaultSyntaxes = <InlineSyntax>[ | 14 static List<InlineSyntax> defaultSyntaxes = <InlineSyntax>[ |
| 11 // This first regexp matches plain text to accelerate parsing. It must | 15 // This first regexp matches plain text to accelerate parsing. It must |
| 12 // be written so that it does not match any prefix of any following | 16 // be written so that it does not match any prefix of any following |
| 13 // syntax. Most markdown is plain text, so it is faster to match one | 17 // syntax. Most markdown is plain text, so it is faster to match one |
| 14 // regexp per 'word' rather than fail to match all the following regexps | 18 // regexp per 'word' rather than fail to match all the following regexps |
| 15 // at each non-syntax character position. It is much more important | 19 // at each non-syntax character position. It is much more important |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 parser.consume(endMatch[0].length); | 414 parser.consume(endMatch[0].length); |
| 411 } else { | 415 } else { |
| 412 // Didn't close correctly so revert to text. | 416 // Didn't close correctly so revert to text. |
| 413 parser.start = startPos; | 417 parser.start = startPos; |
| 414 parser.advanceBy(endMatch[0].length); | 418 parser.advanceBy(endMatch[0].length); |
| 415 } | 419 } |
| 416 | 420 |
| 417 return null; | 421 return null; |
| 418 } | 422 } |
| 419 } | 423 } |
| OLD | NEW |