Skip to content

Fix YAML front matter generation to handle special characters#101

Merged
izzortsi merged 2 commits intofeature/automated-semantic-analysisfrom
copilot/sub-pr-79-another-one
Nov 14, 2025
Merged

Fix YAML front matter generation to handle special characters#101
izzortsi merged 2 commits intofeature/automated-semantic-analysisfrom
copilot/sub-pr-79-another-one

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 14, 2025

YAML front matter in generated concept files was using string interpolation, causing parse errors when concept names or tags contained special characters (:, ", {, [, #, etc.).

Changes

  • Replace manual YAML string formatting with yaml.safe_dump() for proper escaping
  • Add missing Counter import from collections

Before/After

# Before: breaks on "Concept: Example" or tags with colons
content = f"""---
title: {self.name}
tags: [{', '.join(sorted(self.keywords))}]
---"""

# After: proper YAML serialization
frontmatter = {
    'title': self.name,
    'tags': sorted(self.keywords),
    'hierarchy': hierarchy,
    'related': sorted(self.related_concepts)
}
yaml_str = yaml.safe_dump(frontmatter, default_flow_style=False, allow_unicode=True, sort_keys=False)
content = f"""---
{yaml_str}---"""

PyYAML is already in requirements.txt.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Nov 14, 2025
Co-authored-by: izzortsi <35747979+izzortsi@users.noreply.github.com>
Copilot AI changed the title [WIP] Update automated semantic analysis workflow based on feedback Fix YAML front matter generation to handle special characters Nov 14, 2025
Copilot AI requested a review from izzortsi November 14, 2025 01:02
@izzortsi izzortsi marked this pull request as ready for review November 14, 2025 01:14
@izzortsi izzortsi merged commit 4c46687 into feature/automated-semantic-analysis Nov 14, 2025
@izzortsi izzortsi deleted the copilot/sub-pr-79-another-one branch November 14, 2025 01:14
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.

2 participants