ringo380 / ringo380/QueryGrade

Normalize em/en dashes to plain hyphens across the tree

Open
#137 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Problem

The tree mixes Unicode dash characters with plain hyphens in prose. 168 occurrences across 51 tracked files:

  • 150 em-dashes (U+2014)
  • 18 en-dashes (U+2013)

Breakdown by area: 30 Python files, 17 templates/HTML, 1 CSS, 1 markdown, 2 other (Dockerfile.beat, .github/dependabot.yml).

Some of it is user-visible copy, not just comments:

analyzer/templates/analyzer/index.html:34: ...get a letter grade (A–F) with specific optimization recommendations.
analyzer/templates/analyzer/index.html:149: ...keep grading queries — plus unlock AI rewrite suggestions...

The A–F cases are en-dashes used as a range, which read fine as A-F.

Why it matters

It is inconsistent rather than broken. New code in the repo is written with plain hyphens, so the two styles are diverging, and the difference is invisible in review - an em-dash and a hyphen look nearly identical at normal text size, so nobody catches it in a diff. Doing it once mechanically is cheaper than deciding case by case forever.

Suggested fix

One mechanical substitution over tracked files:

git ls-files -z | xargs -0 perl -CSD -i -pe 's/[\x{2012}\x{2013}\x{2014}\x{2015}]/-/g'

Note that macOS BSD grep -P does not support \x{}, so use perl for the scan as well as the edit. Scan on raw bytes rather than -CSD so any binary file does not bury the result in "Malformed UTF-8" noise:

git ls-files -z | xargs -0 perl -ne 'print "$ARGV\n" if /\xe2\x80[\x92-\x95]/'

Verification

  • Assert the scanner finds a known hit before trusting a zero result. A scan that silently fails reports the same "0 occurrences" as a clean tree.
  • Prove the substitution touched only those characters: normalize the removed side of the diff and comm -13 it against the added side. Empty means a pure substitution and nothing else changed.
  • Convert source and test files in the same pass, so any exact-string assertion stays valid (both sides change identically). Checked: the only dash in a test file is in a comment (analyzer/test_integration.py:387), not an assertion, so the risk here is low.
  • Full suite should stay at 796, OK.

Caveat

Do not alter characters inside verbatim quotations if any are present - a quoted external string should keep its original punctuation.

Related

Noticed while working #133; deliberately kept out of PR #136 to keep that diff focused on behavior.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the tracked-file scanner and verify it finds a known hit, including analyzer/templates/analyzer/index.html:34 and :149. Apply the suggested substitution across tracked files, preserving any verbatim quotations, then verify the diff contains only dash substitutions and run the full suite; done means the scan is clean and the suite remains at 796 OK.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, perl, python
Domain
content, tooling
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.