From 3211d3a78d8702e8a893e091ef42d16b90b28d05 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Mon, 19 May 2025 18:56:29 -0600 Subject: improve code style --- scripts/prepare_html_rules.py | 60 ++++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 24 deletions(-) (limited to 'scripts') diff --git a/scripts/prepare_html_rules.py b/scripts/prepare_html_rules.py index 4d533bec..aca29932 100755 --- a/scripts/prepare_html_rules.py +++ b/scripts/prepare_html_rules.py @@ -1,44 +1,56 @@ #!/usr/bin/env python3 +"""Add ids to all rules based on their headline""" # TODO: support nested lists import sys import re +HEADER_RE = re.compile(r' str: - m = data_number_re.search(line) + """Extract the headline's number from it's data-number attribute""" + m = DATA_NUMBER_RE.search(line) if m: return m.group(1) - else: - return "" - -headline = "" -i = 0 -for line in sys.stdin.readlines(): - if header_re.match(line): - headline = extract_headline_nr(line) - h_idx = line.find('