#!/usr/bin/env python3 """Add ids to all rules based on their headline""" import sys import re HEADER_RE = re.compile(r' str: """Extract the headline's number from it's data-number attribute""" m = DATA_NUMBER_RE.search(line) if m: return m.group(1) return "" def main(): """Add ids to all ordered lists in the input""" headline = "" items = [] for line in sys.stdin.readlines(): if HEADER_RE.match(line): headline = extract_headline_nr(line) h_idx = line.find('