fix: Fix encoding, blank lines, and append position in edit operations#201
Merged
rdmueller merged 2 commits intodocToolchain:mainfrom Jan 26, 2026
Merged
Conversation
This commit fixes three critical bugs in edit operations (update/insert): Issue docToolchain#193: Encoding problem with umlauts - Problem: .encode('utf-8').decode('unicode_escape') corrupted non-ASCII characters like umlauts (äöü ß) - Solution: Replaced with custom _process_escape_sequences() function that handles \n, \t, \r, \\ without corrupting UTF-8 characters - Files: src/dacli/cli.py Issue docToolchain#194: Missing blank lines after edit operations - Problem: Sections ended with single newline, causing sections to run together - Solution: Ensure content ends with blank line (two newlines) to properly separate sections - Files: src/dacli/services/content_service.py Issue docToolchain#197: append inserts at beginning instead of end - Problem: _get_section_append_line() only searched for '.' separator, missing Level-1 children that use ':' separator (e.g., 'doc:child') - Solution: Check for both ':' and '.' separators when finding descendants - Files: src/dacli/cli.py Changes: - Added _process_escape_sequences() helper function - Updated _get_section_append_line() to handle both path separators - Modified content_service.py to ensure blank lines between sections - Added comprehensive tests (12 new tests, all passing) Test coverage: - Encoding: umlauts, escape sequences, mixed content - Blank lines: preserved after update and insert - Append position: inserts at end, handles nested sections - Integration: combined bug fixes work together All 501 tests passing (no regressions) Fixes docToolchain#193, docToolchain#194, docToolchain#197 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fix linter errors from CI. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This was referenced Jan 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes three critical bugs in edit operations that affected content quality and document structure:
Problems & Solutions
Issue #193: Encoding Problem with Umlauts⚠️ HIGH
Problem:
This approach corrupted non-ASCII characters, making the tool unusable for German and other international documentation.
Solution:
_process_escape_sequences()function\n,\t,\r,\\without corrupting UTF-8 charactersäöü ßremain intactTest coverage:
Issue #194: Missing Blank Lines⚠️ HIGH
Problem:
Sections ended with single newline (
\n), causing sections to run together:== Section 1 Content == Section 2 ← No blank line!Solution:
\n\n)Test coverage:
Issue #197: Append Position Bug⚠️ HIGH
Problem:
--position appendinserted at the beginning instead of the end because_get_section_append_line()only searched for.separator, missing Level-1 children that use:separator.Example paths:
doc:child(Level 1 - uses:)doc:child.grandchild(Level 2+ - uses.)Solution:
:and.separatorsTest coverage:
Changes
Modified:
src/dacli/cli.py- Added_process_escape_sequences(), fixed_get_section_append_line()src/dacli/services/content_service.py- Ensure blank lines between sectionsAdded:
tests/test_edit_operations_bugs.py- 12 comprehensive tests for all three bugsTest Results
✅ 501 tests passing (12 new tests, no regressions)
New test coverage:
Encoding (6 tests):
Blank lines (2 tests):
Append position (2 tests):
Integration (2 tests):
Examples
Before (Broken):
After (Fixed):
Impact
Severity: HIGH - These bugs affected core functionality:
Backwards compatibility: No breaking changes, only fixes
Fixes #193, #194, #197
🤖 Generated with Claude Code