1919OUTPUT_HTML = ROOT / "docs" / "index.html"
2020
2121
22- # ---------------------------------------------------------------------------
23- # BibTeX parsing
24- # ---------------------------------------------------------------------------
25-
2622def parse_entries (text : str ) -> list [dict ]:
2723 """Parse a .bib file into a list of entry dicts.
2824
@@ -52,7 +48,6 @@ def parse_entries(text: str) -> list[dict]:
5248 bibtidy_comments : list [str ] = []
5349 # Skip commented-out original entry lines (% @... or % ...)
5450 while i < len (lines ) and lines [i ].startswith ("%" ):
55- stripped = lines [i ].lstrip ("% " ).strip ()
5651 if lines [i ].strip ().startswith ("% bibtidy:" ):
5752 bibtidy_comments .append (lines [i ].strip ())
5853 i += 1
@@ -76,19 +71,11 @@ def parse_entries(text: str) -> list[dict]:
7671 brace_depth += lines [i ].count ("{" ) - lines [i ].count ("}" )
7772 i += 1
7873
79- entries .append ({
80- "key" : key ,
81- "lines" : entry_lines ,
82- "bibtidy_comments" : bibtidy_comments ,
83- })
74+ entries .append ({"key" : key , "lines" : entry_lines , "bibtidy_comments" : bibtidy_comments })
8475
8576 return entries
8677
8778
88- # ---------------------------------------------------------------------------
89- # Diff computation
90- # ---------------------------------------------------------------------------
91-
9279def compute_diff (input_lines : list [str ], expected_lines : list [str ]) -> list [tuple [str , str ]]:
9380 """Return list of (type, line) where type is 'ctx', 'del', or 'add'."""
9481 result = []
@@ -111,10 +98,6 @@ def compute_diff(input_lines: list[str], expected_lines: list[str]) -> list[tupl
11198 return result
11299
113100
114- # ---------------------------------------------------------------------------
115- # Badge classification
116- # ---------------------------------------------------------------------------
117-
118101def classify_entry (bibtidy_comments : list [str ], diff : list [tuple [str , str ]]) -> tuple [str , str ]:
119102 """Return (badge_class, badge_label) based on bibtidy comments."""
120103 joined = " " .join (bibtidy_comments ).lower ()
@@ -163,10 +146,6 @@ def make_title(bibtidy_comments: list[str], diff: list[tuple[str, str]]) -> str:
163146 return "Entry corrected"
164147
165148
166- # ---------------------------------------------------------------------------
167- # HTML generation
168- # ---------------------------------------------------------------------------
169-
170149_URL_RE = re .compile (r"(https?://[^\s,;)\"'&{}]+)" )
171150
172151
@@ -177,15 +156,13 @@ def escape_html(s: str) -> str:
177156def linkify (s : str ) -> str :
178157 """Escape HTML and convert URLs to clickable links."""
179158 escaped = escape_html (s )
180- return _URL_RE .sub (r'<a href="\1" target="_blank" rel="noopener" style="color:inherit;text-decoration:underline">\1</a>' , escaped )
159+ return _URL_RE .sub (
160+ r'<a href="\1" target="_blank" rel="noopener" style="color:inherit;text-decoration:underline">\1</a>' , escaped
161+ )
181162
182163
183164def render_diff_card (
184- title : str ,
185- badge_class : str ,
186- badge_label : str ,
187- bibtidy_comments : list [str ],
188- diff : list [tuple [str , str ]],
165+ title : str , badge_class : str , badge_label : str , bibtidy_comments : list [str ], diff : list [tuple [str , str ]]
189166) -> str :
190167 add_count = sum (1 for t , _ in diff if t == "add" ) + len (bibtidy_comments )
191168 del_count = sum (1 for t , _ in diff if t == "del" )
@@ -513,10 +490,6 @@ def build_html(cards_html: str) -> str:
513490"""
514491
515492
516- # ---------------------------------------------------------------------------
517- # Main
518- # ---------------------------------------------------------------------------
519-
520493def main () -> None :
521494 input_text = INPUT_BIB .read_text ()
522495 expected_text = EXPECTED_BIB .read_text ()
0 commit comments