Skip to content

Add HTMLHint validation with auto-fix to all 10 news generation workflows#703

Merged
pethers merged 14 commits intomainfrom
copilot/add-htmlhint-validation-step
Mar 1, 2026
Merged

Add HTMLHint validation with auto-fix to all 10 news generation workflows#703
pethers merged 14 commits intomainfrom
copilot/add-htmlhint-validation-step

Conversation

Copy link
Contributor

Copilot AI commented Mar 1, 2026

Adds HTMLHint-based HTML validation earlier in the agentic news-generation flow, with an auto-fix step for common invalid nesting patterns, and documents/adds the step across all 10 news workflow instruction files.

Changes Made

  • fixArticleHtmlNesting() in scripts/article-quality-enhancer.ts: Renamed from fixHtmlNesting to avoid collision with the existing fixHtmlNesting() in scripts/article-template/helpers.ts. All three nesting patterns (<p><ul>, <p><ol>, <p><div>) now remove the enclosing <p> entirely rather than inserting an empty <p></p>, eliminating extra vertical spacing from paragraph bottom-margin. Docstring updated to accurately describe all 6 transformations using correct block-level nesting terminology.

  • scripts/validate-news-generation.sh — Check 11 (HTMLHint): Runs npx htmlhint "news/*-*.html" (no --config flag, consistent with quality-checks.yml), captures and prints HTMLHint output when errors are found, attempts auto-fix via npx tsx scripts/article-quality-enhancer.ts --fix with stderr visible for debugging, then re-validates and warns if errors remain. Missing fi fixed; redundant grep -v 'index' removed.

  • All 10 news-*.md workflow files: HTMLHint runs on news/*-*.html glob (no --config .htmlhintrc); second HTMLHint run after auto-fix exits 1 if errors remain, blocking PR creation; VALIDATION_EXIT guard added so validate-news-generation.sh failures also gate the workflow; validation checklist numbering corrected to include checks 9 and 10.

  • --fix CLI default glob: Changed from news/*.htmlnews/*-*.html so running the fixer without arguments targets article files only.

  • Unit tests: 10 tests covering fixArticleHtmlNesting()<ul>, <ol>, <p><div>, orphaned </p>, orphaned </div></p>, valid HTML no-op, and empty string cases. All tests pass.

Testing

  • ✅ All unit tests pass (npx vitest run)
  • validate-news-generation.sh bash syntax is valid (no unclosed if blocks)
  • ✅ HTMLHint invoked without --config flag — consistent with existing quality-checks.yml workflow
  • <p><ul>/<p><ol> fix removes enclosing <p> entirely (no extra spacing)
Original prompt

This section details on the original issue you should resolve

<issue_title>Add HTMLHint validation step to news generation workflows</issue_title>
<issue_description>## 📋 Issue Type
News Generation / Quality

🎯 Objective

Add a post-generation HTML validation step to news generation workflows that catches invalid HTML before articles are committed to the repository.

📊 Current State

  • News articles are generated by agentic workflows and committed directly via PR
  • HTMLHint validation only runs in the quality-checks.yml workflow (after merge)
  • Invalid HTML (like <p><ul>...</ul></p> nesting) can make it into the repository
  • The scripts/validate-news-generation.sh has 10 checks but doesn't include HTMLHint validation
  • scripts/article-quality-enhancer.ts checks navigation elements but not HTML validity

🚀 Desired State

  • HTMLHint validation runs as part of every news generation workflow before PR creation
  • Articles with HTML errors are either auto-fixed or flagged for review
  • Zero invalid HTML articles committed to main branch
  • Quality gate prevents merging news PRs with HTML errors

🔧 Implementation Approach

  1. Add HTMLHint step to each news workflow .md file's steps section:
- name: Validate generated articles
  run: |
    npx htmlhint news/*.html
    if [ $? -ne 0 ]; then
      echo "⚠️ HTML validation errors found, attempting auto-fix..."
      npx tsx scripts/article-quality-enhancer.ts --fix
      npx htmlhint news/*.html
    fi
  1. Enhance article-quality-enhancer.ts to fix common HTML nesting issues:
    • <p><ul> → close </p> before <ul>
    • <p><div> → remove enclosing <p>
    • Orphaned </p> after </ul> → remove
  2. Add HTMLHint as a check in validate-news-generation.sh (Check 11)
  3. Update all 10 news workflow .md files

🤖 Recommended Agent

code-quality-engineer — News quality validation

✅ Acceptance Criteria

  • HTMLHint runs in all 10 news generation workflows
  • Auto-fix handles common HTML nesting issues
  • Zero HTML validation errors in newly generated articles
  • validate-news-generation.sh includes HTML validation check
  • Existing article errors documented/fixed

📚 References

  • Validator: scripts/validate-news-generation.sh
  • Quality enhancer: scripts/article-quality-enhancer.ts
  • News workflows: .github/workflows/news-*.md (10 files)
  • HTML utils: scripts/html-utils.ts

🏷️ Labels

type:quality, priority:high, component:news-generation</issue_description>

<agent_instructions>Add HTMLHint validation step to all 10 news workflow .md files. Enhance article-quality-enhancer.ts to fix common nesting issues like <p><ul>. Add HTMLHint as Check 11 in validate-news-generation.sh.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…e-news-generation.sh, and fixHtmlNesting in article-quality-enhancer.ts

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Copilot AI changed the title [WIP] Add HTMLHint validation to news generation workflows Add HTMLHint validation with auto-fix to all 10 news generation workflows Mar 1, 2026
@github-actions github-actions bot added documentation Documentation updates workflow GitHub Actions workflows ci-cd CI/CD pipeline changes testing Test coverage refactor Code refactoring news News articles and content generation agentic-workflow Agentic workflow changes size-l Large change (250-1000 lines) labels Mar 1, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds HTML validation earlier in the agentic news-generation flow by introducing an HTMLHint-based check with an attempted auto-fix for common invalid nesting patterns, and documenting/adding the step across the 10 news workflow instruction files.

Changes:

  • Added fixHtmlNesting() (+ file/CLI helpers) to auto-correct common invalid HTML nesting in generated news articles.
  • Added Check 11 to validate-news-generation.sh to run HTMLHint on news articles and attempt auto-fix.
  • Updated all 10 news-*.md workflow instruction files to run HTMLHint + auto-fix before PR creation, and added unit tests for fixHtmlNesting.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
tests/article-navigation-validation.test.ts Adds unit tests for the new fixHtmlNesting() helper.
scripts/article-quality-enhancer.ts Introduces regex-based HTML nesting fixes and a --fix CLI mode for in-place remediation.
scripts/validate-news-generation.sh Adds Check 11 to HTMLHint-validate news HTML and attempt an auto-fix pass.
.github/workflows/news-article-generator.md Documents running HTMLHint with attempted auto-fix before PR creation.
.github/workflows/news-committee-reports.md Documents running HTMLHint with attempted auto-fix before PR creation.
.github/workflows/news-evening-analysis.md Documents HTMLHint check 11 and manual HTMLHint auto-fix guidance.
.github/workflows/news-month-ahead.md Documents running HTMLHint with attempted auto-fix before PR creation.
.github/workflows/news-monthly-review.md Documents running HTMLHint with attempted auto-fix before PR creation.
.github/workflows/news-motions.md Documents running HTMLHint with attempted auto-fix before PR creation.
.github/workflows/news-propositions.md Documents running HTMLHint with attempted auto-fix before PR creation.
.github/workflows/news-realtime-monitor.md Documents HTMLHint check 11 and manual HTMLHint auto-fix guidance.
.github/workflows/news-week-ahead.md Documents running HTMLHint with attempted auto-fix before PR creation.
.github/workflows/news-weekly-review.md Documents running HTMLHint with attempted auto-fix before PR creation.

Comment on lines 242 to 245
if ! npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
npx htmlhint "news/*.html" --config .htmlhintrc || true
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The re-validation step uses npx htmlhint ... || true, which ignores remaining HTMLHint failures and allows proceeding to PR creation even if invalid HTML remains. If this is intended as a pre-PR gate, consider failing/stopping when the second HTMLHint run still reports errors (and optionally align the validated file glob with the *-*.html count to avoid linting index files).

Suggested change
if ! npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
npx htmlhint "news/*.html" --config .htmlhintrc || true
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
npx htmlhint "news/*-*.html" --config .htmlhintrc

Copilot uses AI. Check for mistakes.
Comment on lines 243 to 246
if ! npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
npx htmlhint "news/*.html" --config .htmlhintrc || true
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The re-validation step uses npx htmlhint ... || true, which ignores remaining HTMLHint failures and allows proceeding to PR creation even if invalid HTML remains. If this is intended as a pre-PR gate, consider failing/stopping when the second HTMLHint run still reports errors (and optionally align the validated file glob with the *-*.html count to avoid linting index files).

Suggested change
if ! npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
npx htmlhint "news/*.html" --config .htmlhintrc || true
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
npx htmlhint "news/*-*.html" --config .htmlhintrc

Copilot uses AI. Check for mistakes.
Comment on lines 305 to 308
if ! npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
npx htmlhint "news/*.html" --config .htmlhintrc || true
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The re-validation step uses npx htmlhint ... || true, which ignores remaining HTMLHint failures and allows proceeding to PR creation even if invalid HTML remains. If this is intended as a pre-PR gate, consider failing/stopping when the second HTMLHint run still reports errors (and optionally align the validated file glob with the *-*.html count to avoid linting index files).

Suggested change
if ! npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
npx htmlhint "news/*.html" --config .htmlhintrc || true
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc; then
echo "❌ HTML validation errors remain after auto-fix. Please fix them before creating a PR."
exit 1
fi

Copilot uses AI. Check for mistakes.
if ! npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
npx htmlhint "news/*.html" --config .htmlhintrc || true
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The re-validation step uses npx htmlhint ... || true, which ignores remaining HTMLHint failures and allows proceeding even if invalid HTML remains. If the intent is to prevent invalid HTML from reaching a PR, consider letting the second HTMLHint run fail (or explicitly stop PR creation) when errors remain.

Suggested change
npx htmlhint "news/*.html" --config .htmlhintrc || true
npx htmlhint "news/*.html" --config .htmlhintrc

Copilot uses AI. Check for mistakes.
Comment on lines 337 to 343
npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null || HTMLHINT_RESULT=$?
if [ $HTMLHINT_RESULT -ne 0 ]; then
echo -e "${YELLOW}⚠️ HTMLHint found errors in news articles (attempting auto-fix)${NC}"
npx tsx scripts/article-quality-enhancer.ts --fix 2>/dev/null || true
HTMLHINT_RESULT2=0
npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null || HTMLHINT_RESULT2=$?
if [ $HTMLHINT_RESULT2 -ne 0 ]; then
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both HTMLHint runs redirect stderr to /dev/null, which hides the actual validation errors and makes it hard to review what remains broken (especially when auto-fix doesn’t resolve everything). Recommend only suppressing output on success, and printing HTMLHint output when it fails (at least for the second/remaining-errors case).

Suggested change
npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null || HTMLHINT_RESULT=$?
if [ $HTMLHINT_RESULT -ne 0 ]; then
echo -e "${YELLOW}⚠️ HTMLHint found errors in news articles (attempting auto-fix)${NC}"
npx tsx scripts/article-quality-enhancer.ts --fix 2>/dev/null || true
HTMLHINT_RESULT2=0
npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null || HTMLHINT_RESULT2=$?
if [ $HTMLHINT_RESULT2 -ne 0 ]; then
HTMLHINT_OUTPUT=$(npx htmlhint "news/*.html" --config .htmlhintrc 2>&1) || HTMLHINT_RESULT=$?
if [ $HTMLHINT_RESULT -ne 0 ]; then
# Show initial HTMLHint errors to aid debugging before attempting auto-fix
echo "$HTMLHINT_OUTPUT"
echo -e "${YELLOW}⚠️ HTMLHint found errors in news articles (attempting auto-fix)${NC}"
npx tsx scripts/article-quality-enhancer.ts --fix 2>/dev/null || true
HTMLHINT_RESULT2=0
HTMLHINT_OUTPUT2=$(npx htmlhint "news/*.html" --config .htmlhintrc 2>&1) || HTMLHINT_RESULT2=$?
if [ $HTMLHINT_RESULT2 -ne 0 ]; then
# Show remaining HTMLHint errors so they can be fixed before merging
echo "$HTMLHINT_OUTPUT2"

Copilot uses AI. Check for mistakes.
if ! npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
npx htmlhint "news/*.html" --config .htmlhintrc || true
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The re-validation step uses npx htmlhint ... || true, which ignores remaining HTMLHint failures and allows proceeding even if invalid HTML remains. If the intent is to prevent invalid HTML from reaching a PR, consider letting the second HTMLHint run fail (or explicitly stop PR creation) when errors remain.

Suggested change
npx htmlhint "news/*.html" --config .htmlhintrc || true
npx htmlhint "news/*.html" --config .htmlhintrc

Copilot uses AI. Check for mistakes.
Comment on lines 337 to 342
npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null || HTMLHINT_RESULT=$?
if [ $HTMLHINT_RESULT -ne 0 ]; then
echo -e "${YELLOW}⚠️ HTMLHint found errors in news articles (attempting auto-fix)${NC}"
npx tsx scripts/article-quality-enhancer.ts --fix 2>/dev/null || true
HTMLHINT_RESULT2=0
npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null || HTMLHINT_RESULT2=$?
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file count explicitly excludes index files (via grep -v 'index'), but the HTMLHint invocation validates news/*.html, which will include news/index*.html if those files exist locally. This can cause unexpected failures or fixes on build-time generated files. Consider validating only the article pattern (e.g., news/*-*.html excluding index) and keep the count/validation patterns consistent.

Suggested change
npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null || HTMLHINT_RESULT=$?
if [ $HTMLHINT_RESULT -ne 0 ]; then
echo -e "${YELLOW}⚠️ HTMLHint found errors in news articles (attempting auto-fix)${NC}"
npx tsx scripts/article-quality-enhancer.ts --fix 2>/dev/null || true
HTMLHINT_RESULT2=0
npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null || HTMLHINT_RESULT2=$?
npx htmlhint "news/*-*.html" --config .htmlhintrc 2>/dev/null || HTMLHINT_RESULT=$?
if [ $HTMLHINT_RESULT -ne 0 ]; then
echo -e "${YELLOW}⚠️ HTMLHint found errors in news articles (attempting auto-fix)${NC}"
npx tsx scripts/article-quality-enhancer.ts --fix 2>/dev/null || true
HTMLHINT_RESULT2=0
npx htmlhint "news/*-*.html" --config .htmlhintrc 2>/dev/null || HTMLHINT_RESULT2=$?

Copilot uses AI. Check for mistakes.
Comment on lines 246 to 249
if ! npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
npx htmlhint "news/*.html" --config .htmlhintrc || true
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The re-validation step uses npx htmlhint ... || true, which ignores remaining HTMLHint failures and allows proceeding to PR creation even if invalid HTML remains. If this is intended as a pre-PR gate, consider failing/stopping when the second HTMLHint run still reports errors (and optionally align the validated file glob with the *-*.html count to avoid linting index files).

Suggested change
if ! npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
npx htmlhint "news/*.html" --config .htmlhintrc || true
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc; then
echo "❌ HTML validation failed after auto-fix. Please fix remaining issues before creating PR."
exit 1
fi

Copilot uses AI. Check for mistakes.
Comment on lines 239 to 244
NEWS_FILES=$(find news -maxdepth 1 -name '*-*.html' | grep -v 'index' | wc -l)
if [ "$NEWS_FILES" -gt 0 ]; then
if ! npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
npx htmlhint "news/*.html" --config .htmlhintrc || true
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The re-validation step uses npx htmlhint ... || true, which ignores remaining HTMLHint failures and allows proceeding to PR creation even if invalid HTML remains. If this is intended as a pre-PR gate, consider failing/stopping when the second HTMLHint run still reports errors (and optionally align the validated file glob with the *-*.html count to avoid linting index files).

Suggested change
NEWS_FILES=$(find news -maxdepth 1 -name '*-*.html' | grep -v 'index' | wc -l)
if [ "$NEWS_FILES" -gt 0 ]; then
if ! npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
npx htmlhint "news/*.html" --config .htmlhintrc || true
NEWS_FILES=$(find news -maxdepth 1 -name '*-*.html' | wc -l)
if [ "$NEWS_FILES" -gt 0 ]; then
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc; then
echo "❌ HTML validation failed after auto-fix. Please fix remaining HTMLHint errors before creating a PR."
exit 1
fi

Copilot uses AI. Check for mistakes.
Comment on lines 241 to 244
if ! npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
npx htmlhint "news/*.html" --config .htmlhintrc || true
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The re-validation step uses npx htmlhint ... || true, which ignores remaining HTMLHint failures and allows proceeding to PR creation even if invalid HTML remains. If this is intended as a pre-PR gate, consider failing/stopping when the second HTMLHint run still reports errors (and optionally align the validated file glob with the *-*.html count to avoid linting index files).

Suggested change
if ! npx htmlhint "news/*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
npx htmlhint "news/*.html" --config .htmlhintrc || true
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc; then
echo "❌ HTML validation failed after auto-fix. Please resolve remaining HTMLHint errors before creating a PR."
exit 1
fi

Copilot uses AI. Check for mistakes.
@pethers
Copy link
Member

pethers commented Mar 1, 2026

@copilot apply changes based on the comments in this thread

@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

…n failure, show htmlhint errors, update docstring

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 1, 2026

@copilot apply changes based on the comments in this thread

Applied all review feedback in commit 47e7c2e:

  • Glob: Changed news/*.htmlnews/*-*.html in all 10 workflows and validate-news-generation.sh to avoid linting build-time index files
  • No more || true: All 10 workflows now use if ! npx htmlhint ... ; then exit 1 ; fi after the auto-fix attempt, consistently blocking PR creation when errors remain
  • Error visibility: validate-news-generation.sh now captures and prints HTMLHint output before and after the auto-fix attempt (instead of suppressing with 2>/dev/null)
  • Docstring: Updated fixHtmlNesting() to list all 6 transformations it performs (<p><ol>, </ol></p>, </div></p> were previously unlisted)

Signed-off-by: James Pether Sörling <pethers@users.noreply.github.com>
@pethers pethers requested a review from Copilot March 1, 2026 11:23
@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Comment on lines 1170 to 1173
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc; then
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This HTML validation snippet calls npx htmlhint "news/*-*.html" --config .htmlhintrc, but the repo doesn’t contain a .htmlhintrc file. That will make the step fail due to missing config rather than actual HTML problems. Either add .htmlhintrc in this PR or remove the --config flag to use HTMLHint defaults (consistent with the existing quality-checks workflow).

Suggested change
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc; then
if ! npx htmlhint "news/*-*.html" 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
if ! npx htmlhint "news/*-*.html"; then

Copilot uses AI. Check for mistakes.
Comment on lines 429 to 432
* Corrects:
* - `<p><ul>` → closes `</p>` before `<ul>` (block element inside inline)
* - `<p><ol>` → closes `</p>` before `<ol>` (block element inside inline)
* - `<p><div>` → removes enclosing `<p>` (block element inside inline)
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring describes the issue as “block element inside inline”, but <p> is itself block-level; the real constraint is that <p> can’t contain other block-level elements like <ul>/<ol>/<div>. Updating the wording would avoid confusion for future maintainers.

Suggested change
* Corrects:
* - `<p><ul>` closes `</p>` before `<ul>` (block element inside inline)
* - `<p><ol>` closes `</p>` before `<ol>` (block element inside inline)
* - `<p><div>` removes enclosing `<p>` (block element inside inline)
* Corrects invalid block-level nesting patterns:
* - `<p><ul>` closes `</p>` before `<ul>` so the `<ul>` list is not nested inside a `<p>` paragraph
* - `<p><ol>` closes `</p>` before `<ol>` so the `<ol>` list is not nested inside a `<p>` paragraph
* - `<p><div>` removes the enclosing `<p>` so the block-level `<div>` is not nested inside a `<p>` paragraph

Copilot uses AI. Check for mistakes.
Comment on lines 1013 to 1016
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc; then
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HTMLHint commands use --config .htmlhintrc, but there is no .htmlhintrc in the repository. This will cause the validation to fail immediately due to missing config, independent of article HTML quality. Either include the config file in this PR or remove --config .htmlhintrc here.

Suggested change
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc; then
if ! npx htmlhint "news/*-*.html" 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
if ! npx htmlhint "news/*-*.html"; then

Copilot uses AI. Check for mistakes.
Comment on lines 812 to 815
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc; then
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTMLHint is run with --config .htmlhintrc, but the repository doesn’t include a .htmlhintrc file. As written, this command will fail due to missing config rather than actual HTML issues. Either add the config file or remove the --config flag here (and in other workflow instructions).

Suggested change
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
if ! npx htmlhint "news/*-*.html" --config .htmlhintrc; then
if ! npx htmlhint "news/*-*.html" 2>/dev/null; then
echo "⚠️ HTML validation errors found, attempting auto-fix..."
npx tsx scripts/article-quality-enhancer.ts --fix
if ! npx htmlhint "news/*-*.html"; then

Copilot uses AI. Check for mistakes.
@pethers
Copy link
Member

pethers commented Mar 1, 2026

@copilot apply changes based on the comments in this thread

@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

…ding in fixHtmlNesting

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 1, 2026

@copilot apply changes based on the comments in this thread

Applied both fixes in commit 91f9fec:

  • --config .htmlhintrc removed: Stripped from all 10 workflow .md files and validate-news-generation.sh. The repo has no .htmlhintrc, and existing workflows (quality-checks.yml) invoke htmlhint without --config.
  • Docstring wording: Replaced "block element inside inline" with the accurate explanation that <p> cannot contain other block-level elements (<ul>, <ol>, <div>).

@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 13 comments.

if [ $HTMLHINT_RESULT -ne 0 ]; then
echo "$HTMLHINT_OUTPUT"
echo -e "${YELLOW}⚠️ HTMLHint found errors in news articles (attempting auto-fix)${NC}"
npx tsx scripts/article-quality-enhancer.ts --fix 2>/dev/null || true
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The auto-fix step suppresses all stderr from tsx (2>/dev/null), which makes CI/local troubleshooting hard if the fixer crashes or can't load dependencies. Consider letting stderr through (or at least printing it when HTMLHint still fails) so reviewers can see why auto-fix didn't run.

Suggested change
npx tsx scripts/article-quality-enhancer.ts --fix 2>/dev/null || true
npx tsx scripts/article-quality-enhancer.ts --fix || true

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0393e7c: removed 2>/dev/null from the tsx auto-fix step so stderr always shows through.

```bash
bash scripts/validate-news-generation.sh
VALIDATION_EXIT=$?

Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VALIDATION_EXIT is captured but never used in this snippet. As written, validation errors from validate-news-generation.sh won’t stop PR creation guidance. Either remove the unused variable or add a check that exits (or otherwise clearly gates) when VALIDATION_EXIT is non-zero.

Suggested change
if [ "$VALIDATION_EXIT" -ne 0 ]; then
echo "❌ Validation script failed. Please fix the reported issues before proceeding to HTML validation or creating a PR."
exit "$VALIDATION_EXIT"
fi

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0393e7c: added if [ "$VALIDATION_EXIT" -ne 0 ]; then exit "$VALIDATION_EXIT"; fi after VALIDATION_EXIT=$? in all 7 workflow files where the guard was missing.

```bash
bash scripts/validate-news-generation.sh
VALIDATION_EXIT=$?

Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VALIDATION_EXIT is captured but never used in this snippet. As written, validation errors from validate-news-generation.sh won’t stop PR creation guidance. Either remove the unused variable or add a check that exits (or otherwise clearly gates) when VALIDATION_EXIT is non-zero.

Suggested change
if [ "$VALIDATION_EXIT" -ne 0 ]; then
echo "❌ News generation validation failed. Fix the reported issues before creating a PR."
exit "$VALIDATION_EXIT"
fi

Copilot uses AI. Check for mistakes.
@@ -1001,9 +1001,26 @@ This validation checks:
6. ✅ Index files have content (> 1KB) (blocking)
7. ⚠️ Sitemap news-URL coverage (validated at build time; missing sitemap.xml is OK — it's generated by prebuild)
8. ⚠️ Language switcher consistency across all 14 languages (warning level)
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documented validation checklist numbering now jumps from 8 to 11, which no longer matches the actual validate-news-generation.sh checks (it has checks 9 and 10 as well). Please update this list to include the missing check numbers/descriptions or renumber so it stays consistent with the script output.

Suggested change
8. ⚠️ Language switcher consistency across all 14 languages (warning level)
8. ⚠️ Language switcher consistency across all 14 languages (warning level)
9. ⚠️ Additional non-blocking quality checks as implemented in \`validate-news-generation.sh\` (warning level)
10. ✅ Additional blocking quality checks as implemented in \`validate-news-generation.sh\` (blocking)

Copilot uses AI. Check for mistakes.
6. ✅ Index files have content (> 1KB) (blocking)
7. ⚠️ Sitemap news-URL coverage (validated at build time; missing sitemap.xml is OK — it's generated by prebuild)
8. ⚠️ Language switcher consistency across all 14 languages (warning level)
11. ⚠️ HTMLHint validation on news articles (warning level; auto-fix attempted)
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documented validation checklist numbering now jumps from 8 to 11, which no longer matches the actual validate-news-generation.sh checks (it has checks 9 and 10 as well). Please update this list to include the missing check numbers/descriptions or renumber so it stays consistent with the script output.

Suggested change
11. ⚠️ HTMLHint validation on news articles (warning level; auto-fix attempted)
9. ⚠️ HTMLHint validation on news articles (warning level; auto-fix attempted)

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0393e7c: added the missing check 9 (article-top-nav) and check 10 (footer back-to-news link) so the list now runs 1–11 consecutively.

```bash
bash scripts/validate-news-generation.sh
VALIDATION_EXIT=$?

Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VALIDATION_EXIT is captured but never used in this snippet. As written, validation errors from validate-news-generation.sh won’t stop PR creation guidance. Either remove the unused variable or add a check that exits (or otherwise clearly gates) when VALIDATION_EXIT is non-zero.

Suggested change
if [ "$VALIDATION_EXIT" -ne 0 ]; then
echo "❌ Validation failed (scripts/validate-news-generation.sh). Please fix the reported issues before running HTMLHint or creating a PR."
exit "$VALIDATION_EXIT"
fi

Copilot uses AI. Check for mistakes.
```bash
bash scripts/validate-news-generation.sh
VALIDATION_EXIT=$?

Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VALIDATION_EXIT is captured but never used in this snippet. As written, validation errors from validate-news-generation.sh won’t stop PR creation guidance. Either remove the unused variable or add a check that exits (or otherwise clearly gates) when VALIDATION_EXIT is non-zero.

Suggested change
if [ "$VALIDATION_EXIT" -ne 0 ]; then
echo "❌ News generation validation failed (exit code $VALIDATION_EXIT). Please fix the reported issues before creating a PR."
exit "$VALIDATION_EXIT"
fi

Copilot uses AI. Check for mistakes.
```bash
bash scripts/validate-news-generation.sh
VALIDATION_EXIT=$?

Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VALIDATION_EXIT is captured but never used in this snippet. As written, validation errors from validate-news-generation.sh won’t stop PR creation guidance. Either remove the unused variable or add a check that exits (or otherwise clearly gates) when VALIDATION_EXIT is non-zero.

Suggested change
if [ "$VALIDATION_EXIT" -ne 0 ]; then
echo "❌ News generation validation failed. Please fix the reported issues before running HTMLHint or creating a PR."
exit "$VALIDATION_EXIT"
fi

Copilot uses AI. Check for mistakes.
6. ℹ️ Index files have content (skipped — index files generated at build time)
7. ⚠️ Sitemap news-URL coverage (warning; missing sitemap.xml is OK — generated by prebuild)
8. ⚠️ Language switcher consistency across all 14 languages (warning level)
11. ⚠️ HTMLHint validation on news articles (warning level; auto-fix attempted)
Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documented validation checklist numbering now jumps from 8 to 11, which no longer matches the actual validate-news-generation.sh checks (it has checks 9 and 10 as well). Please update this list to include the missing check numbers/descriptions or renumber so it stays consistent with the script output.

Suggested change
11. ⚠️ HTMLHint validation on news articles (warning level; auto-fix attempted)
9. ⚠️ HTMLHint validation on news articles (warning level; auto-fix attempted)

Copilot uses AI. Check for mistakes.
Comment on lines 426 to 442
/**
* Fix common HTML nesting errors in article content.
*
* Corrects invalid block-level nesting patterns:
* - `<p><ul>` → closes `</p>` before `<ul>` so the `<ul>` list is not nested inside a `<p>` paragraph
* - `<p><ol>` → closes `</p>` before `<ol>` so the `<ol>` list is not nested inside a `<p>` paragraph
* - `<p><div>` → removes the enclosing `<p>` so the block-level `<div>` is not nested inside a `<p>` paragraph
* - Orphaned `</p>` immediately after `</ul>` → removed
* - Orphaned `</p>` immediately after `</ol>` → removed
* - Orphaned `</p>` immediately after `</div>` (when wrapped by `<p>`) → removed
*
* @param content - Raw HTML content
* @returns Fixed HTML content
*/
export function fixHtmlNesting(content: string): string {
let fixed = content;

Copy link

Copilot AI Mar 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a fixHtmlNesting() helper in scripts/article-template/helpers.ts (currently used during article generation). Introducing a second fixHtmlNesting() with different behavior in article-quality-enhancer.ts risks divergence/confusion over which one to use. Consider reusing a shared implementation or renaming this function to make its scope explicit (e.g., enhancer-specific).

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0393e7c: renamed fixHtmlNesting in article-quality-enhancer.ts to fixArticleHtmlNesting to make its scope explicit and avoid confusion with the simpler fixHtmlNesting in article-template/helpers.ts.

@pethers
Copy link
Member

pethers commented Mar 1, 2026

@copilot apply changes based on the comments in this thread

… VALIDATION_EXIT guard, checklist fix

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.

@pethers pethers marked this pull request as ready for review March 1, 2026 13:36
@github-actions
Copy link
Contributor

github-actions bot commented Mar 1, 2026

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

@pethers pethers merged commit c003ff1 into main Mar 1, 2026
15 checks passed
@pethers pethers deleted the copilot/add-htmlhint-validation-step branch March 1, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentic-workflow Agentic workflow changes ci-cd CI/CD pipeline changes documentation Documentation updates news News articles and content generation refactor Code refactoring size-l Large change (250-1000 lines) testing Test coverage workflow GitHub Actions workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add HTMLHint validation step to news generation workflows

3 participants