Skip to content

Commit 1fa3001

Browse files
iOSDevSKclaude
andcommitted
Release 1.0.0-beta.28 (from f516903)
Synced from iOSDevSK/html2wp-sub-protected feature/dual-target @ f516903df842338c5a32635e900e0ef86c005cd8 by tools/sync-cc.sh / tools/sync-codex.sh, verified: scripts parse, manifests agree, moat and closure clean, no debris, no secrets. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xf7wTz9XZFZ1GCWzDzHaWW
1 parent d71cfd7 commit 1fa3001

2 files changed

Lines changed: 26 additions & 8 deletions

File tree

‎skills/html2wp/assets/scripts/gutenberg-plan.py‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,17 @@ def diff_walk(nodes, metas, overrides, values, mapper, native_title=True, stop=N
254254
overrides[id(first)] = {'title': True} if native_title else {'leaf': [(plain(first), 'postTitle', None)]}
255255
return
256256
# A card list whose headings are its posts' titles but for one (the source
257-
# listing named one post differently from its page): the heading is still
258-
# the title, and the odd card is reported.
257+
# listing named one post differently from its page): the heading binds the
258+
# post's card headline, which is the title unless the post keeps its own
259+
# (the odd card's words, recorded per post), and the odd card is reported.
259260
matched = [bool(m.get('title')) and t == norm(m['title']) for t, m in zip(texts, metas)]
260261
if card and first.tag in HEADINGS and len(nodes) >= 3 and matched.count(False) == 1 and all(texts) and len(set(texts)) == len(texts):
261262
odd = texts[matched.index(False)]
262-
mapper.finding('query-card-title', 'A card heading differs from its post title and shows the title instead: ' + odd[:120])
263-
overrides[id(first)] = {'leaf': [(plain(first), 'postTitle', None)]}
263+
mapper.finding('query-card-title', 'Card headline differs from its post title; kept per post as the card title: ' + odd[:120])
264+
overrides[id(first)] = {'leaf': [(plain(first), 'postCardTitle', None)]}
265+
for store, text, same in zip(values or [], texts, matched):
266+
if not same:
267+
store.setdefault('postCardTitle', (text, None))
264268
return
265269

266270
def record(bind, fmt, per_instance):
@@ -1021,6 +1025,9 @@ def query_block(self, node, targets, cards=None):
10211025
cut = lambda value: value.endswith(('...', '…'))
10221026
if not seen or (cut(seen) and text.startswith(seen.rstrip('.… ')) and len(text) > len(seen)):
10231027
self.posts[key]['cardExcerpt'] = text
1028+
# A card that names its post differently keeps those words per post.
1029+
if values.get('postCardTitle') and not self.posts[key].get('cardTitle'):
1030+
self.posts[key]['cardTitle'] = values['postCardTitle'][0]
10241031
# The date a card prints is that post's publication date.
10251032
if values.get('postDate') and not self.posts[key].get('cardDate'):
10261033
parsed = parse_date(values['postDate'][0])
@@ -3032,6 +3039,8 @@ def convert(href):
30323039
cut = stated.endswith(('...', '…')) and norm(meta.get('cardExcerpt') or '').startswith(stated.rstrip('.… ')) if meta else False
30333040
if entry['kind'] == 'post' and meta and meta.get('cardExcerpt') and (not given.get('excerpt') or cut):
30343041
proposals[entry['key']].setdefault('post', {})['excerpt'] = meta['cardExcerpt']
3042+
if entry['kind'] == 'post' and meta and meta.get('cardTitle') and not given.get('cardTitle'):
3043+
proposals[entry['key']].setdefault('post', {})['cardTitle'] = meta['cardTitle']
30353044
if entry['kind'] == 'post' and meta and meta.get('cardDate') and not given.get('date') and not (proposals[entry['key']].get('post') or {}).get('date'):
30363045
proposals[entry['key']].setdefault('post', {})['date'] = meta['cardDate']
30373046
if entry['kind'] == 'post' and meta and meta.get('cardImage') and not given.get('featuredImage') and not (proposals[entry['key']].get('post') or {}).get('featuredImage'):

‎skills/html2wp/assets/scripts/gutenberg-test-plan.py‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,12 +1144,21 @@ def find(blocks, name):
11441144
yield block
11451145
yield from PlanTest.find(block.get('innerBlocks', []), name)
11461146

1147-
def test_a_card_heading_that_differs_from_one_post_title_still_binds_the_title(self):
1148-
_, proposals, findings = self.blog_site(odd_title=True)
1147+
def test_a_card_heading_that_differs_from_one_post_title_is_kept_per_post(self):
1148+
# The odd card's words are that post's card title: the listing binds
1149+
# postCardTitle (the title unless a post keeps its own), the article
1150+
# keeps its real title, and the slip is reported as information.
1151+
contract, proposals, findings = self.blog_site(odd_title=True)
11491152
query = next(self.find(proposals['blog']['blocks'], 'core/query'))
11501153
binds = [b['attributes'].get('bind') for b in planner.walk_blocks([query]) if b['name'] == 'h2wp/element']
1151-
self.assertIn('postTitle', binds)
1152-
self.assertTrue([f for f in findings['blog'] if f['code'] == 'query-card-title' and 'A different card headline' in f['detail']])
1154+
self.assertIn('postCardTitle', binds)
1155+
self.assertNotIn('postTitle', binds)
1156+
titles = {k: (p.get('post') or {}).get('cardTitle') for k, p in proposals.items() if k.startswith('blog-')}
1157+
odd = [k for k, v in titles.items() if v]
1158+
self.assertEqual(len(odd), 1)
1159+
self.assertEqual(titles[odd[0]], 'A different card headline')
1160+
self.assertIn('core/post-title', json.dumps(contract['templates']['single']))
1161+
self.assertTrue([f for f in findings['blog'] if f['code'] == 'query-card-title' and 'A different card headline' in f['detail'] and 'kept per post' in f['detail']])
11531162

11541163
def test_a_stated_excerpt_cut_short_yields_to_the_card_s_whole_words(self):
11551164
_, proposals, _ = self.blog_site(stated={'blog-a': 'Catch excerpt that is...', 'blog-b': 'A stated excerpt of its own.'})

0 commit comments

Comments
 (0)