Preview checker: named entities like `’` and `—` show up as raw text
維護者通常 1 天內回覆
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 78/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- typescript
研究方向
Start with decodeEntities() and NAMED_ENTITIES in src/lib/meta-fetcher.ts, then review the existing parseMetaTags tests. Add the HTML 4 entity table in src/lib/html-entities.ts and update the entity name matching while preserving exact case and safe lookup behavior. Add a regression test for named entities with digits, then run npm run check, npm run test, and npm run build; done when the acceptance criteria pass.
由索引模型根據 Issue 內容生成。
描述
decodeEntities() in src/lib/meta-fetcher.ts only knows the ten names in NAMED_ENTITIES (line 190: amp, lt, gt, quot, apos, nbsp and the uppercase AMP, LT, GT, QUOT), so any other named entity reaches the preview checker as raw text. Typographic ones like ’, —, … and “ are common in titles and descriptions, and browsers show them as the characters (document.title gives Don’t ship on Fridays — notes from 200 releases | Acme Blog), but the checker keeps them:
parseMetaTags('<title>Don’t ship on Fridays — notes from 200 releases | Acme Blog</title>', 'https://example.com').title
// "Don’t ship on Fridays — notes from 200 releases | Acme Blog"
That 59-character title gets "Title is 71 chars (recommended: under 70)" from analyzeMeta(), every platform card shows the ’ and —, and the Google Search preview (resolvePlatformPreviews() in src/lib/platform-specs.ts) cuts it at 60 characters before | Acme Blog. Accented letters (é, É) and symbols (©, ™, €) stay raw the same way, and Smart Autofill (src/pages/api/ai/autofill.ts:63) hands the raw text to the model.
The regex has a second catch: it only matches names made of letters ([a-z]+), so ½, ² and the other names with digits can't decode even once they're in the table.
What to do
- Add the rest of the 252 named entities from HTML 4 (the Latin-1, symbol and special sets) to the table. That's where the typographic and accented-letter ones live, and it keeps the table to a few hundred lines instead of HTML5's full list of over 2,000. Put it in its own file, like
src/lib/html-entities.ts, someta-fetcher.tsstays readable, and keepaposand the four uppercase names that are there now. - Take the characters from the current list (https://html.spec.whatwg.org/entities.json), since a few changed after HTML 4 (
⟨and⟩are U+27E8 and U+27E9 now). - Names are case-sensitive, so keep the exact lookup (
ÉisÉ,éisé) and theObject.hasOwncheck from #391. - Let the regex match names with digits, like
[a-z][a-z0-9]*. Numeric entities already work, so leave that branch as it is.
Acceptance criteria
- The title above comes out as
Don’t ship on Fridays — notes from 200 releases | Acme Blog, and every HTML 4 named entity decodes in titles and attribute values, including½and² - Unknown names, wrong-case names like
&Amp;and&NBSP;, and prototype names like&constructor;stay as they are, and every existingparseMetaTagstest still passes - A test that fails on the current code
-
npm run check,npm run testandnpm run buildpass
Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off dev, and open your PR against dev with Closes #NUM in the description.
- 主要語言
- TypeScript
- 星號
- 8
- 分支
- 4
- 平均合併
- 8 小時 41 分鐘
- 30 天內合併 PR
- 157
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
codercops/ogcops 的其他 Issue
-
bug good first issue
難度 2/5 1-3 小時 新手友好度 84/100
codercops/ogcops#394 · 3 則留言 ·
維護者通常 1 天內回覆
-
Preview checker: a `<title>` written over several lines keeps its line break and indentation可能已有人在做 @bhushan4work 於 1 天前認領。 未關閉bug good first issue
難度 2/5 1-3 小時 新手友好度 84/100
codercops/ogcops#393 · 1 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
[Bug] “Copy Recommended Meta Tags” generates an unusable placeholder image URL可能重新可做 @CreatorguyS 於 8 天前認領,目前沒有進行中的 PR。 未關閉bug enhancement
難度 2/5 1-3 小時 新手友好度 72/100
codercops/ogcops#378 · 4 則留言 ·
維護者通常 1 天內回覆
-
Add the Transcript podcast template (`podcast-transcript`)可能已有人在做 @08abhinav 於 1 天前認領。 未關閉good first issue templates
codercops/ogcops#399 · 2 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
Add the Do and Don't tutorial template (`tutorial-do-dont`)可能已有人在做 @Ravindar-Amogh-Gummadavelly 於 8 天前認領。 未關閉good first issue templates
codercops/ogcops#355 · 2 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 70/100
backnotprop/plannotator#2914 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
microsoft/vscode-containers#655 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 77/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
dsh-tauri-desk/deepseek-harness-desktop#1477 · 1 則留言 ·