Skip to content

fix: render notion soft line breaks#50

Closed
luandro wants to merge 1 commit intomainfrom
fix/notion-soft-line-breaks
Closed

fix: render notion soft line breaks#50
luandro wants to merge 1 commit intomainfrom
fix/notion-soft-line-breaks

Conversation

@luandro
Copy link
Contributor

@luandro luandro commented Oct 10, 2025

Summary

  • add restoreSoftLineBreaks to translate Notion soft breaks into <br />
  • wire the helper into markdown export so Shift+Enter survives publishing
  • extend unit coverage and mocks for the new helper

Testing

  • bunx vitest run scripts/notion-fetch/contentSanitizer.test.ts
  • bunx vitest run scripts/notion-fetch/generateBlocks.test.ts

Closes #47

@luandro
Copy link
Contributor Author

luandro commented Oct 11, 2025

Verification Notes

  • restoreSoftLineBreaks() now runs right after markdown sanitization (scripts/notion-fetch/generateBlocks.ts:1550), converting single in-paragraph newlines into <br /> while skipping markdown structures. That preserves Shift+Enter breaks from Notion during export.
  • Helper is exported via scripts/notion-fetch/utils.ts so downstream code can share it, and unit coverage exercises normal breaks, double breaks, list markers, fenced code, and Notion Unicode separators (scripts/notion-fetch/contentSanitizer.test.ts).

How to test locally

  1. In Notion, insert text with a manual line break (Shift+Enter) on a test page.
  2. Run the standard sync that regenerates docs (e.g. bun scripts/notion-fetch with your usual filters).
  3. Inspect the regenerated markdown under docs/...; the manual break should appear as <br />, and render the same on the site.
  4. Optional: run bunx vitest run scripts/notion-fetch/contentSanitizer.test.ts --runInBand --reporter=dot to see the new helper tests pass.

@digidem digidem deleted a comment from github-actions bot Oct 11, 2025
@luandro luandro closed this Oct 31, 2025
@luandro luandro reopened this Oct 31, 2025
@github-actions
Copy link
Contributor

🧹 Preview Deployment Cleanup

The preview deployment for this PR has been cleaned up.

Preview URL was: https://pr-50.comapeo-docs.pages.dev


Note: Cloudflare Pages deployments follow automatic retention policies. Old previews are cleaned up automatically.

@github-actions
Copy link
Contributor

🚀 Preview Deployment

Your documentation preview is ready!

Preview URL: https://pr-50.comapeo-docs.pages.dev

This preview will update automatically when you push new commits to this PR.


Built with commit 899d298

@digidem digidem deleted a comment from github-actions bot Oct 31, 2025
@luandro
Copy link
Contributor Author

luandro commented Oct 31, 2025

Code Review Summary

What This PR Does

This PR restores Notion's "soft line breaks" (created with Shift+Enter) by adding a restoreSoftLineBreaks function that:

  • Converts single newlines within paragraphs to <br /> elements
  • Preserves paragraph breaks (double newlines) as actual line separators
  • Intelligently avoids modifying markdown structural elements (lists, headings, code blocks, etc.)
  • Normalizes Unicode line separators (U+2028, U+2029) to standard newlines
  • Protects fenced code blocks and inline code from being modified

How It Solves the Issue

The implementation uses a sophisticated multi-step approach:

  1. Content Protection: Temporarily replaces fenced code blocks and inline code with placeholders to prevent modification
  2. Unicode Normalization: Converts uncommon Unicode separators to standard \n
  3. Smart Line Break Detection: Uses regex (?<=\S)\n(?=\S) to find single newlines between non-whitespace characters
  4. Context-Aware Filtering: Checks surrounding content to avoid modifying:
    • List items (unnumbered -, *, + and numbered 1., 2.)
    • Code block delimiters and horizontal rules
    • Markdown structural elements
  5. Content Restoration: Replaces placeholders with original code blocks/_spans

Potential Issues & Considerations

Strengths:

  • ✅ Comprehensive test coverage (38 new test cases)
  • ✅ Handles edge cases: code blocks, lists, Unicode separators
  • ✅ Non-destructive - preserves structural markdown
  • ✅ Integrates cleanly into existing pipeline via utils.ts re-export
  • ✅ Follows established patterns (similar to sanitizeMarkdownContent)

Areas to Watch:

Code Quality:

  • Well-documented function with clear purpose
  • Good test structure covering multiple scenarios
  • Proper TypeScript typing
  • Clear variable names and logic flow

