diff --git a/.github/workflows/template-sync.yml b/.github/workflows/template-sync.yml index b26de5e..85a8b1a 100755 --- a/.github/workflows/template-sync.yml +++ b/.github/workflows/template-sync.yml @@ -71,8 +71,9 @@ jobs: sys.exit(f"Cannot read canonical project ID from records/SPEC.md: {error}") fields = [] fence = None + tick = chr(96) for line in lines: - marker = re.match(r" {0,3}(`{3,}|~{3,})(.*)$", line) + marker = re.match(r" {0,3}(" + tick + r"{3,}|~{3,})(.*)$", line) if fence is not None: if (marker and marker[1][0] == fence[0] and len(marker[1]) >= len(fence) and not marker[2].strip()): @@ -82,15 +83,21 @@ jobs: fence = marker[1] continue field = re.fullmatch(r" {0,3}-[ \t]+Project id:[ \t]*(.*)", line) - if field: - fields.append(field[1].strip()) + table = re.fullmatch(r" {0,3}\|[ \t]*Project id[ \t]*\|[ \t]*([^|]*)\|[ \t]*", line) + if re.match(r" {0,3}\|[ \t]*Project id[ \t]*\|", line) and not table: + sys.exit("Malformed Project id table row in records/SPEC.md") + bold = re.fullmatch(r" {0,3}\*\*Project id:\*\*[ \t]*(.*)", line) + if field or table or bold: + fields.append((field or table or bold)[1].strip()) if len(fields) != 1: sys.exit("records/SPEC.md must contain exactly one Project id field outside code blocks") project_id = fields[0] - if project_id.startswith("`") and project_id.endswith("`"): + if project_id.startswith(tick) or project_id.endswith(tick): + if len(project_id) < 2 or not (project_id.startswith(tick) and project_id.endswith(tick)): + sys.exit("Unbalanced Project id backticks in records/SPEC.md") project_id = project_id[1:-1] - if not re.fullmatch(r"[a-z0-9]+(?:-[a-z0-9]+)*", project_id): - sys.exit("records/SPEC.md Project id must be a lowercase kebab-case ID, optionally wrapped in backticks") + if not re.fullmatch(r"[A-Za-z0-9]+(?:[-_][A-Za-z0-9]+)*", project_id): + sys.exit("records/SPEC.md Project id must be a nonempty alphanumeric, hyphen or underscore ID") print(project_id) PY )