Add HTMLHint validation with auto-fix to all 10 news generation workflows#703
Add HTMLHint validation with auto-fix to all 10 news generation workflows#703
Conversation
…e-news-generation.sh, and fixHtmlNesting in article-quality-enhancer.ts Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
There was a problem hiding this comment.
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.shto run HTMLHint on news articles and attempt auto-fix. - Updated all 10
news-*.mdworkflow instruction files to run HTMLHint + auto-fix before PR creation, and added unit tests forfixHtmlNesting.
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. |
.github/workflows/news-motions.md
Outdated
| 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 |
There was a problem hiding this comment.
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).
| 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 |
| 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 |
There was a problem hiding this comment.
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).
| 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 |
| 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 |
There was a problem hiding this comment.
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).
| 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 |
| 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 |
There was a problem hiding this comment.
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.
| npx htmlhint "news/*.html" --config .htmlhintrc || true | |
| npx htmlhint "news/*.html" --config .htmlhintrc |
scripts/validate-news-generation.sh
Outdated
| 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 |
There was a problem hiding this comment.
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).
| 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" |
| 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 |
There was a problem hiding this comment.
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.
| npx htmlhint "news/*.html" --config .htmlhintrc || true | |
| npx htmlhint "news/*.html" --config .htmlhintrc |
scripts/validate-news-generation.sh
Outdated
| 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=$? |
There was a problem hiding this comment.
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.
| 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=$? |
| 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 |
There was a problem hiding this comment.
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).
| 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 |
.github/workflows/news-week-ahead.md
Outdated
| 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 |
There was a problem hiding this comment.
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).
| 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 |
| 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 |
There was a problem hiding this comment.
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).
| 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 apply changes based on the comments in this thread |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
…n failure, show htmlhint errors, update docstring Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Applied all review feedback in commit
|
Signed-off-by: James Pether Sörling <pethers@users.noreply.github.com>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
| 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 |
There was a problem hiding this comment.
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).
| 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 |
scripts/article-quality-enhancer.ts
Outdated
| * 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) |
There was a problem hiding this comment.
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.
| * 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 |
| 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 |
There was a problem hiding this comment.
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.
| 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 |
| 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 |
There was a problem hiding this comment.
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).
| 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 apply changes based on the comments in this thread |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
…ding in fixHtmlNesting Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Applied both fixes in commit
|
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
scripts/validate-news-generation.sh
Outdated
| 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 |
There was a problem hiding this comment.
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.
| npx tsx scripts/article-quality-enhancer.ts --fix 2>/dev/null || true | |
| npx tsx scripts/article-quality-enhancer.ts --fix || true |
There was a problem hiding this comment.
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=$? | ||
|
|
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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=$? | ||
|
|
There was a problem hiding this comment.
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.
| if [ "$VALIDATION_EXIT" -ne 0 ]; then | |
| echo "❌ News generation validation failed. Fix the reported issues before creating a PR." | |
| exit "$VALIDATION_EXIT" | |
| fi |
| @@ -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) | |||
There was a problem hiding this comment.
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.
| 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) |
| 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) |
There was a problem hiding this comment.
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.
| 11. ⚠️ HTMLHint validation on news articles (warning level; auto-fix attempted) | |
| 9. ⚠️ HTMLHint validation on news articles (warning level; auto-fix attempted) |
There was a problem hiding this comment.
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=$? | ||
|
|
There was a problem hiding this comment.
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.
| 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 |
| ```bash | ||
| bash scripts/validate-news-generation.sh | ||
| VALIDATION_EXIT=$? | ||
|
|
There was a problem hiding this comment.
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.
| 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 |
| ```bash | ||
| bash scripts/validate-news-generation.sh | ||
| VALIDATION_EXIT=$? | ||
|
|
There was a problem hiding this comment.
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.
| 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 |
| 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) |
There was a problem hiding this comment.
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.
| 11. ⚠️ HTMLHint validation on news articles (warning level; auto-fix attempted) | |
| 9. ⚠️ HTMLHint validation on news articles (warning level; auto-fix attempted) |
| /** | ||
| * 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; | ||
|
|
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
|
@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>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
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()inscripts/article-quality-enhancer.ts: Renamed fromfixHtmlNestingto avoid collision with the existingfixHtmlNesting()inscripts/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): Runsnpx htmlhint "news/*-*.html"(no--configflag, consistent withquality-checks.yml), captures and prints HTMLHint output when errors are found, attempts auto-fix vianpx tsx scripts/article-quality-enhancer.ts --fixwith stderr visible for debugging, then re-validates and warns if errors remain. Missingfifixed; redundantgrep -v 'index'removed.All 10
news-*.mdworkflow files: HTMLHint runs onnews/*-*.htmlglob (no--config .htmlhintrc); second HTMLHint run after auto-fix exits 1 if errors remain, blocking PR creation;VALIDATION_EXITguard added sovalidate-news-generation.shfailures also gate the workflow; validation checklist numbering corrected to include checks 9 and 10.--fixCLI default glob: Changed fromnews/*.html→news/*-*.htmlso 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
npx vitest run)validate-news-generation.shbash syntax is valid (no unclosedifblocks)--configflag — consistent with existingquality-checks.ymlworkflow<p><ul>/<p><ol>fix removes enclosing<p>entirely (no extra spacing)Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.