forge
Clone
https://git.tahinli.com/Tahinli/forge.git
0 watching0 forksRustAGPL-3.09.3 MiBb00f3f4Tahinli1 month ago147 commits
| 1 | //! Parsing of issue references (`#12`) and closing keywords (`fixes #12`) in free text. |
| 2 | //! Hand-written scanner, no regex. Pure, no IO. |
| 3 | |
| 4 | use Range; |
| 5 | |
| 6 | /// Keywords that close an issue when followed by a `#N` reference. Compared case-insensitively. |
| 7 | const CLOSING_KEYWORDS: = |
| 8 | |
| 9 | ; |
| 10 | |
| 11 | /// Maximum number of digits in an issue number. |
| 12 | const MAX_DIGITS: usize = 9; |
| 13 | |
| 14 | /// Byte range (including the `#`) and value of every valid `#N` reference in `text`, in order. |
| 15 | /// Duplicates are kept. Used to link references in rendered markdown with the same rules. |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | /// Every `#N` reference in `text`, deduplicated, in order of first appearance. |
| 21 | /// |
| 22 | /// A reference is `#` followed by 1 to 9 digits. It is not recognised when the `#` is preceded by |
| 23 | /// an alphanumeric char, `&` or `/`, or when the digits are followed by an alphanumeric char. |
| 24 | /// `#0` is not an issue number and is ignored. |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | /// Issue numbers closed by closing keywords in `text`, deduplicated, in order. |
| 36 | /// |
| 37 | /// The keyword (case-insensitive, whole word) must directly precede the reference, optionally |
| 38 | /// separated by a `:`, with at least one whitespace char between the keyword (or colon) and `#`. |
| 39 | /// Example: `"Fixes: #3, closes #4"` gives `[3, 4]`; `"unfixes #2"` gives nothing. |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | /// Byte range of each valid `#N` reference and its value, in order of appearance. |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | /// True when `before` (the text preceding a `#N` reference) ends with a closing keyword, |
| 95 | /// an optional `:`, and at least one whitespace char. |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | |
| 104 | |
| 105 | |
| 106 | |
| 107 | |
| 108 | |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | |
| 160 | |
| 161 | |
| 162 | |
| 163 | |
| 164 | |
| 165 |