(ctx)
| 35 | } |
| 36 | |
| 37 | function readVersionHeader(ctx) { |
| 38 | // Extract the version number. |
| 39 | const versionLine = consumeLine(ctx); |
| 40 | const versionMatch = versionLine.text.match(/^((\d+\.\d+(\.\d+)?(\+|-\w+)?) \((\d{4}-\d{2}-\d{2}|\?\?\?)\))$/); |
| 41 | if (versionMatch == null) { |
| 42 | reportLineError(versionLine, "Expected a version number"); |
| 43 | } |
| 44 | |
| 45 | // Check the version seperator |
| 46 | const versionSeperator = consumeLine(ctx); |
| 47 | if (versionSeperator.text != HeaderSeperator) { |
| 48 | reportLineError(versionSeperator, "Expected version seperator"); |
| 49 | } |
| 50 | |
| 51 | // Check for optional headline, this means the there is text not starting with - and an empty line before |
| 52 | // the first entry. |
| 53 | var headline = peekLine(ctx); |
| 54 | if (headline != null && headline.text != "" && !headline.text.startsWith("-")) { |
| 55 | consumeLine(ctx); |
| 56 | |
| 57 | // Check for empty line |
| 58 | const emptyLine = peekLine(ctx); |
| 59 | if (emptyLine == null || emptyLine.text != "") { |
| 60 | reportError(ctx, "Expected empty line after headline"); |
| 61 | } |
| 62 | |
| 63 | consumeLine(ctx); |
| 64 | headline = headline.text; |
| 65 | } else { |
| 66 | headline = ""; |
| 67 | } |
| 68 | |
| 69 | return { |
| 70 | version: versionMatch[2], |
| 71 | date: versionMatch[5], |
| 72 | headline: headline, |
| 73 | }; |
| 74 | } |
| 75 | |
| 76 | function isValidReference(ref) { |
| 77 | const regex = /^\w*#\d+( \(partial\))?$/; |
no test coverage detected