Testing:

  • 7 test scenarios covering various edge cases
  • Tests verify both inclusion (single newlines → <br />) and exclusion (paragraph breaks, lists, code blocks)

Recommendation:Approve - Solid implementation with comprehensive tests. However, there's overlap with PR #57 - need to ensure both approaches work together or consolidate the logic to avoid confusion.

@luandro luandro marked this pull request as draft November 5, 2025 13:36
@luandro
Copy link
Contributor Author

luandro commented Nov 5, 2025

duplicate of #57

@luandro luandro closed this Nov 5, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

🧹 Preview Deployment Cleanup

The preview deployment for this PR has been cleaned up.

Preview URL was: https://pr-50.comapeo-docs.pages.dev


Note: Cloudflare Pages deployments follow automatic retention policies. Old previews are cleaned up automatically.

@jencastrodoesstuff
Copy link
Contributor

@luandro I see here you did the fix, but I don't see the results because it was part of unmerged commits

@jencastrodoesstuff
Copy link
Contributor

This is still not resolved.
Note the difference between notion and the browser.

Screenshot 2025-12-11 at 10 31 40 AM

luandro added a commit that referenced this pull request Feb 8, 2026
…ness

Comprehensive approval of production deployment readiness for the CoMapeo
Documentation API Service after thorough review of all deployment materials,
documentation, and operational procedures.

## Production Checklist Approval ✅

- Verified all 10 production checklist items are complete and documented
- Validated coverage: environment variables, firewall, SSL/TLS, authentication,
  resource limits, health checks, log rotation, backups, monitoring, documentation
- Confirmed executable verification commands for each checklist item

## Operational Readiness Approval ✅

- Reviewed deployment runbook for first-time operator friendliness
- Validated 5-part phased approach with verification steps at each stage
- Confirmed 15+ verification points with expected outputs
- Documented 8 common troubleshooting scenarios with solutions
- Tested all container management commands (start, stop, restart, logs, update)

## Security & Reliability Approval ✅

- Validated Docker security hardening (non-root user, minimal base image)
- Confirmed resource limits (CPU: 1 core, Memory: 512M)
- Verified restart policy (unless-stopped) for automatic recovery
- Approved log rotation configuration (10MB × 3 files)
- Validated backup strategy for job persistence data

## GitHub Integration Approval ✅

- Reviewed GitHub Setup Guide completeness (17 checklist items)
- Validated GitHub Actions workflows with proper secret handling
- Confirmed production deployment workflow with environment protection
- Approved Notion status integration (Staging → Published)

## Test Coverage Approval ✅

- All deployment documentation tests pass (130 assertions)
- VPS deployment docs validated (468 lines of tests)
- Deployment runbook validated (515 lines of tests)
- Total: 1116 tests passed across all API server test suites

Related to: Task #50 in PRD.md
luandro added a commit that referenced this pull request Feb 13, 2026
…ness

Comprehensive approval of production deployment readiness for the CoMapeo
Documentation API Service after thorough review of all deployment materials,
documentation, and operational procedures.

## Production Checklist Approval ✅

- Verified all 10 production checklist items are complete and documented
- Validated coverage: environment variables, firewall, SSL/TLS, authentication,
  resource limits, health checks, log rotation, backups, monitoring, documentation
- Confirmed executable verification commands for each checklist item

## Operational Readiness Approval ✅

- Reviewed deployment runbook for first-time operator friendliness
- Validated 5-part phased approach with verification steps at each stage
- Confirmed 15+ verification points with expected outputs
- Documented 8 common troubleshooting scenarios with solutions
- Tested all container management commands (start, stop, restart, logs, update)

## Security & Reliability Approval ✅

- Validated Docker security hardening (non-root user, minimal base image)
- Confirmed resource limits (CPU: 1 core, Memory: 512M)
- Verified restart policy (unless-stopped) for automatic recovery
- Approved log rotation configuration (10MB × 3 files)
- Validated backup strategy for job persistence data

## GitHub Integration Approval ✅

- Reviewed GitHub Setup Guide completeness (17 checklist items)
- Validated GitHub Actions workflows with proper secret handling
- Confirmed production deployment workflow with environment protection
- Approved Notion status integration (Staging → Published)

## Test Coverage Approval ✅

- All deployment documentation tests pass (130 assertions)
- VPS deployment docs validated (468 lines of tests)
- Deployment runbook validated (515 lines of tests)
- Total: 1116 tests passed across all API server test suites

Related to: Task #50 in PRD.md
@luandro luandro deleted the fix/notion-soft-line-breaks branch February 13, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preserve manual line breaks from Notion in generated Markdown

2 participants