| // Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| |
| /// The line contains only whitespace or is empty. |
| final emptyPattern = RegExp(r'^(?:[ \t]*)$'); |
| |
| /// A series of `=` or `-` (on the next line) define setext-style headers. |
| final setextPattern = RegExp(r'^[ ]{0,3}(=+|-+)\s*$'); |
| |
| /// Leading (and trailing) `#` define atx-style headers. |
| /// |
| /// Starts with 1-6 unescaped `#` characters which must not be followed by a |
| /// non-space character. Line may end with any number of `#` characters,. |
| final headerPattern = RegExp(r'^ {0,3}(#{1,6})[ \x09\x0b\x0c](.*?)#*$'); |
| |
| /// The line starts with `>` with one optional space after. |
| final blockquotePattern = RegExp(r'^[ ]{0,3}>[ ]?(.*)$'); |
| |
| /// A line indented four spaces. Used for code blocks and lists. |
| final indentPattern = RegExp(r'^(?: | {0,3}\t)(.*)$'); |
| |
| /// Fenced code block. |
| final codeFencePattern = RegExp(r'^[ ]{0,3}(`{3,}|~{3,})(.*)$'); |
| |
| /// Fenced blockquotes. |
| final blockquoteFencePattern = RegExp(r'^>{3}\s*$'); |
| |
| /// Three or more hyphens, asterisks or underscores by themselves. Note that |
| /// a line like `----` is valid as both HR and SETEXT. In case of a tie, |
| /// SETEXT should win. |
| final hrPattern = RegExp(r'^ {0,3}([-*_])[ \t]*\1[ \t]*\1(?:\1|[ \t])*$'); |
| |
| /// A line starting with one of these markers: `-`, `*`, `+`. May have up to |
| /// three leading spaces before the marker and any number of spaces or tabs |
| /// after. |
| /// |
| /// Contains a dummy group at [2], so that the groups in [ulPattern] and |
| /// [olPattern] match up; in both, [2] is the length of the number that begins |
| /// the list marker. |
| final ulPattern = RegExp(r'^([ ]{0,3})()([*+-])(([ \t])([ \t]*)(.*))?$'); |
| |
| /// A line starting with a number like `123.`. May have up to three leading |
| /// spaces before the marker and any number of spaces or tabs after. |
| final olPattern = RegExp(r'^([ ]{0,3})(\d{1,9})([\.)])(([ \t])([ \t]*)(.*))?$'); |
| |
| /// A line of hyphens separated by at least one pipe. |
| final tablePattern = RegExp( |
| r'^[ ]{0,3}\|?([ \t]*:?\-+:?[ \t]*\|)+([ \t]|[ \t]*:?\-+:?[ \t]*)?$'); |
| |
| /// A pattern which should never be used. It just satisfies non-nullability of |
| /// pattern fields. |
| final dummyPattern = RegExp(''); |