Skip to content

refactor: simplify ContentRenderer for clarity and DRY#11

Open
jdevalk wants to merge 1 commit intomainfrom
optimize/content-renderer
Open

refactor: simplify ContentRenderer for clarity and DRY#11
jdevalk wants to merge 1 commit intomainfrom
optimize/content-renderer

Conversation

@jdevalk
Copy link
Member

@jdevalk jdevalk commented Feb 16, 2026

Simplifies ContentRenderer by eliminating duplication and reducing complexity:

  • Consolidate entity decoding logic: Use decode_entities() in escape_yaml() instead of duplicating the html_entity_decode() call
  • Combine string replacements: Merge two str_replace() calls in escape_yaml() into a single call for efficiency
  • Extract taxonomy term formatting: New format_taxonomy_terms() helper method eliminates DRY violation between category and tag rendering
  • Remove redundant variable initialization: Eliminate unnecessary $lang = '' declaration in strip_code_block_markup()
  • Remove obvious comments: Strip comments that simply restate what the code does

No functional changes — output remains identical.

🤖 Generated with Claude Code

- Consolidate entity decoding logic (use decode_entities() in escape_yaml())
- Combine string replacements in escape_yaml() for efficiency
- Extract taxonomy term formatting to helper method (eliminates DRY violation)
- Remove redundant variable initialization in strip_code_block_markup()
- Remove obvious comments that restate what code does

No functional changes — output remains identical.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Copy link

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

Refactors ContentRenderer to reduce duplication and simplify the frontmatter/YAML escaping logic while keeping the markdown output behavior the same.

Changes:

  • Extracted shared category/tag frontmatter rendering into format_taxonomy_terms().
  • Simplified escape_yaml() by reusing decode_entities() and consolidating escaping into a single str_replace() call.
  • Removed redundant inline comments and tightened $lang assignment logic in strip_code_block_markup().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jdevalk
Copy link
Member Author

jdevalk commented Feb 17, 2026

Consolidation note: overlaps with #14 in ContentRenderer. Recommend deciding one primary renderer path (merge one, rebase the other), to avoid churn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant