Skip to content

Commit 5dd31fa

Browse files
committed
Fix precommit and add github link
1 parent d0b0cdf commit 5dd31fa

2 files changed

Lines changed: 23 additions & 32 deletions

File tree

docs/build.py

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
OUTPUT_HTML = ROOT / "docs" / "index.html"
2020

2121

22-
# ---------------------------------------------------------------------------
23-
# BibTeX parsing
24-
# ---------------------------------------------------------------------------
25-
2622
def 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-
9279
def 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-
118101
def 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:
177156
def 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

183164
def 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-
520493
def main() -> None:
521494
input_text = INPUT_BIB.read_text()
522495
expected_text = EXPECTED_BIB.read_text()

docs/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,20 @@
8383
.header h1 { font-size: 2rem; font-weight: 600; margin-bottom: 0.5rem; }
8484
.header p { color: var(--text-muted); font-size: 1.1rem; }
8585

86+
.github-link {
87+
display: inline-flex;
88+
align-items: center;
89+
gap: 0.4rem;
90+
margin-top: 0.75rem;
91+
color: var(--text-muted);
92+
text-decoration: none;
93+
font-size: 0.9rem;
94+
}
95+
96+
.github-link:hover { color: var(--accent); }
97+
98+
.github-link svg { fill: currentColor; }
99+
86100
.container { max-width: 960px; margin: 0 auto; padding: 0 1rem 2rem; }
87101

88102
.tabs {
@@ -219,6 +233,10 @@
219233
<div class="container">
220234
<h1>bibtools</h1>
221235
<p>A bibliography toolkit for LaTeX &mdash; built as a Claude Code plugin.</p>
236+
<a class="github-link" href="https://github.com/mathpluscode/bibtools" target="_blank" rel="noopener">
237+
<svg height="18" width="18" viewBox="0 0 16 16"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z"/></svg>
238+
GitHub
239+
</a>
222240
</div>
223241
</div>
224242

0 commit comments

Comments
 (0)